Add tests #10
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: Build binaries | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| - aarch64-unknown-linux-gnu | |
| - x86_64-unknown-linux-musl | |
| - x86_64-pc-windows-gnu | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install target toolchain | |
| run: rustup target add ${{ matrix.target }} | |
| - name: Install linker for cross targets | |
| run: | | |
| case "${{ matrix.target }}" in | |
| x86_64-pc-windows-gnu) | |
| sudo apt-get update && sudo apt-get install -y mingw-w64 | |
| ;; | |
| aarch64-unknown-linux-gnu) | |
| sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu | |
| ;; | |
| x86_64-unknown-linux-musl|aarch64-unknown-linux-musl) | |
| sudo apt-get update && sudo apt-get install -y musl-tools | |
| ;; | |
| esac | |
| - name: Prepare binary source | |
| run: | | |
| mkdir -p src/bin | |
| cp src/hashimmut.rs src/bin/ | |
| - name: Build binary | |
| run: | | |
| if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then | |
| export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
| fi | |
| if [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then | |
| export CC=musl-gcc | |
| fi | |
| cargo build --release --target=${{ matrix.target }} | |
| BIN="target/${{ matrix.target }}/release/hashimmut" | |
| OUT="" | |
| case "${{ matrix.target }}" in | |
| x86_64-pc-windows-gnu) | |
| OUT="hashimmut-win-amd64.exe" | |
| mv "${BIN}.exe" "${OUT}" | |
| ;; | |
| x86_64-unknown-linux-gnu) | |
| OUT="hashimmut-linux-amd64" | |
| mv "${BIN}" "${OUT}" | |
| ;; | |
| aarch64-unknown-linux-gnu) | |
| OUT="hashimmut-linux-arm64" | |
| mv "${BIN}" "${OUT}" | |
| ;; | |
| x86_64-unknown-linux-musl) | |
| OUT="hashimmut-linux-amd64-musl" | |
| mv "${BIN}" "${OUT}" | |
| ;; | |
| esac | |
| echo "BUILT_FILE=${OUT}" >> $GITHUB_ENV | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-${{ matrix.target }} | |
| path: ${{ env.BUILT_FILE }} | |
| merge-artifacts: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Windows binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: binary-x86_64-pc-windows-gnu | |
| path: combined-binaries | |
| - name: Download Linux amd64 binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: binary-x86_64-unknown-linux-gnu | |
| path: combined-binaries | |
| - name: Download Linux arm64 binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: binary-aarch64-unknown-linux-gnu | |
| path: combined-binaries | |
| - name: Download Linux amd64 musl binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: binary-x86_64-unknown-linux-musl | |
| path: combined-binaries | |
| - name: Upload combined binaries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries | |
| path: combined-binaries |