1+ name : Build Binaries
2+
3+ on :
4+ push :
5+ tags :
6+ - v[0-9]+.[0-9]+.[0-9]+
7+ workflow_dispatch :
8+
9+ jobs :
10+ build-binaries :
11+ name : Build ${{ matrix.build.NAME }}
12+ runs-on : ${{ matrix.build.OS }}
13+ strategy :
14+ fail-fast : false
15+ matrix :
16+ build :
17+ # Linux glibc
18+ - { NAME: linux-x64-glibc, OS: ubuntu-22.04, TARGET: x86_64-unknown-linux-gnu }
19+ - { NAME: linux-x86-glibc, OS: ubuntu-22.04, TARGET: i686-unknown-linux-gnu }
20+ - { NAME: linux-arm64-glibc, OS: ubuntu-22.04, TARGET: aarch64-unknown-linux-gnu }
21+
22+ # Linux musl (fully static)
23+ - { NAME: linux-x64-musl, OS: ubuntu-22.04, TARGET: x86_64-unknown-linux-musl }
24+ - { NAME: linux-x86-musl, OS: ubuntu-22.04, TARGET: i686-unknown-linux-musl }
25+ - { NAME: linux-arm64-musl, OS: ubuntu-22.04, TARGET: aarch64-unknown-linux-musl }
26+
27+ # Windows
28+ - { NAME: windows-x64-msvc, OS: windows-latest, TARGET: x86_64-pc-windows-msvc }
29+ - { NAME: windows-x86-msvc, OS: windows-latest, TARGET: i686-pc-windows-msvc }
30+ - { NAME: windows-arm64-msvc, OS: windows-latest, TARGET: aarch64-pc-windows-msvc }
31+
32+ # macOS
33+ - { NAME: darwin-x64, OS: macos-15, TARGET: x86_64-apple-darwin }
34+ - { NAME: darwin-arm64, OS: macos-15, TARGET: aarch64-apple-darwin }
35+
36+ steps :
37+ - uses : actions/checkout@v4
38+
39+ - name : Setup Rust
40+ uses : dtolnay/rust-toolchain@stable
41+ with :
42+ targets : ${{ matrix.build.TARGET }}
43+
44+ - name : Install cross (Linux only)
45+ if : runner.os == 'Linux'
46+ run : cargo install cross --git https://github.com/cross-rs/cross
47+
48+ - name : Build binary
49+ shell : bash
50+ run : |
51+ if [[ "${{ runner.os }}" == "Linux" ]]; then
52+ cross build --release --target ${{ matrix.build.TARGET }}
53+ else
54+ cargo build --release --target ${{ matrix.build.TARGET }}
55+ fi
56+
57+ - name : Prepare artifact
58+ shell : bash
59+ run : |
60+ BINARY_NAME="gitcraft"
61+ if [[ "${{ matrix.build.TARGET }}" == *"windows"* ]]; then
62+ BINARY_NAME="${BINARY_NAME}.exe"
63+ cp "target/${{ matrix.build.TARGET }}/release/gitcraft.exe" "./gitcraft-${{ matrix.build.NAME }}.exe"
64+ echo "ARTIFACT_FILE=gitcraft-${{ matrix.build.NAME }}.exe" >> $GITHUB_ENV
65+ else
66+ cp "target/${{ matrix.build.TARGET }}/release/gitcraft" "./gitcraft-${{ matrix.build.NAME }}"
67+ chmod +x "./gitcraft-${{ matrix.build.NAME }}"
68+ echo "ARTIFACT_FILE=gitcraft-${{ matrix.build.NAME }}" >> $GITHUB_ENV
69+ fi
70+
71+ - name : Upload binary as artifact
72+ uses : actions/upload-artifact@v4
73+ with :
74+ name : binary-${{ matrix.build.NAME }}
75+ path : ${{ env.ARTIFACT_FILE }}
76+ if-no-files-found : error
0 commit comments