Build FreeCAD MacOS app bundle #115
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
--- | |
# TODOS: | |
# 1. [x] setup more descriptive filenames for homebrew package cache ie. macos-14-arm64-brew-[hash] | |
# 2. [ ] setup step to clone the freecad github repo | |
# 3. [ ] cache the cloned repo. | |
# 4. [ ] check for outdated deps after restoring the cache | |
# REFS: | |
# 1. example of work around for updating cache: https://github.com/actions/cache/issues/342#issuecomment-1711054115 | |
# 2. saveing & restoring cache: https://github.com/marketplace/actions/cache#skipping-steps-based-on-cache-hit | |
# 3. https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key | |
# MILESTONES: | |
# 1. https://github.com/ipatch/homebrew-us-05/blob/1982e316043c68d47b9045b22bc991810807b13e/.github/workflows/build-freecad-app-bundle.yml | |
# - cache appears to be restored, deleted, and then saved in the following order | |
name: Build FreeCAD MacOS app bundle | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
actions: write | |
env: | |
HOMEBREW_NO_ANALYTICS: 1 | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALL_CLEANUP: 1 | |
HOMEBREW_NO_INSTALL_FROM_API: 1 | |
HOMEBREW_DEVELOPER: 1 | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
# max-parallel: 1 | |
matrix: | |
os: [macos-14] | |
arch: [x64, arm64] | |
# - macos-13 | |
# - macos-12 | |
runs-on: ${{ matrix.os }} | |
# env: | |
# cache-key: your-cache-key | |
# cache-key: ${{ env.envHash }}-freecad-deps-${{ runner.os }}-brew | |
timeout-minutes: 1200 | |
steps: | |
- name: set foos | |
id: set-foos | |
run: | | |
echo "foo=bar" >> "$GITHUB_OUTPUT" | |
- name: print foos | |
id: print-foos | |
env: | |
foo: ${{ steps.set-foos.outputs.foo }} | |
run: echo "the value of foo is $foo" | |
- name: set specific vars based on OS and arch | |
id: set-os-arch-vars | |
run: | | |
echo "my_os=${{ matrix.os }}" >> "$GITHUB_ENV" | |
echo "my_arch=${{ matrix.arch }}" >> "$GITHUB_ENV" | |
- name: set brew prefix | |
id: set-brew-prefix | |
run: | | |
bp=$(brew --prefix) | |
echo "bp=\"$bp\"" >> "$GITHUB_OUTPUT" | |
echo "bp=\"$bp\"" >> "$GITHUB_ENV" | |
- name: Print Brew Prefix | |
id: print-brew-prefix | |
env: | |
bp: ${{ steps.set-brew-prefix.outputs.bp }} | |
run: | | |
echo "the value of bp is set to $bp" | |
- name: checkout | |
uses: actions/checkout@v3 # gh command require repository | |
- name: Remove preinstalled Homebrew packages | |
# if: ${{ steps.cache-brewdeps-restore.outputs.cache-hit != 'true' }} | |
id: rm-default-brew-packages | |
run: | | |
brew list --formula | xargs brew uninstall --formula --force; | |
brew list --cask | xargs brew uninstall --cask --force; | |
brew cleanup | |
- name: restore cache | |
if: env.my_os == 'macos-14' && env.my_arch == 'arm64' | |
id: cache-brewdeps-restore | |
uses: actions/cache@v3 | |
# uses: actions/cache@v2 | |
# uses: actions/cache/restore@v4 | |
with: | |
path: /opt/homebrew | |
key: ${{ runner.os }}-brewdeps | |
restore-keys: | | |
${{ runner.os }}-brewdeps | |
${{ runner.os }}-*-brew | |
${{ runner.os }}- | |
- name: setup freecad tap | |
if: ${{ steps.cache-brewdeps-restore.outputs.cache-hit != 'true' }} | |
id: setup-freecad-tap | |
run: | | |
brew tap -v freecad/freecad | |
- name: install freecad deps | |
if: ${{ steps.cache-brewdeps-restore.outputs.cache-hit != 'true' }} | |
id: install-freecad-deps | |
run: | | |
brew install wget gh zstd; | |
brew install --only-dependencies --formula -v freecad/freecad/freecad; | |
- name: update & upgrade brew & formula / packages | |
run: | | |
brew update -v; | |
brew upgrade -v; | |
- name: delete previous cache | |
if: ${{ steps.cache-brewdeps-restore.outputs.cache-hit }} | |
continue-on-error: true | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh extension install actions/gh-actions-cache | |
gh actions-cache delete "${{ runner.os }}-brewdeps" --confirm | |
- name: cache & save homebrew setup | |
if: env.my_os == 'macos-14' && env.my_arch == 'arm64' | |
uses: actions/cache/save@v4 | |
# uses: actions/cache/@v4 | |
with: | |
path: /opt/homebrew | |
#---- | |
# NO WORK! # using tecolicom/actions-install-and-cache | |
# path: ${{ steps.set-brew-prefix-and-cache-paths.outputs.bp }} | |
# path: $(brew --prefix) | |
# path: $bp | |
# path: ${{ env.bp }} # does not properly save /opt/homebrew on macos arm64 | |
#---- | |
key: ${{ runner.os }}-brewdeps | |
# - name: intentionally fail | |
# run: exit 1 | |
- name: debug with tmate on failure | |
if: ${{ failure() }} | |
uses: mxschmitt/action-tmate@v3 | |