-
Notifications
You must be signed in to change notification settings - Fork 2
293 lines (255 loc) · 10.1 KB
/
build.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
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: Build FujiNet-PC Launcher
on:
# push:
# branches: [ master ]
# pull_request:
# branches: [ master ]
workflow_dispatch:
inputs:
releaseBuild:
description: 'Prepare release bundle (adds tag)'
type: boolean
default: false
doRelease:
description: 'Create GitHub Release'
type: boolean
default: false
draftRelease:
description: 'Draft'
type: boolean
default: false
releaseVersion:
description: 'Release version, blank for auto'
jobs:
build-prep:
# prepare to build a release: create tag release-{version} pointing to head
runs-on: ubuntu-latest
name: Prepare
steps:
- name: Not release build
if: ${{ github.event.inputs.releaseBuild == 'false' }}
run: |
echo 'This build in not a release build.'
echo 'Release tag will not be created.'
echo 'However if release tag exists on HEAD, it will be used to make a release build.'
- name: Prepeare for release build
if: ${{ github.event.inputs.releaseBuild == 'true' }}
run: |
echo 'This build is release build.'
echo 'New release tag will be created (or existing tag on HEAD will be used) to make a release build.'
- name: '🧰 Checkout'
if: ${{ github.event.inputs.releaseBuild == 'true' }}
uses: actions/checkout@v3
- name: Fetch tags
if: ${{ github.event.inputs.releaseBuild == 'true' }}
run: git fetch --prune --unshallow --tags
- name: Prepare release tag
if: ${{ github.event.inputs.releaseBuild == 'true' }}
run: python build_version.py release:push ${{ github.event.inputs.releaseVersion }}
scripts:
name: 'Bundle scripts (no binaries)'
needs: build-prep
runs-on: ubuntu-latest
if: ${{ github.event.inputs.releaseBuild == 'true' }}
outputs:
release_version: ${{ steps.version.outputs.release }}
launcher_version: ${{ steps.version.outputs.launcher }}
steps:
- name: '🧰 Checkout Launcher'
uses: actions/checkout@v3
with:
path: fujinet-pc-launcher
- name: '🧰 Checkout Emulator Bridge'
uses: actions/checkout@v3
with:
repository: FujiNetWIFI/fujinet-emulator-bridge
path: fujinet-emulator-bridge
- name: Fetch tags
working-directory: fujinet-pc-launcher
run: git fetch --prune --unshallow --tags
- name: Update launcher version
working-directory: fujinet-pc-launcher
run: python build_version.py
- name: Get launcher version
id: version
working-directory: fujinet-pc-launcher/launcher
# prevent __pycache__ to be created
env:
PYTHONDONTWRITEBYTECODE: 1
run: |
python -c 'import version; print(version.VERSION_FULL)'
echo "launcher=$(python -c 'import version; print(version.VERSION_FULL)')" >> $GITHUB_OUTPUT
echo "release=$(python -c 'import version; print(version.VERSION_FULL)' | sed 's/\(\.[1-9]\)\..*/\1/')" >> $GITHUB_OUTPUT
- name: Populate dist directory
run: |
mkdir dist
mkdir dist/emulator
cp -av fujinet-pc-launcher/launcher dist
cp -av fujinet-emulator-bridge/fujinet-bridge/netsiohub dist
cp -av fujinet-emulator-bridge/altirra-custom-device dist/emulator/Altirra
mkdir dist/fujinet-pc
echo 'This directory is for FujiNet-PC executable.' > dist/fujinet-pc/README.txt
echo 'Visit https://github.com/FujiNetWIFI/fujinet-pc/releases to download binaries for your OS.' >> dist/fujinet-pc/README.txt
echo 'Place extracted files here.' >> dist/fujinet-pc/README.txt
- name: List dist
run: ls -lR dist
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: fujinet-pc-scripts_${{ steps.version.outputs.release }}
path: dist/**
build:
# Build binary bundles
needs: build-prep
strategy:
fail-fast: false
matrix:
name: [Windows]
target: [windows-x64]
runner: [windows-latest]
include:
# - name: Ubuntu 22.04
# target: ubuntu-22.04-amd64
# runner: ubuntu-22.04
# default-shell: bash
# - name: Ubuntu 18.04
# target: ubuntu-18.04-amd64
# runner: ubuntu-18.04
# default-shell: bash
- name: macOS 12
target: macos-12
runner: macos-12
# continue-on-error: true
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
steps:
- name: '🧰 Checkout Launcher'
uses: actions/checkout@v3
with:
path: fujinet-pc-launcher
- name: '🧰 Checkout Emulator Bridge'
uses: actions/checkout@v3
with:
repository: FujiNetWIFI/fujinet-emulator-bridge
path: fujinet-emulator-bridge
- name: Fetch tags
working-directory: fujinet-pc-launcher
run: git fetch --prune --unshallow --tags
- name: 'Copy NetSIO hub module'
shell: bash
run: cp -av fujinet-emulator-bridge/fujinet-bridge/netsiohub fujinet-pc-launcher
- name: 'List directories'
shell: bash
run: |
pwd
ls -lR .
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
architecture: 'x64'
- name: List versions
run: |
python --version
pip --version
- name: Install requirements
working-directory: fujinet-pc-launcher
run: pip install -r requirements_build.txt
- name: Update launcher version
working-directory: fujinet-pc-launcher
run: python build_version.py
- name: '🚧 [Windows] Build FujiNet-PC Launcher'
if: ${{ startsWith(matrix.target, 'windows') }}
working-directory: fujinet-pc-launcher
run: pyinstaller --clean --onedir --noconfirm --noconsole --python-option u --name launcher --icon launcher\images\launcher-bg.ico --add-data "launcher\images;images" launcher\__main__.py
- name: '🚧 [macOS] Build FujiNet-PC Launcher'
if: ${{ startsWith(matrix.target, 'macos') }}
working-directory: fujinet-pc-launcher
run: pyinstaller --clean --onedir --noconfirm --noconsole --python-option u --name launcher --icon launcher/images/launcher-bg.ico --add-data launcher/images:images launcher/__main__.py
- name: 'Get launcher version'
id: version
working-directory: fujinet-pc-launcher
shell: bash
run: |
python -m launcher -V
echo "launcher=$(python -m launcher -V | awk '{if(tolower($1)=="fujinet-pc" && tolower($2)=="launcher") print $3}')" >> $GITHUB_OUTPUT
echo "release=$(python -m launcher -V | awk '{if(tolower($1)=="fujinet-pc" && tolower($2)=="launcher") print $3}' | sed 's/\(\.[1-9][0-9]*\)\..*/\1/')" >> $GITHUB_OUTPUT
- name: Update dist with emulator files
if: ${{ github.event.inputs.releaseBuild == 'true' }}
shell: bash
run: |
mkdir -p fujinet-pc-launcher/dist/emulator
cp -av fujinet-emulator-bridge/altirra-custom-device fujinet-pc-launcher/dist/emulator/Altirra
- name: 'Download latest FujiNet-PC release'
if: ${{ github.event.inputs.releaseBuild == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python fujinet-pc-launcher/launcher/download_release.py "fujinet-pc_*_${{ matrix.target }}.*"
- name: '[Windows] Unzip FujiNet-PC into dist'
if: ${{ startsWith(matrix.target, 'windows') && github.event.inputs.releaseBuild == 'true' }}
run: 7z x -ofujinet-pc-launcher/dist fujinet-pc_*_${{ matrix.target }}.zip
- name: '[macOS] Uncompress FujiNet-PC into launcher.app'
if: ${{ startsWith(matrix.target, 'macos') && github.event.inputs.releaseBuild == 'true' }}
run: tar -xzf fujinet-pc_*_${{ matrix.target }}.tar.gz -C fujinet-pc-launcher/dist/launcher.app/Contents
- name: '[macOS] Remove dist/launcher (keep launcher.app only)'
if: ${{ startsWith(matrix.target, 'macos') && github.event.inputs.releaseBuild == 'true' }}
run: rm -rf fujinet-pc-launcher/dist/launcher
- name: List dist
shell: bash
run: ls -lR fujinet-pc-launcher/dist
# To preserve executable bit on files (GH artifacts are automatically zipped and executable bit is lost)
- name: 'Tar dist files'
shell: bash
working-directory: fujinet-pc-launcher/dist
run: |
tar -czf ../fujinet-pc-bundle_${{ steps.version.outputs.release }}_${{ matrix.target }}.tgz *
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: fujinet-pc-bundle_${{ steps.version.outputs.release }}_${{ matrix.target }}
path: fujinet-pc-launcher/fujinet-pc-bundle_${{ steps.version.outputs.release }}_${{ matrix.target }}.tgz
release:
if: ${{ github.event.inputs.releaseBuild == 'true' && github.event.inputs.doRelease == 'true'}}
# Create release
runs-on: ubuntu-latest
name: Release
needs: [scripts, build]
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
path: release
- name: Display structure of downloaded files
run: ls -lR release
- name: 'Zip release files (scripts and windows)'
working-directory: release
run: |
for D in fujinet-pc-scripts_*
do
zip -r ${D}.zip $D
tar -czvf ${D}.tar.gz $D
done
for D in fujinet-pc-bundle_*windows*
do
(
cd $D
F=(fujinet-pc-bundle_*.tgz)
mkdir dist
tar -xzvf $F -C dist
rm -f $F
cd dist
zip -r ../${F%.*}.zip *
)
done
- name: Release
uses: softprops/action-gh-release@v1
with:
name: "FujiNet-PC Launcher ${{ needs.scripts.outputs.release_version }}"
tag_name: release-${{ needs.scripts.outputs.release_version }}
draft: ${{ github.event.inputs.draftRelease }}
files: |
release/fujinet-pc-scripts_*.tar.gz
release/fujinet-pc-scripts_*.zip
release/fujinet-pc-bundle_*/fujinet-pc-bundle_*.tgz
release/fujinet-pc-bundle_*/fujinet-pc-bundle_*.zip