forked from kichik/nsis
-
Notifications
You must be signed in to change notification settings - Fork 7
289 lines (253 loc) · 10.8 KB
/
build-n-release.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
name: Build and Release
on:
push:
branches:
- master
- 'feature/**'
- 'bugfix/**'
- 'github/**'
workflow_dispatch:
jobs:
build:
name: Build
outputs:
# accessible from other jobs as ${{needs.build.outputs.version_full}}
version_full: ${{steps.version.outputs.version_full}}
version_packed: ${{steps.version.outputs.version_packed}}
version_major: ${{steps.version.outputs.version_major}}
version_minor: ${{steps.version.outputs.version_minor}}
version_revision: ${{steps.version.outputs.version_revision}}
version_build: ${{steps.version.outputs.version_build}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # nothing works on macos-latest (`cppunit` fails to build. `zlib` not found)
arch: [x86, amd64]
compiler: [gcc]
include:
- os: windows-latest
arch: x86
compiler: msvc
- os: windows-latest
arch: amd64
compiler: msvc
runs-on: ${{ matrix.os }}
steps:
- name: Brew Dependencies
if: startsWith(matrix.os, 'macos')
run: |
brew install scons mingw-w64 libtool autoconf automake
- name: Apt Dependencies
if: startsWith(matrix.os, 'ubuntu')
run: sudo DEBIAN_FRONTEND=noninteractive apt-get install -y scons mingw-w64
- name: Setup Python
if: startsWith(matrix.os, 'windows')
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Windows Dependencies
if: startsWith(matrix.os, 'windows')
run: |
# install scons excluding build 4.8.0 (https://github.com/SCons/scons/issues/4585)
pip install -U scons!=4.8.0
#pip install -U scons
# microsoft removed the download of htmlhelp.exe -- https://chocolatey.org/packages/html-help-workshop#comment-5245282888
#choco install html-help-workshop
echo "${Env:ProgramFiles(x86)}\HTML Help Workshop" >> $Env:GITHUB_PATH
echo -------------------------------------------------------------
py -0p
pip list
- name: Upgrade msys2/mingw64
if: startsWith(matrix.os, 'windows') && matrix.compiler == 'gcc'
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
release: false
update: true
install: >-
libtool
autoconf-wrapper
automake-wrapper
# `fetch-depth: 0` pulls full branch history. Needed to extract the SVN revision number from git comments
- name: Checkout
uses: actions/checkout@v4
with:
path: nsis
submodules: 'true'
fetch-depth: 0
- name: Version
id: version
shell: python
working-directory: nsis
run: |
import sys, os
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis'))
from nsis_version import *
version_full = nsis_version(build_number=${{github.run_number}})
version_packed = nsis_packed_version(build_number=${{github.run_number}})
version_major = nsis_major_version()
version_minor = nsis_minor_version()
version_revision = nsis_revision_number()
version_build = nsis_build_number(${{github.run_number}})
print(f"version_full={version_full}")
print(f"version_full=[{version_major}, {version_minor}, {version_revision}, {version_build}]")
print(f"version_packed={version_packed}")
with open(os.getenv('GITHUB_OUTPUT'), "a") as fout:
fout.write(f"version_full={version_full}\n")
fout.write(f"version_packed={version_packed}\n")
fout.write(f"version_major={version_major}\n")
fout.write(f"version_minor={version_minor}\n")
fout.write(f"version_revision={version_revision}\n")
fout.write(f"version_build={version_build}\n")
- name: Zlib Checkout & Build
shell: python
working-directory: nsis
run: |
import sys, os
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis'))
from nsis_build import *
# ----- nsis_build.py -----
zlibdir = os.path.join(r'${{github.workspace}}', 'zlib')
git_checkout('https://github.com/madler/zlib.git', zlibdir)
build_zlib(r'${{matrix.compiler}}', r'${{matrix.arch}}', zlibdir)
- name: Debug MacOS
if: startsWith(matrix.os, 'macos')
run: |
ls -la /usr/bin/i686* || echo "no /usr/bin/i686* files"
echo ------------------------------------------------------------
ls -la /usr/bin/x86_64* || echo "no /usr/bin/x86_64* files"
echo ------------------------------------------------------------
ls -la /usr/bin/*-13 || echo "no /usr/bin/*-13 files"
ls -la /usr/local/bin/*-13 || echo "no /usr/local/bin/*-13 files"
echo ------------------------------------------------------------
ls -la /usr/local/Cellar/gcc@13/13.3.0/bin/* || echo "/usr/local/Cellar/gcc@13/13.3.0/bin/* files"
echo ------------------------------------------------------------
ls -la /opt/homebrew/bin/i686* || echo "no /opt/homebrew/bin/i686* files"
echo ------------------------------------------------------------
ls -la /opt/homebrew/bin/x86_64* || echo "no /opt/homebrew/bin/x86_64* files"
echo ------------------------------------------------------------
for compiler in cc c++ gcc g++ gcc-13 g++-13 clang clang++
do
echo -- $compiler --------------------------------------------------------
which $compiler
$compiler --version
done
- name: CppUnit Checkout & Build
shell: python
working-directory: nsis
run: |
import sys, os
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis'))
from nsis_build import *
# ----- nsis_build.py -----
cppunitdir = os.path.join(r'${{github.workspace}}', 'cppunit')
#git_checkout('git://anongit.freedesktop.org/git/libreoffice/cppunit', cppunitdir) # git server is unreliable lately
download_cppunit(cppunitdir)
build_cppunit(r'${{matrix.compiler}}', r'${{matrix.arch}}', cppunitdir)
- name: Build NSIS
working-directory: nsis
shell: python
run: |
import sys, os
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis'))
from nsis_build import *
# ----- nsis_build.py -----
zlibdir = os.path.join(r'${{github.workspace}}', 'zlib')
cppunitdir = os.path.join(r'${{github.workspace}}', 'cppunit')
build_nsis_distro(r'${{matrix.compiler}}', r'${{matrix.arch}}', ${{github.run_number}}, zlibdir, cppunitdir, nsislog=True, nsismaxstrlen=4096, actions=['test', 'dist-zip'])
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{matrix.os}}-${{matrix.arch}}-${{matrix.compiler}}
path: nsis/nsis-*.zip
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package:
name: Package
needs: build
runs-on: ubuntu-latest
steps:
# `fetch-depth: 0` pulls full branch history. Needed to extract the SVN revision number from git comments
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: artifacts-*
- name: Merge Architectures
shell: python
run: |
import sys, os
sys.path.insert(0, r'${{github.workspace}}')
from nsis_package import *
# ----- nsis_package.py -----
# blend x86 and amd64 artifacts together
build_nsis_package('artifacts', '.instdist-ubuntu-x86', '.instdist-ubuntu-amd64')
- name: Build NSIS Setup (x86)
shell: python
run: |
import sys, os
sys.path.insert(0, r'${{github.workspace}}')
from nsis_package import *
# ----- nsis_package.py -----
build_nsis_installer('.instdist-ubuntu-x86', 'x86', ${{needs.build.outputs.version_major}}, ${{needs.build.outputs.version_minor}}, ${{needs.build.outputs.version_revision}}, ${{needs.build.outputs.version_build}})
- name: Build NSIS Setup (amd64)
shell: python
run: |
import sys, os
sys.path.insert(0, r'${{github.workspace}}')
from nsis_package import *
# ----- nsis_package.py -----
build_nsis_installer('.instdist-ubuntu-amd64', 'amd64', ${{needs.build.outputs.version_major}}, ${{needs.build.outputs.version_minor}}, ${{needs.build.outputs.version_revision}}, ${{needs.build.outputs.version_build}})
- name: Upload NSIS Setup (x86)
uses: actions/upload-artifact@v4
with:
name: nsis-x86-setup
path: .instdist-ubuntu-x86/nsis*-x86.exe
- name: Upload NSIS Setup (amd64)
uses: actions/upload-artifact@v4
with:
name: nsis-amd64-setup
path: .instdist-ubuntu-amd64/nsis*-amd64.exe
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
release:
name: Release Draft
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/github/')
needs: [build, package]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download NSIS
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: nsis-*-setup
merge-multiple: true
- name: Prepare release notes
shell: python
run: |
lines = []
with open(".github/workflows/release-body.md") as fin:
line = fin.read()
line = line.replace('{version-gcc}', 'todo')
line = line.replace('{url-workflow}', 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}')
lines.append(line)
with open(".github/workflows/release-body.md", "w") as fout:
for line in lines:
fout.write(line)
- name: Create GitHub release draft
uses: ncipollo/release-action@v1
with:
# note: `tag` is the release key
tag: release-candidate
name: v${{needs.build.outputs.version_full}}
artifacts: artifacts/*.exe
bodyFile: .github/workflows/release-body.md
draft: true
makeLatest: true
allowUpdates: true
updateOnlyUnreleased: true
artifactErrorsFailBuild: true
removeArtifacts: true