Skip to content

Commit

Permalink
ci: build for both x86 and arm on macOS (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Jan 13, 2024
1 parent 9114877 commit a752ff9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 19 deletions.
16 changes: 12 additions & 4 deletions .CI/MacDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,23 @@ if [ -n "$MACOS_CODESIGN_CERTIFICATE" ]; then
_macdeployqt_args+=("-codesign=$MACOS_CODESIGN_CERTIFICATE")
fi

macdeployqt chatterino.app "${_macdeployqt_args[@]}"
echo "Extracting kimageformats plugins"
7z e -okimg kimg.zip

# Download kimageformats plugins
if [ -n "$MACOS_CODESIGN_CERTIFICATE" ]; then
echo "Codesigning libKF5Archive"
codesign -s "$MACOS_CODESIGN_CERTIFICATE" --force kimg/libKF5Archive.5.dylib
echo "Codesigning kimg_avif"
codesign -s "$MACOS_CODESIGN_CERTIFICATE" --force kimg/kimg_avif.so
fi

curl -SsfLo kimg.zip "https://github.com/jurplel/kimageformats-binaries/releases/download/cont/kimageformats-macos-latest-$_img_version.zip"
7z e -okimg kimg.zip
mkdir -p chatterino.app/Contents/Frameworks
mkdir -p chatterino.app/Contents/PlugIns/imageformats
cp kimg/libKF5Archive.5.dylib chatterino.app/Contents/Frameworks/
cp kimg/kimg_avif.so chatterino.app/Contents/PlugIns/imageformats/

macdeployqt chatterino.app "${_macdeployqt_args[@]}" -verbose=1

if [ -n "$MACOS_CODESIGN_CERTIFICATE" ]; then
# Validate that chatterino.app was codesigned correctly
codesign -v chatterino.app
Expand Down
60 changes: 48 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ env:

jobs:
build:
name: "Build ${{ matrix.os }}, Qt ${{ matrix.qt-version }} (LTO:${{ matrix.force-lto }}, crashpad:${{ matrix.skip-crashpad && 'off' || 'on' }})"
name: "Build ${{ matrix.os }}${{ matrix.arch && format(' ({0})', matrix.arch) || ''}}, Qt ${{ matrix.qt-version }} (LTO:${{ matrix.force-lto }}, crashpad:${{ matrix.skip-crashpad && 'off' || 'on' }})"
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -53,9 +53,18 @@ jobs:
plugins: true
skip-artifact: false
skip-crashpad: false
# macOS
- os: macos-latest
qt-version: 5.15.2
# macOS (ARM)
- os: macos-12
qt-version: 6.5.0
arch: arm64
force-lto: false
plugins: false
skip-artifact: false
skip-crashpad: false
# macOS (x86)
- os: macos-12
qt-version: 6.5.0
arch: x86_64
force-lto: false
plugins: false
skip-artifact: false
Expand Down Expand Up @@ -392,7 +401,18 @@ jobs:
- name: Install dependencies (MacOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install boost openssl rapidjson p7zip create-dmg cmake tree libavif
LIBS=(boost openssl rapidjson)
for package in "${LIBS[@]}"
do
brew fetch --force --bottle-tag=${{ matrix.arch }}_monterey $package
formula=$(brew --cache --bottle-tag=${{ matrix.arch }}_monterey $package)
if [[ $package == "openssl" ]]; then
brew reinstall $formula
else
brew install $formula
fi
done
brew install p7zip create-dmg cmake tree
shell: bash

- name: Build (MacOS)
Expand All @@ -409,19 +429,28 @@ jobs:
-DCHATTERINO_PLUGINS="$C2_PLUGINS" \
-DBUILD_WITH_QT6="$C2_BUILD_WITH_QT6" \
-DCHATTERINO_NO_AVIF_PLUGIN=On \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
..
make -j"$(sysctl -n hw.logicalcpu)"
shell: bash

- name: Package (MacOS)
if: startsWith(matrix.os, 'macos')
env:
OUTPUT_DMG_PATH: chatterino-macos-Qt-${{ matrix.qt-version}}.dmg
OUTPUT_DMG_PATH: chatterino-macos-Qt-${{ matrix.qt-version}}-${{ matrix.arch }}.dmg
run: |
ls -la
pwd
ls -la build || true
cd build
export MACOS_CODESIGN_CERTIFICATE="-"
echo "-> $MACOS_CODESIGN_CERTIFICATE"
brew reinstall openssl
echo "Downloading kimageformats plugins"
curl -SsfLo kimg.zip "https://github.com/nerixyz/kimageformats-binaries/releases/download/cont/kimageformats-macos-latest-${{ matrix.qt-version}}.zip"
${{matrix.arch == 'arm64' && 'brew reinstall $(brew --cache --bottle-tag=arm64_monterey openssl)' || ''}}
./../.CI/MacDeploy.sh
./../.CI/CreateDMG.sh
shell: bash
Expand All @@ -430,8 +459,8 @@ jobs:
if: startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v4
with:
name: chatterino-macos-Qt-${{ matrix.qt-version }}.dmg
path: build/chatterino-macos-Qt-${{ matrix.qt-version }}.dmg
name: chatterino-macos-Qt-${{ matrix.qt-version }}-${{ matrix.arch }}.dmg
path: build/chatterino-macos-Qt-${{ matrix.qt-version }}-${{ matrix.arch }}.dmg
create-release:
needs: build
runs-on: ubuntu-latest
Expand Down Expand Up @@ -479,16 +508,23 @@ jobs:
path: release-artifacts/

- uses: actions/download-artifact@v4
name: macOS x86_64 Qt5.15.2 dmg
name: macOS x86_64 Qt6.5.0 x86 dmg
with:
name: chatterino-macos-Qt-6.5.0-x86_64.dmg
path: release-artifacts/

- uses: actions/download-artifact@v4
name: macOS x86_64 Qt6.5.0 ARM dmg
with:
name: chatterino-macos-Qt-5.15.2.dmg
name: chatterino-macos-Qt-6.5.0-arm64.dmg
path: release-artifacts/

- name: Rename artifacts
run: |
ls -l
# Rename the macos build to indicate that it's for macOS 10.15 users
mv chatterino-macos-Qt-5.15.2.dmg Chatterino-macOS-12.0.dmg
# Rename the macos build to indicate that it's for macOS 12.0 users
mv chatterino-macos-Qt-6.5.0-x86_64.dmg Chatterino-macOS-12.0-x86_64.dmg
mv chatterino-macos-Qt-6.5.0-arm64.dmg Chatterino-macOS-12.0-arm64.dmg
working-directory: release-artifacts
shell: bash

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/create-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,15 @@ jobs:
run: |
ls -l
mv Chatterino-ubuntu-22.04-Qt-5.15.2.deb Chatterino-Ubuntu-22.04.deb
mv Chatterino-ubuntu-22.04-Qt-6.2.4.deb EXPERIMENTAL-Chatterino-Ubuntu-22.04-Qt6.deb
mv Chatterino-ubuntu-22.04-Qt-6.2.4.deb Chatterino-Ubuntu-22.04-Qt6.deb
mv Chatterino-x86_64-5.15.2.AppImage Chatterino-x86_64.AppImage
mv Chatterino-x86_64-6.2.4.AppImage EXPERIMENTAL-Chatterino-x86_64-Qt6.AppImage
mv Chatterino-x86_64-6.2.4.AppImage Chatterino-x86_64-Qt6.AppImage
mv chatterino-windows-x86-64-Qt-6.5.0-symbols.pdb.7z Chatterino-Windows-debug-symbols.pdb.7z
mv chatterino-macos-Qt-5.15.2.dmg Chatterino.dmg
mv chatterino-macos-Qt-6.5.0-x86_64.dmg Chatterino-x86_64.dmg
mv chatterino-macos-Qt-6.5.0-arm64.dmg Chatterino-arm64.dmg
- name: Hash files
working-directory: build
Expand Down

0 comments on commit a752ff9

Please sign in to comment.