Fix macOS build #799
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
code-style: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Install Linux Dependencies | |
if: runner.os == 'Linux' | |
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libssl-dev libasound2-dev | |
- name: Check Formatting | |
run: cargo clippy -- -D warnings | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
- os: windows-latest | |
runs-on: ${{ matrix.os }} | |
env: | |
MACOSX_DEPLOYMENT_TARGET: 11.0 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ hashFiles('Cross.toml') }} | |
- name: Install Cross | |
if: runner.os == 'Linux' | |
run: cargo install cross | |
- name: Build (Linux) | |
if: runner.os == 'Linux' | |
run: cross build --release --target ${{ matrix.target }} | |
- name: Build Release (Windows) | |
if: runner.os == 'Windows' | |
run: cargo build --release | |
- name: Make Linux Binary Executable | |
if: runner.os == 'Linux' | |
run: chmod +x target/${{ matrix.target }}/release/psst-gui | |
- name: Upload Linux Binary | |
uses: actions/upload-artifact@v4 | |
if: runner.os == 'Linux' | |
with: | |
name: psst-gui-${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/psst-gui | |
- name: Upload Windows Executable | |
uses: actions/upload-artifact@v4 | |
if: runner.os == 'Windows' | |
with: | |
name: Psst.exe | |
path: target/release/psst-gui.exe | |
build-macos: | |
runs-on: macos-latest | |
env: | |
MACOSX_DEPLOYMENT_TARGET: 11.0 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Add ARM64 target | |
run: rustup target add aarch64-apple-darwin | |
- name: Build for x86_64 | |
run: cargo build --release --target x86_64-apple-darwin | |
- name: Build for ARM64 | |
run: cargo build --release --target aarch64-apple-darwin | |
- name: Create Universal Binary | |
run: | | |
mkdir -p target/universal-apple-darwin/release | |
lipo -create -output target/universal-apple-darwin/release/psst-gui \ | |
target/x86_64-apple-darwin/release/psst-gui \ | |
target/aarch64-apple-darwin/release/psst-gui | |
- name: Install create-dmg | |
run: brew install create-dmg | |
- name: Create App Bundle | |
run: | | |
mkdir -p Psst.app/Contents/MacOS | |
cp target/universal-apple-darwin/release/psst-gui Psst.app/Contents/MacOS/ | |
# Copy other necessary resources, icons, and Info.plist | |
# Adjust paths as needed for your project structure | |
cp -r psst-gui/assets Psst.app/Contents/Resources | |
cp psst-gui/Info.plist Psst.app/Contents/ | |
- name: Create DMG | |
run: | | |
create-dmg \ | |
--volname "Psst" \ | |
--volicon "psst-gui/assets/logo.icns" \ | |
--window-pos 200 120 \ | |
--window-size 600 400 \ | |
--icon-size 100 \ | |
--icon "Psst.app" 150 160 \ | |
--hide-extension "Psst.app" \ | |
--app-drop-link 450 160 \ | |
--no-internet-enable \ | |
"Psst.dmg" \ | |
"Psst.app" | |
- name: Upload macOS DMG | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Psst.dmg | |
path: Psst.dmg | |
deb: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
include: | |
- arch: amd64 | |
target: x86_64-unknown-linux-gnu | |
- arch: arm64 | |
target: aarch64-unknown-linux-gnu | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Download Linux Binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: psst-gui-${{ matrix.target }} | |
path: ${{runner.workspace}}/binaries | |
- name: Move Binary | |
run: | | |
mkdir -p ${{runner.workspace}}/pkg/usr/bin/ | |
mv ${{runner.workspace}}/binaries/psst-gui ${{runner.workspace}}/pkg/usr/bin/ | |
- name: Move Desktop Entry | |
run: mkdir -p ${{runner.workspace}}/pkg/usr/share/applications/; mv .pkg/psst.desktop $_ | |
- name: Add Icons | |
run: | | |
LOGOS=$(cd ./psst-gui/assets/ && ls logo_*.png) | |
for LOGO in $LOGOS | |
do | |
LOGO_SIZE=$(echo "${LOGO}" | grep -oE '[[:digit:]]{2,}') | |
mkdir -p "${{runner.workspace}}/pkg/usr/share/icons/hicolor/${LOGO_SIZE}x${LOGO_SIZE}/" | |
cp "./psst-gui/assets/${LOGO}" "$_/psst.png" | |
done | |
mkdir -p "${{runner.workspace}}/pkg/usr/share/icons/hicolor/scalable/apps/" | |
cp "./psst-gui/assets/logo.svg" "$_/psst.svg" | |
- name: Set Permissions | |
run: chmod 755 ${{runner.workspace}}/pkg/usr/bin/psst-gui | |
- name: Move License | |
run: mkdir -p ${{runner.workspace}}/pkg/usr/share/doc/psst-gui/; mv .pkg/copyright $_ | |
- name: Move Package Config | |
run: | | |
mkdir -p ${{runner.workspace}}/pkg/ | |
cp -r .pkg/DEBIAN $_/ | |
sed -i 's/Architecture: amd64/Architecture: ${{ matrix.arch }}/' ${{runner.workspace}}/pkg/DEBIAN/control | |
- name: Set Version | |
run: "echo Version: $(git rev-list --count HEAD) >> ${{runner.workspace}}/pkg/DEBIAN/control" | |
- name: Build Package | |
run: | | |
cat ${{runner.workspace}}/pkg/DEBIAN/control | |
dpkg-deb -b ${{runner.workspace}}/pkg/ psst_$(git rev-list --count HEAD)_${{ matrix.arch }}.deb | |
- name: Upload Debian Package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: psst-deb-${{ matrix.arch }} | |
path: "*.deb" | |
appimage: | |
if: false # Disable temporarily: https://github.com/jpochyla/psst/actions/runs/3897410142/jobs/6655282029 | |
runs-on: ubuntu-latest | |
needs: deb | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Download Debian Package | |
uses: actions/download-artifact@v4 | |
with: | |
name: psst-deb | |
path: ${{runner.workspace}} | |
- name: Install Dependencies | |
run: sudo apt-get update && sudo apt-get install -y libfuse2 | |
- name: Create Workspace | |
run: mkdir -p ${{runner.workspace}}/appimage | |
- name: Download the Latest pkg2appimage | |
run: | | |
latest_release_appimage_url=$(wget -q https://api.github.com/repos/AppImageCommunity/pkg2appimage/releases/latest -O - | jq -r '.assets[0].browser_download_url') | |
wget --directory-prefix=${{runner.workspace}}/appimage -c $latest_release_appimage_url | |
- name: Create Path to pkg2appimage | |
run: | | |
pkg2appimage_executable=$(ls ${{runner.workspace}}/appimage) | |
app_path=${{runner.workspace}}/appimage/${pkg2appimage_executable} | |
chmod +x ${app_path} | |
echo "app_path=${app_path}" >> $GITHUB_ENV | |
- name: Create Path to pkg2appimage's Recipe File | |
run: | | |
recipe_path=${{runner.workspace}}/psst/.pkg/APPIMAGE/pkg2appimage-ingredients.yml | |
echo "recipe_path=${recipe_path}" >> $GITHUB_ENV | |
- name: Run pkg2appimage | |
run: | | |
${{env.app_path}} ${{env.recipe_path}} | |
- name: Upload AppImage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: psst-appimage | |
path: ${{runner.workspace}}/out/*.AppImage |