Build binaries on github #6
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: Rust | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Clone repository | |
| uses: actions/checkout@v4 | |
| - name: Install Cross Compilation Targets | |
| run: | | |
| rustup target add x86_64-unknown-linux-gnu | |
| rustup target add aarch64-unknown-linux-gnu | |
| rustup target add x86_64-apple-darwin | |
| rustup target add aarch64-apple-darwin | |
| rustup target add x86_64-pc-windows-gnu | |
| rustup target add aarch64-pc-windows-msvc | |
| - name: Build Binaries | |
| run: | | |
| version="${{ github.event.inputs.version }}" | |
| [ -z "$version" ] && version="latest" | |
| mkdir -p bin | |
| architectures=("x86_64" "aarch64") | |
| for arch in "${architectures[@]}"; do | |
| cargo build --release --target x86_64-unknown-linux-gnu | |
| mv target/x86_64-unknown-linux-gnu/release/my_rust_program bin/my_rust_program-$version-linux-$arch | |
| cargo build --release --target aarch64-unknown-linux-gnu | |
| mv target/aarch64-unknown-linux-gnu/release/my_rust_program bin/my_rust_program-$version-linux-$arch | |
| cargo build --release --target x86_64-apple-darwin | |
| mv target/x86_64-apple-darwin/release/my_rust_program bin/my_rust_program-$version-darwin-$arch | |
| cargo build --release --target aarch64-apple-darwin | |
| mv target/aarch64-apple-darwin/release/my_rust_program bin/my_rust_program-$version-darwin-$arch | |
| cargo build --release --target x86_64-pc-windows-gnu | |
| mv target/x86_64-pc-windows-gnu/release/my_rust_program.exe bin/my_rust_program-$version-windows-$arch.exe | |
| done | |
| echo "ARTIFACT_NAME=my_rust_program-$(date +'%d.%m.%Y')" >> $GITHUB_ENV | |
| - name: Upload Binaries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: bin/ |