From 9562f307b715a04ed887ad6b903d808cc48eb4a7 Mon Sep 17 00:00:00 2001 From: Oliver Stenbom Date: Wed, 8 Nov 2023 14:38:05 +0100 Subject: [PATCH] Get release version from Cargo toml (#44) --- .github/workflows/release.yml | 19 +++++++++++++------ Cargo.lock | 2 +- linkup-cli/Cargo.toml | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e199a6..974315a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,11 @@ name: Create Release on: - workflow_dispatch: - inputs: - tag: - description: "Tag to use for the new release" - required: true + push: + branches: + - main + paths: + - "linkup-cli/Cargo.toml" jobs: publish-to-github: @@ -58,6 +58,12 @@ jobs: - name: Build run: cargo build --release --manifest-path linkup-cli/Cargo.toml --target ${{ matrix.target }} + - name: Get Version from Cargo.toml + id: get_version + run: | + VERSION=$(grep '^version = ' linkup-cli/Cargo.toml | sed -E 's/version = "(.*)"/\1/') + echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV + - name: Package Artifacts run: | src=$(pwd) @@ -74,7 +80,8 @@ jobs: cp target/${{ matrix.target }}/release/linkup $stage/ cd $stage - RELEASE_VERSION=${{ github.event.inputs.tag }} + # Use the version from the environment variable + RELEASE_VERSION=${{ env.RELEASE_VERSION }} ASSET_NAME="linkup-$RELEASE_VERSION-${{ matrix.target }}.tar.gz" ASSET_PATH="$src/$ASSET_NAME" CHECKSUM_PATH="$ASSET_PATH.sha256" diff --git a/Cargo.lock b/Cargo.lock index 979d986..90f9acd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1043,7 +1043,7 @@ dependencies = [ [[package]] name = "linkup-cli" -version = "0.1.0" +version = "0.1.14" dependencies = [ "actix-web", "clap", diff --git a/linkup-cli/Cargo.toml b/linkup-cli/Cargo.toml index 0d40685..afdc816 100644 --- a/linkup-cli/Cargo.toml +++ b/linkup-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "linkup-cli" -version = "0.1.0" +version = "0.1.14" edition = "2021" [[bin]]