ci: use universal build for macOS #685
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: Build | |
on: | |
push: | |
branches: | |
- chatterino7 | |
- "bugfix-release/**" | |
- "release/*" | |
pull_request: | |
workflow_dispatch: | |
merge_group: | |
concurrency: | |
group: build-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
C2_ENABLE_LTO: ${{ github.ref == 'refs/heads/chatterino7' || startsWith(github.ref, 'refs/heads/bugfix-release') || startsWith(github.ref, 'refs/heads/release/')}} | |
CHATTERINO_REQUIRE_CLEAN_GIT: On | |
C2_BUILD_WITH_QT6: Off | |
# Last known good conan version | |
# 2.0.3 has a bug on Windows (conan-io/conan#13606) | |
CONAN_VERSION: 2.4.0 | |
jobs: | |
build-ubuntu-docker: | |
name: "Build Ubuntu in Docker" | |
runs-on: ubuntu-latest | |
container: ${{ matrix.container }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
container: ghcr.io/chatterino/chatterino2-build-ubuntu-22.04:latest | |
qt-version: 6.7.2 | |
force-lto: false | |
plugins: true | |
skip-artifact: false | |
skip-crashpad: false | |
build-appimage: true | |
build-deb: true | |
- os: ubuntu-24.04 | |
container: ghcr.io/chatterino/chatterino2-build-ubuntu-24.04:latest | |
qt-version: 6.7.2 | |
force-lto: false | |
plugins: true | |
skip-artifact: false | |
skip-crashpad: false | |
build-appimage: false | |
build-deb: true | |
env: | |
C2_ENABLE_LTO: ${{ matrix.force-lto }} | |
C2_PLUGINS: ${{ matrix.plugins }} | |
C2_ENABLE_CRASHPAD: ${{ matrix.skip-crashpad == false }} | |
C2_BUILD_WITH_QT6: ${{ startsWith(matrix.qt-version, '6.') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 # allows for tags access | |
- name: Fix git permission error | |
run: | | |
git config --global --add safe.directory '*' | |
- name: Build | |
run: | | |
mkdir build | |
cd build | |
CXXFLAGS=-fno-sized-deallocation cmake \ | |
-DCMAKE_INSTALL_PREFIX=appdir/usr/ \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On \ | |
-DUSE_PRECOMPILED_HEADERS=OFF \ | |
-DCMAKE_EXPORT_COMPILE_COMMANDS=On \ | |
-DCHATTERINO_LTO="$C2_ENABLE_LTO" \ | |
-DCHATTERINO_PLUGINS="$C2_PLUGINS" \ | |
-DCMAKE_PREFIX_PATH="$Qt6_DIR/lib/cmake" \ | |
-DBUILD_WITH_QT6="$C2_BUILD_WITH_QT6" \ | |
-DCHATTERINO_STATIC_QT_BUILD=On \ | |
.. | |
make -j"$(nproc)" | |
- name: Package - AppImage (Ubuntu) | |
if: matrix.build-appimage | |
run: | | |
cd build | |
sh ./../.CI/CreateAppImage.sh | |
- name: Upload artifact - AppImage (Ubuntu) | |
if: matrix.build-appimage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Chatterino-x86_64-Qt-${{ matrix.qt-version }}.AppImage | |
path: build/Chatterino-x86_64.AppImage | |
- name: Package - .deb (Ubuntu) | |
if: matrix.build-deb | |
run: | | |
cd build | |
sh ./../.CI/CreateUbuntuDeb.sh | |
- name: Upload artifact - .deb (Ubuntu) | |
if: matrix.build-deb | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Chatterino-${{ matrix.os }}-Qt-${{ matrix.qt-version }}.deb | |
path: build/Chatterino-${{ matrix.os }}-x86_64.deb | |
build: | |
name: "Build ${{ matrix.os }}, Qt ${{ matrix.qt-version }} (LTO:${{ matrix.force-lto }}, crashpad:${{ matrix.skip-crashpad && 'off' || 'on' }})" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# Windows | |
- os: windows-latest | |
qt-version: 6.7.3 | |
force-lto: false | |
plugins: true | |
skip-artifact: false | |
skip-crashpad: false | |
# macOS (ARM) | |
- os: macos-latest | |
qt-version: 6.7.3 | |
force-lto: false | |
plugins: true | |
skip-artifact: false | |
skip-crashpad: false | |
fail-fast: false | |
env: | |
C2_ENABLE_LTO: ${{ matrix.force-lto }} | |
C2_PLUGINS: ${{ matrix.plugins }} | |
C2_ENABLE_CRASHPAD: ${{ matrix.skip-crashpad == false }} | |
C2_BUILD_WITH_QT6: ${{ startsWith(matrix.qt-version, '6.') }} | |
C2_USE_OPENSSL3: ${{ startsWith(matrix.qt-version, '6.') && 'True' || 'False' }} | |
C2_CONAN_CACHE_SUFFIX: ${{ startsWith(matrix.qt-version, '6.') && '-QT6' || '' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 # allows for tags access | |
- name: Install Qt5 | |
if: startsWith(matrix.qt-version, '5.') | |
uses: jurplel/[email protected] | |
with: | |
cache: true | |
cache-key-prefix: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}-v2 | |
version: ${{ matrix.qt-version }} | |
- name: Install Qt6 | |
if: startsWith(matrix.qt-version, '6.') | |
uses: jurplel/[email protected] | |
with: | |
cache: true | |
cache-key-prefix: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}-v2 | |
modules: qt5compat qtimageformats | |
version: ${{ matrix.qt-version }} | |
# WINDOWS | |
- name: Enable Developer Command Prompt (Windows) | |
if: startsWith(matrix.os, 'windows') | |
uses: ilammy/[email protected] | |
- name: Setup sccache (Windows) | |
# sccache v0.7.4 | |
uses: hendrikmuhs/[email protected] | |
if: startsWith(matrix.os, 'windows') | |
with: | |
variant: sccache | |
# only save on on the default (master) branch | |
save: ${{ github.event_name == 'push' }} | |
key: sccache-build-${{ matrix.os }}-${{ matrix.qt-version }}-${{ matrix.skip-crashpad }} | |
restore-keys: | | |
sccache-build-${{ matrix.os }}-${{ matrix.qt-version }} | |
- name: Cache conan packages (Windows) | |
if: startsWith(matrix.os, 'windows') | |
uses: actions/cache@v4 | |
with: | |
key: ${{ runner.os }}-conan-user-${{ hashFiles('**/conanfile.py') }}${{ env.C2_CONAN_CACHE_SUFFIX }} | |
path: ~/.conan2/ | |
- name: Install Conan (Windows) | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
python3 -c "import site; import sys; print(f'{site.USER_BASE}\\Python{sys.version_info.major}{sys.version_info.minor}\\Scripts')" >> "$GITHUB_PATH" | |
pip3 install --user "conan==${{ env.CONAN_VERSION }}" | |
shell: powershell | |
- name: Setup Conan (Windows) | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
conan --version | |
conan profile detect -f | |
shell: powershell | |
- name: Install dependencies (Windows) | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
mkdir build | |
cd build | |
conan install .. ` | |
-s build_type=RelWithDebInfo ` | |
-c tools.cmake.cmaketoolchain:generator="NMake Makefiles" ` | |
-b missing ` | |
--output-folder=. ` | |
-o with_openssl3="$Env:C2_USE_OPENSSL3" | |
shell: powershell | |
- name: Build (Windows) | |
if: startsWith(matrix.os, 'windows') | |
shell: pwsh | |
run: | | |
cd build | |
cmake ` | |
-G"NMake Makefiles" ` | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo ` | |
-DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" ` | |
-DUSE_PRECOMPILED_HEADERS=ON ` | |
-DBUILD_WITH_CRASHPAD="$Env:C2_ENABLE_CRASHPAD" ` | |
-DCHATTERINO_LTO="$Env:C2_ENABLE_LTO" ` | |
-DCHATTERINO_PLUGINS="$Env:C2_PLUGINS" ` | |
-DBUILD_WITH_QT6="$Env:C2_BUILD_WITH_QT6" ` | |
.. | |
set cl=/MP | |
nmake /S /NOLOGO | |
- name: Build crashpad (Windows) | |
if: startsWith(matrix.os, 'windows') && !matrix.skip-crashpad | |
shell: pwsh | |
run: | | |
cd build | |
set cl=/MP | |
nmake /S /NOLOGO chatterino-crash-handler | |
mkdir Chatterino2/crashpad | |
cp bin/crashpad/crashpad-handler.exe Chatterino2/crashpad/crashpad-handler.exe | |
7z a bin/chatterino-Qt-${{ matrix.qt-version }}.pdb.7z bin/chatterino.pdb | |
- name: Prepare build dir (windows) | |
if: startsWith(matrix.os, 'windows') | |
working-directory: build | |
run: | | |
windeployqt bin/chatterino.exe --release --no-compiler-runtime --no-translations --no-opengl-sw --dir Chatterino2/ | |
cp bin/chatterino.exe Chatterino2/ | |
..\.CI\deploy-crt.ps1 Chatterino2 | |
echo nightly > Chatterino2/modes | |
- name: Package (windows) | |
if: startsWith(matrix.os, 'windows') | |
working-directory: build | |
run: | | |
7z a chatterino-windows-x86-64-Qt-${{ matrix.qt-version }}.zip Chatterino2/ | |
- name: Upload artifact (Windows - binary) | |
if: startsWith(matrix.os, 'windows') && !matrix.skip-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: chatterino-windows-x86-64-Qt-${{ matrix.qt-version }}.zip | |
path: build/chatterino-windows-x86-64-Qt-${{ matrix.qt-version }}.zip | |
- name: Upload artifact (Windows - symbols) | |
if: startsWith(matrix.os, 'windows') && !matrix.skip-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: chatterino-windows-x86-64-Qt-${{ matrix.qt-version }}-symbols.pdb.7z | |
path: build/bin/chatterino-Qt-${{ matrix.qt-version }}.pdb.7z | |
- name: Clean Conan cache | |
if: startsWith(matrix.os, 'windows') | |
run: conan cache clean --source --build --download "*" | |
shell: bash | |
# MACOS | |
- name: Install dependencies (MacOS) | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
# binary dependencies | |
./.CI/SetupHomebrewDeps.sh boost openssl | |
# build and header-only dependencies | |
brew install rapidjson p7zip create-dmg cmake tree | |
shell: bash | |
- name: Build (MacOS) | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
mkdir build | |
cd build | |
cmake \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ | |
-DUSE_PRECOMPILED_HEADERS=OFF \ | |
-DCHATTERINO_LTO="$C2_ENABLE_LTO" \ | |
-DCHATTERINO_PLUGINS="$C2_PLUGINS" \ | |
-DBUILD_WITH_QT6="$C2_BUILD_WITH_QT6" \ | |
-DCHATTERINO_NO_AVIF_PLUGIN=On \ | |
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ | |
.. | |
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}}-universal.dmg | |
run: | | |
ls -la | |
pwd | |
ls -la build || true | |
cd build | |
export MACOS_CODESIGN_CERTIFICATE="-" | |
echo "-> $MACOS_CODESIGN_CERTIFICATE" | |
echo "Downloading kimageformats plugins" | |
curl -SsfLo kimg.zip "https://github.com/nerixyz/kimageformats-binaries/releases/download/cont/kimageformats-macos-13-${{ matrix.qt-version}}.zip" | |
./../.CI/MacDeploy.sh | |
# Copy dynamic library dependencies into the Frameworks directory | |
cp /opt/universal-lib/libcrypto.dylib chatterino.app/Contents/Frameworks/libcrypto.3.dylib | |
cp /opt/universal-lib/libssl.dylib chatterino.app/Contents/Frameworks/libssl.3.dylib | |
# Fix the library IDs to match their new location | |
install_name_tool -id @executable_path/../Frameworks/libssl.3.dylib chatterino.app/Contents/Frameworks/libssl.3.dylib | |
install_name_tool -id @executable_path/../Frameworks/libcrypto.3.dylib chatterino.app/Contents/Frameworks/libcrypto.3.dylib | |
# Fix the search path for libcrypto in libssl | |
otool -L chatterino.app/Contents/Frameworks/libssl.3.dylib \ | |
| grep libcrypto.3.dylib \ | |
| cut -d" " -f1 \ | |
| cut -f2 \ | |
| while read input_crypto_dylib; do \ | |
install_name_tool -change \ | |
"$input_crypto_dylib" \ | |
@executable_path/../Frameworks/libcrypto.3.dylib \ | |
chatterino.app/Contents/Frameworks/libssl.3.dylib; \ | |
done | |
./../.CI/CreateDMG.sh | |
shell: bash | |
- name: Upload artifact (MacOS) | |
if: startsWith(matrix.os, 'macos') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: chatterino-macos-Qt-${{ matrix.qt-version }}-universal.dmg | |
path: build/chatterino-macos-Qt-${{ matrix.qt-version }}-universal.dmg | |
- if: startsWith(matrix.os, 'macos') | |
name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
- if: startsWith(matrix.os, 'macos') | |
name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
timeout-minutes: 15 | |
- if: failure() && startsWith(matrix.os, 'macos') | |
name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
timeout-minutes: 15 | |
create-release: | |
needs: [build-ubuntu-docker, build] | |
runs-on: ubuntu-latest | |
if: (github.event_name == 'push' && github.ref == 'refs/heads/chatterino7') | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # allows for tags access | |
# Windows | |
- uses: actions/download-artifact@v4 | |
name: Windows Qt6.7.3 | |
with: | |
name: chatterino-windows-x86-64-Qt-6.7.3.zip | |
path: release-artifacts/ | |
- uses: actions/download-artifact@v4 | |
name: Windows Qt6.7.3 symbols | |
with: | |
name: chatterino-windows-x86-64-Qt-6.7.3-symbols.pdb.7z | |
path: release-artifacts/ | |
# Linux | |
- uses: actions/download-artifact@v4 | |
name: Linux AppImage | |
with: | |
name: Chatterino-x86_64-Qt-6.7.2.AppImage | |
path: release-artifacts/ | |
- uses: actions/download-artifact@v4 | |
name: Ubuntu 22.04 deb | |
with: | |
name: Chatterino-ubuntu-22.04-Qt-6.7.2.deb | |
path: release-artifacts/ | |
- uses: actions/download-artifact@v4 | |
name: Ubuntu 24.04 deb | |
with: | |
name: Chatterino-ubuntu-24.04-Qt-6.7.2.deb | |
path: release-artifacts/ | |
# macOS | |
- uses: actions/download-artifact@v4 | |
name: macOS Qt6.7.3 dmg | |
with: | |
name: chatterino-macos-Qt-6.7.3-universal.dmg | |
path: release-artifacts/ | |
- name: Rename artifacts | |
run: | | |
ls -l | |
# Rename the macos build to indicate that it's for macOS 12.0 users | |
mv chatterino-macos-Qt-6.7.3-x86_64.dmg Chatterino-macOS-12.0-universal.dmg | |
working-directory: release-artifacts | |
shell: bash | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Format changes | |
id: format-changes | |
run: | | |
delimiter=$(openssl rand -hex 32) | |
{ | |
echo "changelog<<$delimiter" | |
python3 ./.CI/format-recent-changes.py | |
echo $delimiter | |
} >> "$GITHUB_OUTPUT" | |
shell: bash | |
- name: Create release | |
uses: ncipollo/[email protected] | |
with: | |
replacesArtifacts: true | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
artifacts: "release-artifacts/*" | |
body: ${{ steps.format-changes.outputs.changelog }} | |
prerelease: true | |
name: Nightly Release | |
tag: nightly-build | |
- name: Update nightly-build tag | |
run: | | |
git tag -f nightly-build | |
git push -f origin nightly-build | |
shell: bash |