Only *save* cache on the default branch (develop), restore it everywhere it fits
93 lines
3.0 KiB
YAML
93 lines
3.0 KiB
YAML
name: Build MacOS Binary
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
macos_ver:
|
|
required: false
|
|
default: "26" # ARM64
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build-MacOS:
|
|
runs-on: macos-${{ inputs.macos_ver }}
|
|
# Only pushes to the default branch (develop) populate the cache; PR / merge_group runs
|
|
# restore it but never save, so they stop filling up the repo's Actions cache storage.
|
|
env:
|
|
SAVE_CACHE: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Capture runner image version (for caching)
|
|
id: r_image
|
|
run: echo "ver=$ImageVersion" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Restore Homebrew cache
|
|
id: brew-cache
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: ~/Library/Caches/Homebrew
|
|
key: brew-macos-${{ inputs.macos_ver }}-${{ steps.r_image.outputs.ver }}
|
|
|
|
- name: Install deps (Homebrew)
|
|
shell: bash
|
|
env:
|
|
# GitHub-Hosted MacOS runner images are updated frequently
|
|
# so skip running `brew update` to avoid unnecessary failures and delays.
|
|
HOMEBREW_NO_AUTO_UPDATE: "1"
|
|
HOMEBREW_NO_INSTALL_CLEANUP: "1"
|
|
run: >
|
|
brew install
|
|
platformio yaml-cpp libuv openssl@3 libusb argp-standalone pkg-config ulfius jsoncpp
|
|
|
|
- name: Save Homebrew cache
|
|
if: env.SAVE_CACHE == 'true' && steps.brew-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v6
|
|
with:
|
|
path: ~/Library/Caches/Homebrew
|
|
key: brew-macos-${{ inputs.macos_ver }}-${{ steps.r_image.outputs.ver }}
|
|
|
|
- name: Get release version string
|
|
run: |
|
|
echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
|
id: version
|
|
|
|
- name: Restore PlatformIO cache
|
|
id: pio-cache
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: ~/.platformio/.cache
|
|
key: pio-macos-${{ inputs.macos_ver }}-${{ hashFiles('platformio.ini', 'variants/native/portduino.ini') }}
|
|
restore-keys: |
|
|
pio-macos-${{ inputs.macos_ver }}-
|
|
|
|
- name: Build for MacOS
|
|
run: |
|
|
platformio run -e native-macos
|
|
env:
|
|
PKG_VERSION: ${{ steps.version.outputs.long }}
|
|
|
|
- name: Save PlatformIO cache
|
|
if: env.SAVE_CACHE == 'true' && steps.pio-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v6
|
|
with:
|
|
path: ~/.platformio/.cache
|
|
key: pio-macos-${{ inputs.macos_ver }}-${{ hashFiles('platformio.ini', 'variants/native/portduino.ini') }}
|
|
|
|
- name: List output files
|
|
run: ls -lah .pio/build/native-macos/
|
|
|
|
- name: Store binaries as an artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-macos-${{ inputs.macos_ver }}-${{ steps.version.outputs.long }}
|
|
overwrite: true
|
|
path: |
|
|
.pio/build/native-macos/meshtasticd
|