Files
zodia/.github/workflows/release.yml
T

170 lines
5.8 KiB
YAML

name: Release
on:
push:
tags:
- 'v[0-9]*'
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
artifact: zodia
- os: macos-14
target: aarch64-apple-darwin
artifact: zodia
steps:
- uses: actions/checkout@v4
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
libgtk-4-dev \
libadwaita-1-dev \
libopus-dev \
libasound2-dev \
pkg-config
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install gtk4 libadwaita pango opus pkg-config glib
- name: Export brew paths for build tools (macOS)
if: runner.os == 'macOS'
run: |
BREW="$(brew --prefix)"
echo "PKG_CONFIG_PATH=${BREW}/lib/pkgconfig:${BREW}/share/pkgconfig" >> "$GITHUB_ENV"
echo "LIBRARY_PATH=${BREW}/lib" >> "$GITHUB_ENV"
echo "CPATH=${BREW}/include" >> "$GITHUB_ENV"
# Tell the linker where to find dylibs at link time
echo "RUSTFLAGS=-L ${BREW}/lib" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build release binary
run: cargo build --release --bin zodia --target ${{ matrix.target }}
- name: Prepare Linux artifact
if: runner.os == 'Linux'
run: |
BIN=target/${{ matrix.target }}/release/${{ matrix.artifact }}
strip "$BIN"
cp "$BIN" zodia-${{ matrix.target }}
- name: Create macOS .app bundle
if: runner.os == 'macOS'
run: |
APP=Zodia.app
mkdir -p "$APP/Contents/MacOS"
mkdir -p "$APP/Contents/Resources"
cp target/${{ matrix.target }}/release/${{ matrix.artifact }} \
"$APP/Contents/MacOS/zodia-bin"
cat > "$APP/Contents/Info.plist" <<'PLIST'
<?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>CFBundleName</key>
<string>Zodia</string>
<key>CFBundleDisplayName</key>
<string>Zodia</string>
<key>CFBundleIdentifier</key>
<string>app.zodia.Zodia</string>
<key>CFBundleVersion</key>
<string>${{ github.ref_name }}</string>
<key>CFBundleShortVersionString</key>
<string>${{ github.ref_name }}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>zodia</string>
<key>LSMinimumSystemVersion</key>
<string>13.0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>AGPL-3.0-or-later</string>
</dict>
</plist>
PLIST
# Bundle shared libraries so the .app is self-contained
brew install dylibbundler
BREW="$(brew --prefix)"
dylibbundler \
--bundle-deps \
--fix-file "$APP/Contents/MacOS/zodia-bin" \
--dest-dir "$APP/Contents/libs" \
--install-path "@executable_path/../libs" \
--search-path "${BREW}/lib" \
--overwrite-dir
# Copy Adwaita icon theme so symbolic icons render
ICONS_SRC="$(brew --prefix)/share/icons"
if [ -d "$ICONS_SRC/hicolor" ]; then
mkdir -p "$APP/Contents/Resources/share/icons"
cp -r "$ICONS_SRC/hicolor" "$APP/Contents/Resources/share/icons/"
fi
if [ -d "$ICONS_SRC/Adwaita" ]; then
mkdir -p "$APP/Contents/Resources/share/icons"
cp -r "$ICONS_SRC/Adwaita" "$APP/Contents/Resources/share/icons/"
fi
# Launcher wrapper — sets XDG_DATA_DIRS so GTK finds our bundled icons
# Also exports GDK_PIXBUF_MODULE_FILE so pixbuf loaders are found.
BREW="$(brew --prefix)"
cat > "$APP/Contents/MacOS/zodia" <<SH
#!/bin/sh
BUNDLE="\$(cd "\$(dirname "\$0")/../.." && pwd)"
export XDG_DATA_DIRS="\$BUNDLE/Contents/Resources/share:${BREW}/share"
export GDK_PIXBUF_MODULE_FILE="${BREW}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
exec "\$BUNDLE/Contents/MacOS/zodia-bin" "\$@"
SH
chmod +x "$APP/Contents/MacOS/zodia"
zip -r "zodia-${{ matrix.target }}.zip" "$APP"
- name: Upload Linux artifact to GitHub Release
if: runner.os == 'Linux'
uses: softprops/action-gh-release@v2
with:
files: zodia-${{ matrix.target }}
generate_release_notes: true
- name: Upload macOS artifact to GitHub Release
if: runner.os == 'macOS'
uses: softprops/action-gh-release@v2
with:
files: zodia-${{ matrix.target }}.zip
generate_release_notes: false