-
Notifications
You must be signed in to change notification settings - Fork 156
231 lines (196 loc) · 6.84 KB
/
build-darwin-arm64.yaml
File metadata and controls
231 lines (196 loc) · 6.84 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: build-darwin-arm64
on:
workflow_call:
env:
# These are set later.
TARGET_PLATFORM: ""
PYTHON_VERSION: ""
APIO_REPO: ""
APIO_COMMIT: ""
RELEASE_TAG: ""
PACKAGE_TAG: ""
jobs:
build:
runs-on: macos-latest
defaults:
run:
shell: bash # Set Bash as the default shell
steps:
- name: Check required platform
uses: fpgawars/apio-workflows/.github/actions/check-platform@main
with:
os: darwin
arch: arm64
# - name: Checkout this repo (for builder)
# uses: actions/checkout@v4
- name: Download build-info.json artifact from main job
uses: actions/download-artifact@v4
with:
merge-multiple: true
name: build-info
path: _artifacts
- name: Move build info
run: |
find _artifacts
mv _artifacts/build-info.json .
cat -n build-info.json
- name: Add platform info to build info json file
uses: fpgawars/apio-workflows/.github/actions/write-to-json-file@main
with:
json-file: build-info.json
key: target-platform
value: darwin-arm64
- name: Format build info json file
uses: fpgawars/apio-workflows/.github/actions/format-json-file@main
with:
json-file: build-info.json
- name: Set env vars from JSON
uses: fpgawars/apio-workflows/.github/actions/set-env-from-json@main
with:
json-file: build-info.json
mappings: >-
TARGET_PLATFORM target-platform
PYTHON_VERSION apio-python-version
APIO_REPO repo
APIO_COMMIT repo-commit
APIO_VERSION apio-cli-version
RELEASE_TAG release-tag
PACKAGE_TAG package-tag
# -- This is the python that will be included in pyinstaller.
- name: Install python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
# We checkout the repo into a subdirectory not to step on build-info.json.
- name: Checkout this repo
uses: actions/checkout@v4
with:
repository: ${{env.APIO_REPO}}
ref: ${{env.APIO_COMMIT}}
path: _apio-repo
- name: Set apio release info
uses: ./_apio-repo/.github/actions/set-apio-release-info
with:
repo_path: _apio-repo
platform_id: ${{env.TARGET_PLATFORM}}
release_type: pyinst
release_tag: ${{env.RELEASE_TAG}}
- name: Pip install apio
run: |
python -m pip install --upgrade pip
pip install -e _apio-repo
- name: Pip install pyinstaller
run: |
pip install pyinstaller
- name: Setup working directories
run: |
mkdir _work
mkdir _dist
mkdir _scripts
pwd
ls -la .
- name: Run pyinstaller
run: |
pyinstaller \
--log-level=DEBUG \
--workpath _work \
--distpath _dist \
_apio-repo/.github/workflows/resources/apio-pyinstaller.spec
echo "_dist:"
ls -al _dist
echo "_dist/apio:"
ls -al _dist/apio
- name: Show symlinks
run: |
# Per the link below, _dist may contain symlinks that
# we need to propagate all the way.
# https://github.com/orgs/pyinstaller/discussions/9166
echo "Searching for symlinks:"
find _dist -type l
- name: Add the build info file
run: |
cp build-info.json _dist/apio/BUILD-INFO.json
cat -n _dist/apio/BUILD-INFO.json
- name: Add the LICENSE file
run: |
# cp _apio-repo/LICENSE _dist/apio
cp _apio-repo/LICENSE _dist/apio
cat _dist/apio/LICENSE
- name: Add the 'readme' file
run: |
cat <<EOF > _dist/apio/README.txt
This is the Apio file bundle for macOS arm64.
For installation instructions see
https://fpgawars.github.io/apio/installing-apio/#mac-arm64-bundle
For bundle information see BUILD-INFO.json.
EOF
- name: List the bundle files
run: |
find _dist
# We use .tgz and not .zip to preserve symlinks.
- name: Compress the pyinstaller bundle
run: |
pushd _dist
bundle="apio-cli-darwin-arm64-${PACKAGE_TAG}-bundle.tgz"
tar zcf ../${bundle} apio
popd
ls -al
- name: Delete the readme files
run: |
rm _dist/apio/README.txt
echo "_dist/apio:"
ls -al _dist/apio
# This sets the app name in /Applications
- name: Rename apio to Apio
run: |
mv _dist/apio _dist/Apio
echo "_dist:"
ls -al _dist
- name: Create installer postinstall scripts
run: |
cp _apio-repo/.github/workflows/resources/darwin/postinstall _scripts/postinstall
chmod 755 _scripts/postinstall
echo "_scripts:"
ls -al _scripts
echo "_scripts/postinstall:"
cat -n _scripts/postinstall
- name: Run pkgbuild
run: |
pkgbuild --root _dist \
--install-location /Applications \
--identifier "io.github.fpgawars.apio" \
--version "${APIO_VERSION}" \
--scripts _scripts \
--ownership recommended \
apio-component.pkg
pwd
ls -al
- name: Run productbuild
run: |
productbuild --resources _apio-repo/.github/workflows/resources/darwin \
--distribution _apio-repo/.github/workflows/resources/darwin/distribution.xml \
--package-path . \
"apio-cli-darwin-arm64-${PACKAGE_TAG}-installer.pkg"
pwd
ls -al
# -- Now that we are done with the file bundle directory
# -- let's test it.
- name: Uninstall all pip packages (including apio)
uses: fpgawars/apio-workflows/.github/actions/uninstall-all-pip-packages@main
- name: Test Apio file bundle
uses: ./_apio-repo/.github/actions/test-apio-bundle
with:
apio-bundle-dir: _dist/Apio
work-dir-name: _work_dir
- name: Export the pyinstaller bundle as an artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: "apio-cli-darwin-arm64-bundle"
path: "apio-cli-darwin-arm64-${{env.PACKAGE_TAG}}-bundle.tgz"
- name: Export the installer file as an artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: "apio-cli-darwin-arm64-installer"
path: "apio-cli-darwin-arm64-${{env.PACKAGE_TAG}}-installer.pkg"