diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7530f187..2a0e749a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,11 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] + include: + - os: ubuntu-latest + targets: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] + - os: macOS-latest + - os: windows-latest runs-on: ${{ matrix.os }} env: MACOSX_DEPLOYMENT_TARGET: 11.0 @@ -45,72 +49,68 @@ jobs: if: runner.os == 'Linux' run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libssl-dev libasound2-dev - - name: Run Tests - run: cargo test - continue-on-error: true + - name: Setup ARM Linux build environment + if: runner.os == 'Linux' + run: | + sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user-static + rustup target add aarch64-unknown-linux-gnu - - name: Build Release - if: runner.os != 'macOS' - run: cargo build --release + - name: Build and Package (Linux) + if: runner.os == 'Linux' + run: | + targets=("x86_64-unknown-linux-gnu" "aarch64-unknown-linux-gnu") + + for target in "${targets[@]}"; do + cargo build --release --target $target + arch=$(echo $target | cut -d'-' -f1) + chmod +x target/$target/release/psst-gui + zip -j psst-gui-$arch.zip target/$target/release/psst-gui + echo "artifact_$arch=psst-gui-$arch.zip" >> $GITHUB_OUTPUT + done - - name: Build x86_64 and aarch64 for macOS + - name: Build and Package (macOS) if: runner.os == 'macOS' run: | - rustup target add x86_64-apple-darwin aarch64-apple-darwin - cargo build --release --target x86_64-apple-darwin --target aarch64-apple-darwin + targets=("x86_64-apple-darwin" "aarch64-apple-darwin") - - name: Cache cargo-bundle - if: runner.os == 'macOS' - id: cache-cargo-bundle - uses: actions/cache@v4 - with: - path: ~/.cargo/bin/cargo-bundle - key: ${{ runner.os }}-cargo-bundle-${{ hashFiles('**/Cargo.lock') }} + for target in "${targets[@]}"; do + rustup target add $target + cargo build --release --target $target + done - - name: Install cargo-bundle - if: runner.os == 'macOS' && steps.cache-cargo-bundle.outputs.cache-hit != 'true' - run: cargo install cargo-bundle + lipo -create -output target/release/psst-gui \ + target/x86_64-apple-darwin/release/psst-gui \ + target/aarch64-apple-darwin/release/psst-gui - - name: Bundle macOS Release - if: runner.os == 'macOS' - run: cargo bundle --release - working-directory: psst-gui + # Bundle the app + cargo bundle --release - - name: Create macOS universal binary - if: runner.os == 'macOS' - run: | + # Create universal binary in the bundle lipo -create -output target/release/bundle/osx/Psst.app/Contents/MacOS/psst-gui \ target/x86_64-apple-darwin/release/psst-gui \ target/aarch64-apple-darwin/release/psst-gui - - name: Create macOS Disk Image - if: runner.os == 'macOS' - run: hdiutil create -volname "Psst" -srcfolder target/release/bundle/osx -ov -format UDZO Psst.dmg + # Create DMG + hdiutil create -volname "Psst" -srcfolder target/release/bundle/osx -ov -format UDZO Psst.dmg - - name: Upload macOS Disk Image - uses: actions/upload-artifact@v4 - if: runner.os == 'macOS' - with: - name: Psst.dmg - path: ./Psst.dmg + # Zip the DMG + zip -j Psst.dmg.zip Psst.dmg + echo "artifact_macos=Psst.dmg.zip" >> $GITHUB_OUTPUT - - name: Make Linux Binary Executable - if: runner.os == 'Linux' - run: chmod +x target/release/psst-gui - - - name: Upload Linux Binary - uses: actions/upload-artifact@v4 - if: runner.os == 'Linux' - with: - name: psst-gui - path: target/release/psst-gui + - name: Build and Package (Windows) + if: runner.os == 'Windows' + run: | + cargo build --release + zip -j psst-gui-win64.zip target/release/psst-gui.exe + echo "artifact_win64=psst-gui-win64.zip" >> $GITHUB_OUTPUT - - name: Upload Windows Executable + - name: Upload Artifacts uses: actions/upload-artifact@v4 - if: runner.os == 'Windows' with: - name: Psst.exe - path: target/release/psst-gui.exe + name: psst-gui-${{ runner.os }} + path: | + psst-gui-*.zip + Psst.dmg.zip deb: runs-on: ubuntu-latest