From 7895f4d2625c3c8f2c3e84e7ac3fc8b99e6fcb6e Mon Sep 17 00:00:00 2001 From: Ewart Nijburg Date: Mon, 30 Mar 2026 17:33:39 +0200 Subject: [PATCH] Revise release workflow to mimic tag build/release pipeline --- .github/workflows/release.yml | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3c42d2d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,105 @@ +name: Release Build + +on: + push: + tags: + - 'v*' + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +permissions: + contents: write + +jobs: + build: + name: Build - ${{ matrix.platform.target }} + runs-on: ${{ matrix.platform.os }} + + strategy: + fail-fast: false + matrix: + platform: + - name: Windows x86_64 + os: windows-latest + target: x86_64-pc-windows-msvc + binary_ext: ".exe" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Validate semantic version tag + if: startsWith(github.ref, 'refs/tags/') + shell: bash + run: | + TAG="${GITHUB_REF_NAME}" + if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then + echo "Tag '$TAG' is not a valid semantic version (expected e.g. v1.2.3)." + exit 1 + fi + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.platform.target }} + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v4 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Build + run: cargo build --release --target ${{ matrix.platform.target }} + + - name: Package binary + shell: pwsh + run: | + $binaryName = "lfv${{ matrix.platform.binary_ext }}" + $binaryPath = "target/${{ matrix.platform.target }}/release/$binaryName" + $archiveName = "lfv-${{ matrix.platform.target }}.zip" + + New-Item -ItemType Directory -Path dist -Force | Out-Null + Compress-Archive -Path $binaryPath -DestinationPath "dist/$archiveName" -Force + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: lfv-${{ matrix.platform.target }} + path: dist/* + if-no-files-found: error + + release: + name: Create Release + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Upload artifacts to release page + uses: softprops/action-gh-release@v2 + with: + files: artifacts/**/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}