Skip to content

Commit 32aaffd

Browse files
committed
fix (ci): refactored Binaries workflow yml to first build upon maturin and extract from that, for binaries that allow maturin build, created a separate step for those which can't be build by maturin
Signed-off-by: rafaeljohn9 <rafaeljohb@gmail.com>
1 parent 135f5b1 commit 32aaffd

1 file changed

Lines changed: 52 additions & 41 deletions

File tree

.github/workflows/build-binaries.yml

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
build:
15-
# Linux glibc
15+
# Linux glibc (64-bit only)
1616
- { NAME: linux-x64-glibc, OS: ubuntu-22.04, TARGET: x86_64-unknown-linux-gnu, BUILD_WHEEL: true }
17-
- { NAME: linux-x86-glibc, OS: ubuntu-22.04, TARGET: i686-unknown-linux-gnu, BUILD_WHEEL: true }
1817
- { NAME: linux-arm64-glibc, OS: ubuntu-22.04, TARGET: aarch64-unknown-linux-gnu, BUILD_WHEEL: true }
1918

20-
# Linux musl (static)
19+
# Linux musl (64-bit only) → no wheels
2120
- { NAME: linux-x64-musl, OS: ubuntu-22.04, TARGET: x86_64-unknown-linux-musl, BUILD_WHEEL: false }
22-
- { NAME: linux-x86-musl, OS: ubuntu-22.04, TARGET: i686-unknown-linux-musl, BUILD_WHEEL: false }
2321
- { NAME: linux-arm64-musl, OS: ubuntu-22.04, TARGET: aarch64-unknown-linux-musl, BUILD_WHEEL: false }
2422

25-
# Windows (MSVC)
23+
# Windows (64-bit only)
2624
- { NAME: windows-x64-msvc, OS: windows-latest, TARGET: x86_64-pc-windows-msvc, BUILD_WHEEL: true }
27-
- { NAME: windows-x86-msvc, OS: windows-latest, TARGET: i686-pc-windows-msvc, BUILD_WHEEL: true }
28-
# ⚠️ Skip Windows ARM64 for wheels (maturin doesn't support it yet)
25+
# Skip Windows ARM64 wheels (maturin limitation)
2926
- { NAME: windows-arm64-msvc, OS: windows-latest, TARGET: aarch64-pc-windows-msvc, BUILD_WHEEL: false }
3027

3128
# macOS
@@ -40,22 +37,20 @@ jobs:
4037
with:
4138
targets: ${{ matrix.build.TARGET }}
4239

43-
- name: Install cross (Linux only)
44-
if: runner.os == 'Linux'
45-
run: cargo install cross --git https://github.com/cross-rs/cross
46-
47-
# === BUILD RUST BINARY ===
48-
- name: Build binary
49-
shell: bash
40+
# === HANDLE WHEEL TARGETS (maturin-controlled build) ===
41+
- name: Setup for maturin build (wheel targets)
42+
if: matrix.build.BUILD_WHEEL == true
5043
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
44+
# Install maturin and cross (maturin will use cross internally)
45+
pip install maturin
46+
cargo install cross --locked
47+
48+
- name: Build with maturin (for wheel targets)
49+
if: matrix.build.BUILD_WHEEL == true
50+
run: maturin build --release --target ${{ matrix.build.TARGET }}
5651

57-
# === PREPARE RAW BINARY ARTIFACT ===
58-
- name: Prepare raw binary artifact
52+
- name: Extract raw binary (from maturin build)
53+
if: matrix.build.BUILD_WHEEL == true
5954
shell: bash
6055
run: |
6156
BINARY_NAME="gitcraft"
@@ -69,40 +64,56 @@ jobs:
6964
echo "BINARY_ARTIFACT=gitcraft-${{ matrix.build.NAME }}" >> $GITHUB_ENV
7065
fi
7166
72-
- name: Upload raw binary artifact
67+
- name: Upload raw binary (wheel targets)
68+
if: matrix.build.BUILD_WHEEL == true
7369
uses: actions/upload-artifact@v4
7470
with:
7571
name: binary-${{ matrix.build.NAME }}
7672
path: ${{ env.BINARY_ARTIFACT }}
7773
if-no-files-found: error
7874

79-
# === BUILD PYTHON WHEEL (if enabled) ===
80-
- name: Setup Python for maturin
75+
- name: Upload Python wheel
8176
if: matrix.build.BUILD_WHEEL == true
82-
uses: actions/setup-python@v5
77+
uses: actions/upload-artifact@v4
8378
with:
84-
python-version: '3.11'
79+
name: wheels-${{ matrix.build.NAME }}
80+
path: target/wheels/*.whl
81+
if-no-files-found: error
8582

86-
- name: Install maturin
87-
if: matrix.build.BUILD_WHEEL == true
88-
run: pip install maturin
83+
# === HANDLE NON-WHEEL TARGETS (musl) ===
84+
- name: Install cross (for non-wheel Linux targets)
85+
if: matrix.build.BUILD_WHEEL == false && runner.os == 'Linux'
86+
run: cargo install cross --locked
8987

90-
- name: Build Python wheel with maturin
91-
if: matrix.build.BUILD_WHEEL == true
88+
- name: Build binary (non-wheel targets)
89+
if: matrix.build.BUILD_WHEEL == false
90+
shell: bash
91+
run: |
92+
if [[ "${{ runner.os }}" == "Linux" ]]; then
93+
cross build --release --target ${{ matrix.build.TARGET }}
94+
else
95+
cargo build --release --target ${{ matrix.build.TARGET }}
96+
fi
97+
98+
- name: Prepare raw binary artifact (non-wheel)
99+
if: matrix.build.BUILD_WHEEL == false
92100
shell: bash
93101
run: |
94-
# Ensure pyproject.toml exists and has bindings = "bin"
95-
maturin build --release --target ${{ matrix.build.TARGET }}
96-
# Verify wheel exists
97-
if [ ! -d "target/wheels" ] || [ -z "$(ls target/wheels/*.whl 2>/dev/null)" ]; then
98-
echo "❌ No wheel found after maturin build!"
99-
exit 1
102+
BINARY_NAME="gitcraft"
103+
if [[ "${{ matrix.build.TARGET }}" == *"windows"* ]]; then
104+
BINARY_NAME="${BINARY_NAME}.exe"
105+
cp "target/${{ matrix.build.TARGET }}/release/gitcraft.exe" "./gitcraft-${{ matrix.build.NAME }}.exe"
106+
echo "BINARY_ARTIFACT=gitcraft-${{ matrix.build.NAME }}.exe" >> $GITHUB_ENV
107+
else
108+
cp "target/${{ matrix.build.TARGET }}/release/gitcraft" "./gitcraft-${{ matrix.build.NAME }}"
109+
chmod +x "./gitcraft-${{ matrix.build.NAME }}"
110+
echo "BINARY_ARTIFACT=gitcraft-${{ matrix.build.NAME }}" >> $GITHUB_ENV
100111
fi
101112
102-
- name: Upload Python wheel artifact
103-
if: matrix.build.BUILD_WHEEL == true
113+
- name: Upload raw binary artifact (non-wheel)
114+
if: matrix.build.BUILD_WHEEL == false
104115
uses: actions/upload-artifact@v4
105116
with:
106-
name: wheels-${{ matrix.build.NAME }}
107-
path: target/wheels/*.whl
117+
name: binary-${{ matrix.build.NAME }}
118+
path: ${{ env.BINARY_ARTIFACT }}
108119
if-no-files-found: error

0 commit comments

Comments
 (0)