fix: release action #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| release: | |
| name: Release - ${{ matrix.os }} (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: linux | |
| arch: x86_64 | |
| runner: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| binary_name: ci | |
| asset_name: ci-linux-x86_64 | |
| - os: linux | |
| arch: aarch64 | |
| runner: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| binary_name: ci | |
| asset_name: ci-linux-aarch64 | |
| - os: windows | |
| arch: x86_64 | |
| runner: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| binary_name: ci.exe | |
| asset_name: ci-windows-x86_64.exe | |
| - os: windows | |
| arch: aarch64 | |
| runner: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| binary_name: ci.exe | |
| asset_name: ci-windows-aarch64.exe | |
| - os: macos | |
| arch: x86_64 | |
| runner: macos-latest | |
| target: x86_64-apple-darwin | |
| binary_name: ci | |
| asset_name: ci-macos-x86_64 | |
| - os: macos | |
| arch: aarch64 | |
| runner: macos-latest | |
| target: aarch64-apple-darwin | |
| binary_name: ci | |
| asset_name: ci-macos-aarch64 | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v4 | |
| - name: Set variables | |
| id: vars | |
| shell: bash | |
| run: | | |
| echo "package_name=$(sed -En 's/name[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_OUTPUT | |
| echo "package_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools (Linux ARM64) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Configure cross-compilation (Linux ARM64) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml | |
| echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config.toml | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.target }}-cargo- | |
| - name: Build release binary | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Upload binary as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: target/${{ matrix.target }}/release/${{ matrix.binary_name }} | |
| create-release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: release | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v4 | |
| - name: Set variables | |
| id: vars | |
| run: | | |
| echo "package_name=$(sed -En 's/name[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_OUTPUT | |
| echo "package_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create Release and Upload Assets | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG: ${{ steps.vars.outputs.package_version }} | |
| PACKAGE_NAME: ${{ steps.vars.outputs.package_name }} | |
| run: | | |
| # Delete existing release if exists | |
| gh release delete "$TAG" --yes || true | |
| # Create release | |
| gh release create "$TAG" \ | |
| --title "Version $TAG" \ | |
| --notes "$PACKAGE_NAME - $TAG" \ | |
| artifacts/ci-linux-x86_64/ci \ | |
| artifacts/ci-linux-aarch64/ci \ | |
| artifacts/ci-windows-x86_64.exe/ci.exe \ | |
| artifacts/ci-windows-aarch64.exe/ci.exe \ | |
| artifacts/ci-macos-x86_64/ci \ | |
| artifacts/ci-macos-aarch64/ci | |
| - name: Purge artifacts | |
| uses: omarabid-forks/purge-artifacts@v1 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| expire-in: 0 |