Build and Release #31
This file contains 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 and Release | |
on: | |
workflow_dispatch: | |
env: | |
VERSION: 2.0.0 | |
jobs: | |
# Release build job | |
release: | |
permissions: write-all | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [macos-latest, macos-13, ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies (ubuntu only) | |
if: matrix.platform == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential curl libssl-dev | |
- name: Rust setup | |
uses: dtolnay/rust-toolchain@stable | |
- name: Rust cache | |
uses: swatinem/rust-cache@v2 | |
- name: Install app dependencies | |
run: cargo install cargo-packager --locked | |
- name: Package Binary | |
run: cargo packager --release --verbose | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.platform }}-release-artifacts | |
path: | | |
${{ matrix.platform == 'macos-latest' && 'target/release/Raspirus.app' || '' }} | |
${{ matrix.platform == 'macos-latest' && 'target/release/Raspirus_*_aarch64.dmg' || '' }} | |
${{ matrix.platform == 'macos-13' && 'target/release/Raspirus.app' || '' }} | |
${{ matrix.platform == 'macos-13' && 'target/release/Raspirus_*_x64.dmg' || '' }} | |
${{ matrix.platform == 'ubuntu-latest' && 'target/release/PKGBUILD' || '' }} | |
${{ matrix.platform == 'ubuntu-latest' && 'target/release/raspirus_*_amd64.deb' || '' }} | |
${{ matrix.platform == 'ubuntu-latest' && 'target/release/raspirus_*_x86_64.AppImage' || '' }} | |
${{ matrix.platform == 'windows-latest' && 'target/release/raspirus_*_x64_en-US.msi' || '' }} | |
${{ matrix.platform == 'windows-latest' && 'target/release/raspirus_*_x64-setup.exe' || '' }} | |
# Cross-compilation job | |
cross_compile: | |
permissions: write-all | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- arch: aarch64 | |
target: aarch64-unknown-linux-gnu | |
apt: gcc-aarch64-linux-gnu | |
sysroot: /usr/aarch64-linux-gnu/ | |
pkg_arch: arm64 | |
- arch: riscv64 | |
target: riscv64gc-unknown-linux-gnu | |
apt: gcc-riscv64-linux-gnu | |
sysroot: /usr/riscv64-linux-gnu/ | |
pkg_arch: riscv64 | |
# UNSUPPORTED with iced :( | |
# - arch: armv7 | |
# target: armv7-unknown-linux-gnueabihf | |
# apt: gcc-arm-linux-gnueabihf | |
# sysroot: /usr/arm-linux-gnueabihf/ | |
# pkg_arch: armhf | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Clean install Debian packages | |
run: sudo apt-get clean && sudo apt-get update && sudo apt-get upgrade -y | |
- name: Install cross-compile dependencies | |
uses: ryankurte/[email protected] | |
with: | |
arch: ${{ matrix.pkg_arch }} | |
packages: "libssl-dev:${{ matrix.pkg_arch }}" | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
pkg-config \ | |
build-essential \ | |
curl \ | |
libssl-dev \ | |
${{ matrix.apt }} | |
- name: Rust setup | |
uses: dtolnay/rust-toolchain@stable | |
- name: Rust cache | |
uses: swatinem/rust-cache@v2 | |
- name: Install Rust target | |
run: rustup target add ${{ matrix.target }} | |
- name: Set environment variables | |
run: echo "PKG_CONFIG_SYSROOT_DIR=${{ matrix.sysroot }}" >> $GITHUB_ENV | |
- name: Install app dependencies | |
run: cargo install cargo-packager --locked | |
- name: Package Binary | |
env: | |
PKG_CONFIG_SYSROOT_DIR: ${{ matrix.sysroot }} | |
run: | | |
cargo packager --release --verbose --config "{\"beforePackagingCommand\": \"cargo build --release --target ${{ matrix.target }}\", \"targetTriple\": \"${{ matrix.target }}\"}" | |
- name: List release | |
run: ls * target/${{ matrix.target }} | |
- name: Upload cross-compile artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.pkg_arch }}-cross-compile-artifacts | |
path: target/${{ matrix.target }}/debian/*.deb | |
# Upload to GitHub release job | |
upload_to_release: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
needs: [release, cross_compile] | |
steps: | |
- name: Download release artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
merge-multiple: true | |
- name: Create attestation for all builds | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-path: | | |
artifacts/PKGBUILD | |
artifacts/Raspirus_*_aarch64.dmg | |
artifacts/Raspirus_*_x64.dmg | |
artifacts/raspirus_*_amd64.deb | |
artifacts/raspirus_*_x86_64.AppImage | |
artifacts/raspirus_*_x64_en-US.msi | |
artifacts/raspirus_*_x64-setup.exe | |
artifacts/raspirus_*_arm64.deb | |
artifacts/raspirus_*_riscv64.deb | |
# target/armv7-unknown-linux-gnueabihf/debian/*.deb | |
- name: Release to GitHub | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
generate_release_notes: true | |
tag_name: Raspirus v${{ env.VERSION }} | |
files: | | |
artifacts/PKGBUILD | |
artifacts/Raspirus_*_aarch64.dmg | |
artifacts/Raspirus_*_x64.dmg | |
artifacts/raspirus_*_amd64.deb | |
artifacts/raspirus_*_x86_64.AppImage | |
artifacts/raspirus_*_x64_en-US.msi | |
artifacts/raspirus_*_x64-setup.exe | |
artifacts/raspirus_*_arm64.deb | |
artifacts/raspirus_*_riscv64.deb | |
# target/armv7-unknown-linux-gnueabihf/debian/*.deb |