-
Notifications
You must be signed in to change notification settings - Fork 3
154 lines (128 loc) · 4.71 KB
/
build-freecad-app-bundle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
# 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@v2
# uses: actions/cache/restore@v4
with:
path: /opt/homebrew
key: ${{ runner.os }}-brewdeps
restore-keys: |
${{ runner.os }}-brewdeps
- 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