fix: vcpkg cache in CI #109
This file contains hidden or 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 CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: macos-ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: macOS build test | |
| runs-on: macos-latest | |
| env: | |
| CLIPP_CACHE_DIR: ${{ github.workspace }}/clipp-cache | |
| VCPKG_ROOT: ${{ github.workspace }}/v | |
| VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg-cache | |
| VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg-cache,readwrite | |
| steps: | |
| - name: Checkout clipp | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Install build dependencies | |
| run: brew install autoconf autoconf-archive automake libtool ninja | |
| - name: Read vcpkg baseline | |
| id: vcpkg-baseline | |
| run: | | |
| baseline="$(python3 - <<'PY' | |
| import json | |
| with open("src/vcpkg.json", encoding="utf-8") as manifest_file: | |
| manifest = json.load(manifest_file) | |
| print(manifest.get("builtin-baseline", "")) | |
| PY | |
| )" | |
| if [[ -z "$baseline" ]]; then | |
| echo "src/vcpkg.json must define builtin-baseline for CI." >&2 | |
| exit 1 | |
| fi | |
| echo "ref=$baseline" >> "$GITHUB_OUTPUT" | |
| - name: Checkout vcpkg | |
| run: | | |
| git clone --no-tags https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT" | |
| git -C "$VCPKG_ROOT" checkout --detach "${{ steps.vcpkg-baseline.outputs.ref }}" | |
| - name: Bootstrap vcpkg | |
| run: | | |
| "$VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics | |
| - name: Prepare vcpkg binary cache | |
| run: mkdir -p "$VCPKG_DEFAULT_BINARY_CACHE" | |
| # Restore/save split (see windows-ci.yml): vcpkg's ABI hash includes the | |
| # toolchain version, so an Xcode/clang image update otherwise deadlocks a | |
| # combined actions/cache step into a permanent rebuild loop. | |
| - name: Restore vcpkg binary cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: vcpkg-cache | |
| key: ${{ runner.os }}-${{ runner.arch }}-vcpkg-${{ hashFiles('src/vcpkg.json', 'src/vcpkg-triplets/**') }}-ci-${{ github.run_id }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-vcpkg-${{ hashFiles('src/vcpkg.json', 'src/vcpkg-triplets/**') }}- | |
| ${{ runner.os }}-${{ runner.arch }}-vcpkg- | |
| - name: Build Release | |
| run: ./scripts/build_macos.sh | |
| - name: Save vcpkg binary cache | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: vcpkg-cache | |
| key: ${{ runner.os }}-${{ runner.arch }}-vcpkg-${{ hashFiles('src/vcpkg.json', 'src/vcpkg-triplets/**') }}-ci-${{ github.run_id }} | |
| - name: Verify macOS app bundle | |
| run: | | |
| app="$(find build -name 'clipp.app' -type d -print -quit)" | |
| if [[ -z "$app" ]]; then | |
| echo "Could not find clipp.app under build/." >&2 | |
| find build -print | sed -n '1,160p' | |
| exit 1 | |
| fi | |
| echo "Verifying app bundle: $app" | |
| find "$app/Contents" -print | sed -n '1,160p' | |
| for path in \ | |
| "$app/Contents/MacOS/clipp" \ | |
| "$app/Contents/Resources/Clipp.icns" \ | |
| "$app/Contents/Resources/ClippMenuBarTemplate.png" \ | |
| "$app/Contents/Resources/ClippAbout.png" \ | |
| "$app/Contents/Info.plist" | |
| do | |
| if [[ ! -e "$path" ]]; then | |
| echo "Missing expected bundle path: $path" >&2 | |
| exit 1 | |
| fi | |
| done | |
| if [[ ! -x "$app/Contents/MacOS/clipp" ]]; then | |
| echo "App executable is not executable: $app/Contents/MacOS/clipp" >&2 | |
| ls -l "$app/Contents/MacOS" | |
| exit 1 | |
| fi | |
| icon_file="$(plutil -extract CFBundleIconFile raw "$app/Contents/Info.plist")" | |
| if [[ "$icon_file" != "Clipp.icns" ]]; then | |
| echo "Expected CFBundleIconFile to be Clipp.icns, got '$icon_file'." >&2 | |
| exit 1 | |
| fi |