ci: Reorder and improve dependency installation in build workflow #71
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
on: | |
push: | |
pull_request: | |
name: CI | |
# Note: Windows ARM64 builds are currently disabled as GTK4 and its dependencies | |
# are not yet available for this platform in vcpkg | |
jobs: | |
macos: | |
name: "macOS" | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-apple-darwin | |
arch: x86_64 | |
- target: x86_64-apple-darwin | |
arch: x86_64 | |
- target: x86_64-apple-darwin | |
arch: x86_64 | |
- target: x86_64-apple-darwin | |
arch: x86_64 | |
- target: x86_64-apple-darwin | |
arch: x86_64 | |
- target: x86_64-apple-darwin | |
arch: x86_64 | |
- target: x86_64-apple-darwin | |
arch: x86_64 | |
# Temporarily disabled the arm build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: moonrepo/setup-rust@v1 | |
# Cache Homebrew packages | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/Library/Caches/Homebrew | |
/usr/local/Homebrew | |
/opt/homebrew | |
key: ${{ runner.os }}-${{ matrix.arch }}-brew-${{ hashFiles('.github/workflows/build.yml') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.arch }}-brew- | |
- name: Setup x86_64 Homebrew | |
if: matrix.arch == 'x86_64' | |
run: | | |
HOMEBREW_PREFIX="/usr/local" | |
sudo mkdir -p /usr/local | |
sudo chown -R $(whoami) /usr/local | |
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
eval "$(/usr/local/bin/brew shellenv)" | |
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/opt/pango/lib/pkgconfig:/usr/local/opt/cairo/lib/pkgconfig:/usr/local/opt/gdk-pixbuf/lib/pkgconfig:/usr/local/opt/graphene/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/gtk4/lib/pkgconfig:/usr/local/opt/libadwaita/lib/pkgconfig" >> $GITHUB_ENV | |
- name: Install pkg-config (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install pkg-config || echo Error - exited non 0 | |
- name: Install GDK-Pixbuf (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install gdk-pixbuf || echo Error - exited non 0 | |
- name: Install Cairo (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install cairo || echo Error - exited non 0 | |
- name: Install Pango (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install pango || echo Error - exited non 0 | |
- name: Install Graphene (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install graphene || echo Error - exited non 0 | |
- name: Install GTK4 (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install gtk4 || echo Error - exited non 0 | |
- name: Install AT-SPI2-Core (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install at-spi2-core || echo Error - exited non 0 | |
- name: Install Libadwaita (x86_64) | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 /usr/local/bin/brew install -v libadwaita || echo Error - exited non 0 | |
- name: Finalize x86_64 setup | |
if: matrix.arch == 'x86_64' | |
run: arch -x86_64 brew link --force pango cairo gdk-pixbuf gtk4 libadwaita | |
- name: Install ARM64 dependencies | |
if: matrix.arch == 'arm64' | |
run: | | |
brew install pkg-config gtk4 pango cairo gdk-pixbuf at-spi2-core graphene libadwaita | |
brew upgrade pkg-config gtk4 pango cairo gdk-pixbuf at-spi2-core graphene libadwaita | |
- name: Finalize ARM64 setup | |
if: matrix.arch == 'arm64' | |
run: | | |
echo "PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig" >> $GITHUB_ENV | |
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV | |
- name: Add target ${{ matrix.target }} | |
run: rustup target add ${{ matrix.target }} | |
- name: Build | |
env: | |
PKG_CONFIG_ALLOW_CROSS: "1" | |
CFLAGS: "-I/usr/local/include -I/usr/local/include/gtk-4.0 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" | |
LDFLAGS: "-L/usr/local/lib -framework Cocoa -framework Security" | |
MACOSX_DEPLOYMENT_TARGET: "10.15" | |
PKG_CONFIG_SYSROOT_DIR: "" | |
PKG_CONFIG_PATH: "${{ env.PKG_CONFIG_PATH }}" | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Create App Bundle | |
run: | | |
mkdir -p Aardvark.app/Contents/MacOS | |
cp target/${{ matrix.target }}/release/aardvark Aardvark.app/Contents/MacOS/ | |
# Create Info.plist - you'll need to customize this | |
cat > Aardvark.app/Contents/Info.plist << EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>CFBundleExecutable</key> | |
<string>aardvark</string> | |
<key>CFBundleIdentifier</key> | |
<string>org.p2panda.aardvark</string> | |
<key>CFBundleName</key> | |
<string>Aardvark</string> | |
<key>CFBundlePackageType</key> | |
<string>APPL</string> | |
<key>CFBundleShortVersionString</key> | |
<string>1.0</string> | |
</dict> | |
</plist> | |
EOF | |
- name: Create DMG | |
run: | | |
hdiutil create -volname "Aardvark" -srcfolder Aardvark.app -ov -format UDZO aardvark-${{ matrix.arch }}.dmg | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: aardvark-macos-${{ matrix.arch }} | |
path: aardvark-${{ matrix.arch }}.dmg |