bump base #1265
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: macos | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
macos: | |
# macos-11, macos-12 & macos-13 are broken at this time being. | |
# https://github.com/koreader/koreader/issues/8686, | |
# https://github.com/koreader/koreader/issues/8686#issuecomment-1172950236 | |
# Please don't update to newer macOS version unless you can test that the new | |
# action produces working binaries. | |
# 10.15 is no longer supported so we are running 13 just to make sure the build does not break. | |
runs-on: macos-13 | |
env: | |
MACOSX_DEPLOYMENT_TARGET: '10.15' | |
MAKEFLAGS: 'OUTPUT_DIR=build INSTALL_DIR=install TARGET=macos' | |
steps: | |
- name: XCode version | |
run: xcode-select -p | |
# Checkout / fetch. {{{ | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
clean: false | |
fetch-depth: 0 | |
filter: tree:0 | |
show-progress: false | |
- name: Fetch | |
run: make fetchthirdparty | |
# }}} | |
# Install dependencies. {{{ | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
# Note: Python 3.12 removal of `distutils` breaks GLib's build. | |
python-version: '3.11' | |
- name: Install ccache | |
run: | | |
wget --progress=dot:mega https://github.com/ccache/ccache/releases/download/v4.9.1/ccache-4.9.1-darwin.tar.gz | |
tar xf ccache-4.9.1-darwin.tar.gz | |
printf '%s\n' "$PWD/ccache-4.9.1-darwin" >>"${GITHUB_PATH}" | |
- name: Install meson & ninja | |
run: python -m pip --disable-pip-version-check install 'meson==1.4.0' 'ninja==1.11.1.1' | |
- name: Install homebrew dependencies | |
# Compared to the README, adds p7zip. | |
run: | | |
packages=( | |
nasm binutils coreutils libtool autoconf automake cmake make | |
makedepend sdl2 [email protected] luarocks gettext pkg-config wget | |
gnu-getopt grep bison p7zip | |
) | |
# Lua 5.1 is disabled, so we need to work around that: | |
# - fetch all packages | |
brew fetch "${packages[@]}" | |
# - disable auto-updates | |
export HOMEBREW_NO_AUTO_UPDATE=1 | |
# - install [email protected] from cache | |
brew install "$(brew --cache [email protected])" | |
# - and install the rest | |
brew install "${packages[@]}" | |
- name: Update PATH | |
run: > | |
printf '%s\n' | |
"$(brew --prefix)/opt/bison/bin" | |
"$(brew --prefix)/opt/gettext/bin" | |
"$(brew --prefix)/opt/gnu-getopt/bin" | |
"$(brew --prefix)/opt/grep/libexec/gnubin" | |
"$(brew --prefix)/opt/make/libexec/gnubin" | |
| tee "${GITHUB_PATH}" | |
# }}} | |
# Restore / setup caches. {{{ | |
- name: Generate cache keys | |
run: | | |
make -C base TARGET= cache-key | |
# Bump number to reset all caches. | |
epoch=1 | |
prefix="$epoch-$RUNNER_OS" | |
base_hash="$(shasum -a 256 base/cache-key | cut -f1 -d\ )" | |
keys=( | |
"CACHE_KEY_BUILD=$prefix-build-$base_hash" | |
"CACHE_KEY_BASE_CCACHE=$prefix-ccache" | |
"CACHE_KEY_FULL_CCACHE=$prefix-ccache-$base_hash" | |
) | |
printf '%s\n' "${keys[@]}" | tee "${GITHUB_ENV}" | |
- name: Restore build directory | |
id: build-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: base/build | |
key: ${{ env.CACHE_KEY_BUILD }} | |
- name: Restore build cache | |
id: ccache-restore | |
# Only if we're going to build. | |
if: steps.build-restore.outputs.cache-hit != 'true' | |
uses: actions/cache/restore@v4 | |
with: | |
path: /Users/runner/Library/Caches/ccache | |
key: ${{ env.CACHE_KEY_FULL_CCACHE }} | |
restore-keys: | | |
${{ env.CACHE_KEY_FULL_CCACHE }}- | |
${{ env.CACHE_KEY_BASE_CCACHE }}- | |
- name: Setup build cache | |
# Only if we're going to build. | |
if: steps.build-restore.outputs.cache-hit != 'true' | |
run: | | |
set -x | |
which ccache | |
ccache --version | |
ccache --zero-stats | |
ccache --max-size=256M | |
ccache --show-config | |
# }}} | |
# Build. {{{ | |
- name: Build | |
if: steps.build-restore.outputs.cache-hit != 'true' | |
run: make base | |
# }}} | |
# Clean / save caches. {{{ | |
- name: Clean build cache | |
# On failure too, but only if we built. | |
if: > | |
always() | |
&& steps.build-restore.outputs.cache-hit != 'true' | |
run: | | |
set -x | |
ccache --cleanup >/dev/null | |
ccache --show-stats --verbose | |
- name: Save build cache | |
uses: actions/cache/save@v4 | |
# On failure too, but only if we built and the | |
# cache was not restored from a primary key hit. | |
if: > | |
always() | |
&& steps.build-restore.outputs.cache-hit != 'true' | |
&& steps.ccache-restore.outputs.cache-hit != 'true' | |
with: | |
path: /Users/runner/Library/Caches/ccache | |
key: ${{ env.CACHE_KEY_FULL_CCACHE }}${{ steps.build.outcome != 'success' && format('-{0}.{1}', github.run_number, github.run_attempt) || '' }} | |
- name: Save build directory | |
uses: actions/cache/save@v4 | |
# Only if we built. | |
if: steps.build-restore.outputs.cache-hit != 'true' | |
with: | |
path: base/build | |
key: ${{ env.CACHE_KEY_BUILD }} | |
# }}} | |
# Generate / upload artifact. {{{ | |
- name: Generate artifact | |
run: make update --assume-old=base | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: koreader-macos | |
path: '*.7z' | |
# }}} | |
# vim: foldmethod=marker foldlevel=0 |