From f5b4470fec249065df5ee1314be66c6641c419f5 Mon Sep 17 00:00:00 2001 From: jacoby Date: Sun, 22 Dec 2024 23:39:37 -0500 Subject: [PATCH] fix: enhance build workflow to extract and validate version from metadata --- .github/workflows/build.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b0521d..f69cdc4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,12 +19,18 @@ jobs: - run: rustup toolchain install stable --profile minimal - uses: Swatinem/rust-cache@v2 + - name: Metadata + run: cargo metadata --no-deps --format-version 1 > metadata.json + - name: Extract Version - id: version + run: echo "VERSION=$(jq -r '.packages[0].version' metadata.json)" >> $GITHUB_ENV + + - name: Check Version run: | - $VERSION = cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version' - echo "Latest version: $VERSION" - echo "VERSION=$VERSION" >> $GITHUB_ENV + if [ -z "$VERSION" ]; then + echo "No version found, skipping release" + exit 1 + fi - name: Build run: cargo build --release --verbose @@ -45,6 +51,7 @@ jobs: powershell -Command "Compress-Archive -Path target/release/lunar-stitch.exe -DestinationPath release/lunar-stitch-${{ env.VERSION }}-windows.zip" - name: Release + if: env.VERSION != 'none' uses: softprops/action-gh-release@v2 with: token: ${{ secrets.GITHUB_TOKEN }}