-
Notifications
You must be signed in to change notification settings - Fork 89
437 lines (358 loc) · 13.4 KB
/
draft_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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
name: 'Draft release: build binaries and run tests'
on:
# On new tags, build binaries and srpm, run a full brew test, and create a draft release automatically.
create:
# We often mess up the automatic build. Allow to correct manually (optionally with different build numbers)
workflow_dispatch:
inputs:
tag:
description: 'Release tag for which to build'
required: true
jobs:
checks:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.name.outputs.tag }}
release_id: ${{ steps.release.outputs.release_id }}
steps:
- name: Make tag name
id: name
run: |
ref=${{ github.ref }}
[ "${ref::10}" = 'refs/tags/' ] && tag=${ref:10} || tag=${{ github.event.inputs.tag }}
echo tag=${tag#v} | tee -a $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v3
with:
path: pympress
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Check tag matches python package version
continue-on-error: true
run: >
env PYTHONPATH=pympress python3 -c "import importlib;
assert importlib.import_module('pympress.__init__').__version__ == '${{ steps.name.outputs.tag }}'"
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -qy gettext
- name: Check latest translations are included
run: |
./pympress/scripts/poedit.sh download
git -C pympress status --porcelain $i18n_files | tee status
if [ -s status ]; then
echo "Unversioned translation updates:"
git diff -- $i18n_files
exit 1
fi
env:
poeditor_api_token: ${{ secrets.POEDITOR_API_TOKEN }}
i18n_files: README.md pympress/share/locale/pympress.pot pympress/share/locale/*/LC_MESSAGES/pympress.po
- name: Create a tarball of the release since we can not rely on getting it from the github release
env:
basename: pympress-${{ steps.name.outputs.tag }}
run: tar czf $basename.tar.gz --exclude-vcs --exclude=.github --transform="s/^pympress/$basename/" pympress/
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: tarball
path: pympress-${{ steps.name.outputs.tag }}.tar.gz
- name: Create draft GitHub Release
id: release
uses: softprops/action-gh-release@v1
with:
draft: true
tag_name: v${{ steps.name.outputs.tag }}
files: pympress-${{ steps.name.outputs.tag }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
macos:
name: Install and run test on mac
needs: checks
runs-on: macos-latest
steps:
- name: Configure brew repo
continue-on-error: true
run: |
cd "`brew --repo homebrew/core`"
git remote -v
git log -1 --decorate
grep head Formula/p/pympress.rb
brew update
# Credentials and remotes
git remote add gh "https://github.com/Cimbali/homebrew-core/"
git fetch gh
# Attempt a rebase of changes in our repo copy
git checkout --detach
git rebase origin/master gh/master && git branch -f master HEAD || git rebase --abort
# Now use master and update remote so we can use the bump-formula-pr
git checkout master
git log -1 --decorate
grep head Formula/p/pympress.rb
- name: Run the audit
continue-on-error: true
run: |
brew audit --strict pympress
- name: Install latest
run: |
brew install pympress --only-dependencies
brew install pympress --build-from-source --HEAD
- name: Test help output
if: always()
run: |
pympress --help
- name: Test starting pympress and quitting from the command line
if: always()
run: |
pympress --quit
- name: Check the log has been created from the previous step
if: always()
run: |
head ~/Library/Logs/pympress.log
- name: Run the brew test
if: always()
run: |
brew test pympress
- name: Debug the brew test
if: failure()
run: |
# NB. don’t use --debug which is interactive
brew test --keep-tmp --verbose pympress | tee test.log
tempdir=`sed -n '/Temporary files retained at/{n;p}' test.log`
tree -a $tempdir
srpm:
name: Source RPM
needs: checks
runs-on: ubuntu-latest
outputs:
file: ${{ steps.srpm.outputs.file }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -qy python3-rpm
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel twine babel pysrpm rpmlint
- name: Compile translations
run: |
python3 setup.py compile_catalog
- name: Build source rpm
id: srpm
env:
BUILD_DIR: build/rpm
run: |
mkdir srpm
pysrpm --dest-dir=srpm/ --source-only .
echo file=`find srpm/ -name '*.src.rpm' -printf '%P\n' -quit` | tee -a $GITHUB_OUTPUT
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
draft: true
tag_name: v${{ needs.checks.outputs.tag }}
fail_on_unmatched_files: true
files: srpm/${{ steps.srpm.outputs.file }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
- name: Check built RPM with rpmlint
run: rpmlint srpm/${{ steps.name.outputs.file }}
continue-on-error: true
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: source-rpm
path: srpm/${{ steps.name.outputs.file }}
rpmbuild:
name: Build binary RPMs for Source RPM
needs: srpm
runs-on: ubuntu-latest
container: fedora:latest
steps:
- name: Download from GitHub
uses: actions/download-artifact@v3
with:
name: source-rpm
path: .
- name: Install dependencies
# NB. querying requires on a source rpm should give us build requires
run: dnf install -y rpm-build `rpm -qR "${{ needs.srpm.outputs.file }}" | awk '$1 !~ /^rpmlib(.*)/ {print $1}'`
- name: Build binary from source spm
id: build
env:
srpm: ${{ needs.srpm.outputs.file }}
run: |
rpm -q --qf "dest=`rpm --eval %{_rpmfilename}`\n" "$srpm" | tee -a $GITHUB_OUTPUT
rpmbuild -D "_rpmdir ${PWD}" -ra "$srpm"
suse-rpmbuild:
name: Build Suse RPM end-to-end from spec to binary install
needs: checks
runs-on: ubuntu-latest
container: opensuse/tumbleweed
steps:
- name: Install most basic dependencies
run: zypper install -y rpm-build rpmlint osc
- name: Download tarball
uses: actions/download-artifact@v3
with:
name: tarball
path: .
- name: Get the spec file from OpenBuildService
run: |
trap 'rm -f ./osc-config' EXIT && echo "$OPENBUILDSERVICE_TOKEN_SECRET" > ./osc-config
osc --config ./osc-config co -o osc home:cimbali python-pympress
sed -r '
s/^(Version: *)[0-9.]+$/\1${{ needs.checks.outputs.tag }}/
s/^(Source0: *pympress-)[0-9.]+(\.tar\.gz)/\1${{ needs.checks.outputs.tag }}\2/
' osc/pympress.spec > pympress.spec
env:
OPENBUILDSERVICE_TOKEN_SECRET: ${{ secrets.OPENBUILDSERVICE_TOKEN_SECRET }}
- name: rpmlint specfile
continue-on-error: true
run: rpmlint pympress.spec
- name: Make a source rpm
id: srpm
run: |
filename=`rpm -q --qf "%{name}-%{version}-%{release}.src.rpm" --specfile pympress.spec`
echo "filename=$filename" | tee -a $GITHUB_OUTPUT
rpmbuild -D "_sourcedir $PWD" -D "_srcrpmdir $PWD" -bs pympress.spec
[ -f "$filename" ] # Check it’s the expected file name
- name: rpmlint source rpm
continue-on-error: true
run: rpmlint ${{ steps.srpm.outputs.filename }}
- name: Install build dependencies
# NB. querying requires on a source rpm should give us build requires
run: zypper install -y `rpm -qR "${{ steps.srpm.outputs.filename }}"`
- name: Build binary from source spm
id: build
run: |
filename=`rpm -q --qf "%{arch}/%{name}-%{version}-%{release}.%{arch}.rpm" "$srpm"`
echo "filename=$filename" | tee -a $GITHUB_OUTPUT
rpmbuild -D "_rpmdir ${PWD}" -ra "$srpm"
env:
srpm: ${{ steps.srpm.outputs.filename }}
- name: rpmlint rpm
continue-on-error: true
run: rpmlint ${{ steps.build.outputs.filename }}
- name: Install with runtime dependencies
run: zypper install -y --allow-unsigned-rpm ${{ steps.build.outputs.filename }}
- name: Run
run: env PYMPRESS_HEADLESS_TEST=1 pympress --quit
- name: Show log
run: head ${XDG_CACHE_HOME:-$HOME/.cache}/pympress.log
- name: Push changes to OpenBuildService
run: |
trap 'rm -f ./osc-config' EXIT && echo "$OPENBUILDSERVICE_TOKEN_SECRET" > ./osc-config
cd osc/
osc="osc --config ../osc-config"
$osc rm `sed -n 's/^Source0: *//p' pympress.spec`
cp ../pympress-${{ needs.checks.outputs.tag }}.tar.gz ./
$osc add pympress-${{ needs.checks.outputs.tag }}.tar.gz
cp ../pympress.spec ./
$osc ci -m "Update build to v${{ needs.checks.outputs.tag }}"
env:
OPENBUILDSERVICE_TOKEN_SECRET: ${{ secrets.OPENBUILDSERVICE_TOKEN_SECRET }}
windows-build:
name: Windows Binaries
needs: checks
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
include:
- { arch: x86_64, msystem: MINGW64 }
- { arch: i686, msystem: MINGW32 }
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup msys and dependencies
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
install: >-
git
zip
base-devel
mingw-w64-${{ matrix.arch }}-jq
mingw-w64-${{ matrix.arch }}-curl
mingw-w64-${{ matrix.arch }}-gtk3
mingw-w64-${{ matrix.arch }}-cairo
mingw-w64-${{ matrix.arch }}-poppler
mingw-w64-${{ matrix.arch }}-python3
mingw-w64-${{ matrix.arch }}-python3-pip
mingw-w64-${{ matrix.arch }}-python3-gobject
mingw-w64-${{ matrix.arch }}-python3-cairo
mingw-w64-${{ matrix.arch }}-python3-appdirs
mingw-w64-${{ matrix.arch }}-python3-setuptools
mingw-w64-${{ matrix.arch }}-python3-packaging
mingw-w64-${{ matrix.arch }}-python3-cx_Freeze
mingw-w64-${{ matrix.arch }}-python3-babel
mingw-w64-${{ matrix.arch }}-python3-watchdog
- name: Install ghostscript "base 35" fonts
shell: msys2 {0}
run: >
curl -L https://sourceforge.net/projects/gs-fonts/files/latest/download
| tar xzf - -C /${{ matrix.msystem }}/share/
- name: Install python-only dependencies
run: |
python3 -m pip install --disable-pip-version-check --upgrade pip
python3 -m pip install python-vlc
- name: Compile translations
run: python3 setup.py compile_catalog
- name: Build binary
run: python3 setup.py --freeze build_exe
- name: Make file basename
id: name
run: |
echo file=pympress-${{ needs.checks.outputs.tag }}-${{ matrix.arch }} | tee -a $GITHUB_OUTPUT
- name: Build installer
run: python3 setup.py --freeze bdist_msi --target-name ${{ steps.name.outputs.file }}.msi --skip-build
- name: Make portable install
run: |
cd build
mv exe.* pympress
cp ../pympress/share/defaults.conf pympress/pympress.conf
zip -r ../dist/${{ steps.name.outputs.file }}.zip pympress/
cd -
- name: Install pympress
shell: pwsh
run: |
$installer = gci -path dist\* -include *.msi -name
Start-Process msiexec.exe -Wait -NoNewWindow -ArgumentList ('/i "dist\{0}" /qn /norestart /L* installer.log' -f $installer)
echo "::group::Installer log"
get-content installer.log
echo "::endgroup::"
- name: Run pympress
shell: pwsh
run: |
# Check pympress install dir is appended to one of the $PATH variables
$dir = (
[System.Environment]::GetEnvironmentVariable("Path","Machine").split(";") +
[System.Environment]::GetEnvironmentVariable("Path","User").split(";")
) | Select-String 'pympress'
gci -path $dir -filter *exe
Start-Process "$dir\pympress.exe" -Wait -NoNewWindow -ArgumentList "--quit"
echo "::group::Pympress log"
get-content "$env:LOCALAPPDATA\pympress.log"
echo "::endgroup::"
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist-without-release
path: |
dist/*.zip
dist/*.msi
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
draft: true
tag_name: v${{ needs.checks.outputs.tag }}
fail_on_unmatched_files: true
files: |
dist/*.zip
dist/*.msi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}