Rust build-and-release #87
This file contains 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: Rust build-and-release | |
on: | |
workflow_dispatch: # Manually triggered | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
outputs: | |
cargo_version: ${{ steps.cargo_version.outputs.t_cargo_version }} # Expose version to other jobs | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust target | |
run: rustup target add ${{ matrix.target }} | |
- name: Install cross (for cross-compilation) | |
run: cargo install cross --git https://github.com/cross-rs/cross | |
- name: Get Version from Cargo.toml | |
id: cargo_version | |
run: | | |
THE_VERSION_STRING=$(grep '^version' Cargo.toml | cut -d '=' -f2 | tr -d ' "') | |
echo "::set-output name=t_cargo_version::$THE_VERSION_STRING" | |
- name: Build | |
run: cross build --release --target=${{ matrix.target }} | |
- name: Zip Binary | |
uses: vimtor/action-zip@v1 | |
with: | |
files: target/${{ matrix.target }}/release/limonium | |
dest: target/${{ matrix.target }}/release/limonium-${{ matrix.target }}.zip | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: limonium-${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/limonium-${{ matrix.target }}.zip | |
release: | |
needs: build | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Deploy Release With Artifacts | |
uses: marvinpinto/action-automatic-releases@latest | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "${{ needs.build.outputs.cargo_version }}" # Use version from build | |
prerelease: false | |
files: artifacts/** |