From f837314f5c63879c6b5eb155024940308400665f Mon Sep 17 00:00:00 2001 From: Gronod Date: Sat, 5 Sep 2026 17:48:53 +0100 Subject: [PATCH] ci(gitea): build intel and arm64 in matrix and merge into universal binary --- .gitea/workflows/build-macos.yml | 132 ++++++++++++++++++++++++++++--- 1 file changed, 123 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/build-macos.yml b/.gitea/workflows/build-macos.yml index 362008c..f6efac7 100644 --- a/.gitea/workflows/build-macos.yml +++ b/.gitea/workflows/build-macos.yml @@ -1,4 +1,4 @@ -name: macOS x86_64 Release Build +name: macOS Release Build on: push: @@ -8,6 +8,15 @@ on: jobs: build: + strategy: + matrix: + include: + - arch: x86_64 + machtype: x86_64-apple-darwin + artifact: macOS_x86_64_bin + - arch: arm64 + machtype: arm64-apple-darwin + artifact: macOS_arm64_bin runs-on: macos steps: @@ -29,8 +38,8 @@ jobs: run: | export PATH="$HOME/.local/bin:/usr/local/bin:$PATH" export OSTYPE=darwin - export MACHTYPE=x86_64-apple-darwin - export HOSTTYPE=x86_64 + export MACHTYPE=${{ matrix.machtype }} + export HOSTTYPE=${{ matrix.arch }} export CCOPTFLAG="-O0 -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -Wno-error=implicit-int" jam -q -d2 -fJambase -j1 -sBUILTIN_TIFF=true -sBUILTIN_JPEG=true -sBUILTIN_PNG=true -sBUILTIN_Z=true -sBUILTIN_SSL=true install @@ -58,21 +67,27 @@ jobs: run: | export PATH="$HOME/.local/bin:/usr/local/bin:$PATH" export OSTYPE=darwin - export MACHTYPE=x86_64-apple-darwin - export HOSTTYPE=x86_64 + export MACHTYPE=${{ matrix.machtype }} + export HOSTTYPE=${{ matrix.arch }} export CCOPTFLAG="-O0 -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -Wno-error=implicit-int" export NO_BUILD=1 ./makepackagebin.sh TAG="${{ github.ref_name }}" SHORT_SHA="$(git rev-parse --short HEAD)" echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV - mv Argyll_V*_macOS_x86_64_bin.tgz "Argyll_${TAG}_${SHORT_SHA}_macOS_x86_64_bin.tgz" + mv Argyll_V*_${{ matrix.artifact }}.tgz "Argyll_${TAG}_${SHORT_SHA}_${{ matrix.artifact }}.tgz" + + - name: Upload Raw Binaries + uses: actions/upload-artifact@v3 + with: + name: raw-bin-${{ matrix.arch }} + path: bin/ - name: Upload Artifact uses: actions/upload-artifact@v3 with: - name: Argyll_${{ github.ref_name }}_${{ env.SHORT_SHA }}_macOS_x86_64_bin - path: Argyll_*_macOS_x86_64_bin.tgz + name: Argyll_${{ github.ref_name }}_${{ env.SHORT_SHA }}_${{ matrix.artifact }} + path: Argyll_*_${{ matrix.artifact }}.tgz - name: Upload Release Asset if: startsWith(github.ref, 'refs/tags/') @@ -81,4 +96,103 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} name: Release ${{ github.ref_name }} body: "Release ${{ github.ref_name }} built from commit ${{ github.sha }}" - files: Argyll_*_macOS_x86_64_bin.tgz + files: Argyll_*_${{ matrix.artifact }}.tgz + + universal: + needs: build + runs-on: macos + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download x86_64 binaries + uses: actions/download-artifact@v3 + with: + name: raw-bin-x86_64 + path: raw-bin-x86_64 + + - name: Download arm64 binaries + uses: actions/download-artifact@v3 + with: + name: raw-bin-arm64 + path: raw-bin-arm64 + + - name: Create Universal Binaries + run: | + mkdir -p bin + for file in raw-bin-arm64/*; do + bin_name=$(basename "$file") + if [ -f "raw-bin-x86_64/$bin_name" ]; then + if file "raw-bin-arm64/$bin_name" | grep -q "Mach-O" && file "raw-bin-x86_64/$bin_name" | grep -q "Mach-O"; then + echo "Creating universal binary with lipo: $bin_name" + lipo -create "raw-bin-x86_64/$bin_name" "raw-bin-arm64/$bin_name" -output "bin/$bin_name" + chmod +x "bin/$bin_name" + codesign -f -s - "bin/$bin_name" + else + echo "Non Mach-O file, copying directly: $bin_name" + cp "$file" "bin/$bin_name" + fi + else + echo "Warning: $bin_name not found in raw-bin-x86_64, copying arm64 version" + cp "$file" "bin/$bin_name" + if file "bin/$bin_name" | grep -q "Mach-O"; then + codesign -f -s - "bin/$bin_name" + fi + fi + done + for file in raw-bin-x86_64/*; do + bin_name=$(basename "$file") + if [ ! -f "bin/$bin_name" ]; then + echo "Warning: $bin_name only found in raw-bin-x86_64, copying x86_64 version" + cp "$file" "bin/$bin_name" + if file "bin/$bin_name" | grep -q "Mach-O"; then + codesign -f -s - "bin/$bin_name" + fi + fi + done + + - name: Verify Architecture & Code Signatures + env: + ARGYLL_NOT_INTERACTIVE: "1" + ARGYLL_EXCLUDE_SERIAL_SCAN: "1" + run: | + echo "=== Binary Architecture & Signature Verification ===" + for file in bin/*; do + if [ -f "$file" ] && file "$file" | grep -q "Mach-O"; then + file "$file" + codesign -dvv "$file" + fi + done + echo "=== Smoke Tests ===" + ./bin/dispcal -? || true + ./bin/chartread -? || true + ./bin/colprof -? || true + ./bin/targen -? || true + + - name: Package Universal Release + run: | + export OSTYPE=darwin + export MACHTYPE=universal-apple-darwin + export HOSTTYPE=universal + export NO_BUILD=1 + ./makepackagebin.sh + TAG="${{ github.ref_name }}" + SHORT_SHA="$(git rev-parse --short HEAD)" + echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV + mv Argyll_V*_macOS_universal_bin.tgz "Argyll_${TAG}_${SHORT_SHA}_macOS_universal_bin.tgz" + + - name: Upload Universal Artifact + uses: actions/upload-artifact@v3 + with: + name: Argyll_${{ github.ref_name }}_${{ env.SHORT_SHA }}_macOS_universal_bin + path: Argyll_*_macOS_universal_bin.tgz + + - name: Upload Universal Release Asset + if: startsWith(github.ref, 'refs/tags/') + uses: akkuman/gitea-release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: Release ${{ github.ref_name }} + body: "Release ${{ github.ref_name }} built from commit ${{ github.sha }}" + files: Argyll_*_macOS_universal_bin.tgz -- 2.39.5