-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
662 lines (586 loc) · 17.1 KB
/
.gitlab-ci.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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
stages:
- build
- pre-package
- package
- deploy
variables:
BRIEFCASE_VERSION: "0.3.20"
build:sdist:
stage: build
# Usually, a minimal image like `alpine` would be sufficient to build a sdist
# but gr does not build on alpine currently and is a build dependency for pymoldyn.
image: debian:12
before_script:
- apt-get update
- apt-get install -y
pipx
script:
- pipx run build --sdist
artifacts:
paths:
- dist/*.tar.gz
build:wheel:linux:
stage: build
image: docker:latest
tags:
- privileged-executor
variables:
CIBW_ARCHS: "auto64"
CIBW_BEFORE_BUILD: "python -m pip install wheel"
CIBW_BUILD: "cp*-manylinux*"
# Do not use `auditwheel` since libGR3.so would be detected as missing but will be loaded by the `gr` package.
# Use the `wheel` command to retag the wheel as `manylinux2014_x86_64` (current default build image in CIBW)
CIBW_REPAIR_WHEEL_COMMAND: >
manylinux_wheel_filename=$(python -m wheel tags --platform-tag manylinux2014_x86_64 {wheel}) &&
mv $(dirname {wheel})/$${manylinux_wheel_filename} {dest_dir}/
before_script:
- apk --no-cache add pipx
script:
- pipx run 'cibuildwheel <3' --output-dir dist
artifacts:
paths:
- dist/*.whl
build:wheel:macos:
stage: build
image: macos:sonoma-xcode
tags:
- utm
variables:
CIBW_ARCHS: "universal2 x86_64 arm64"
CIBW_BUILD: "cp*"
CIBW_REPAIR_WHEEL_COMMAND: "" # libGR3.so would be detected as missing but will be loaded by the `gr` package
before_script:
- /usr/bin/python3 -m pip install 'cibuildwheel <3'
script:
- /usr/bin/python3 -m cibuildwheel --output-dir dist
artifacts:
paths:
- dist/*.whl
build:wheel:windows:
stage: build
image: windows:10-python3
tags:
- libvirt
variables:
CIBW_ARCHS: "auto64"
CIBW_BUILD: "cp*"
CIBW_REPAIR_WHEEL_COMMAND: "" # libGR3.dll could be detected as missing but will be loaded by the `gr` package
before_script:
- vcvars_cmd python -m pip install 'cibuildwheel <3'
script:
- vcvars_cmd python -m cibuildwheel --output-dir dist
artifacts:
paths:
- dist/*.whl
pre-package:
stage: pre-package
image: debian:12
needs: []
before_script:
- apt-get update
- apt-get install -y
gawk
git
pipx
vim
- export PATH="${HOME}/.local/bin:${PATH}"
# Upgrade `pipx` since it is quite old in Debian bookworm and does not support to run scripts with `pipx run`
- pipx install pipx
- pipx install "briefcase==${BRIEFCASE_VERSION}"
script:
- project_name="$(
gawk
-F'[="[:space:]]+'
'$1 == "name" {
print $2
}'
pyproject.toml
)"
- project_name_lowercase="$(echo "$project_name" | tr '[:upper:]' '[:lower:]')"
- project_version="$(
python3 -c "$(
gawk
-F'[={}"[:space:]]+'
'$1 == "version" && $2 == "attr" {
match($3, "(.+)\\.(.+)", c);
printf(
"import runpy; g = runpy.run_path(\"%s\".replace(\".\", \"/\") + \".py\"); print(g[\"%s\"])\n",
c[1],
c[2]
)
}'
pyproject.toml
)"
)"
- |
cat <<'EOF' >convert_icon.py
#!/usr/bin/env -S pipx run
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "pillow",
# ]
# ///
import os
import sys
from PIL import Image
def create_iconset(icon_path):
icon_out_path_template = os.path.splitext(icon_path)[0] + "-{size}.png"
original_icon = Image.open(icon_path)
for filepath, size in (
(icon_out_path_template.format(size=size), size) for size in (16, 32, 64, 128, 256, 512)
):
resized_icon = original_icon.resize((size, size), Image.LANCZOS)
resized_icon.save(filepath)
def main():
create_iconset(sys.argv[1])
if __name__ == "__main__":
main()
EOF
- chmod +x convert_icon.py
- touch CHANGELOG
- ./convert_icon.py "${project_name_lowercase}/icon.png"
- briefcase convert --no-input
- ex
-s
"+%s/^project_name = *\".*/project_name = \"${project_name}\"/"
"+%s/^formal_name = *\".*/formal_name = \"${project_name}\"/"
'+%s/^bundle =.*/bundle = "de.fzj"/'
"+%s/^version = *\".*/version = \"${project_version}\"/"
+x
pyproject.toml
- |
ex -s pyproject.toml <<'EOF'
/^long_description
d2
-1
y
pu
s/description/long_description/
x
EOF
- |
cat <<EOF >>pyproject.toml
icon = "${project_name_lowercase}/icon"
[tool.briefcase.app.${project_name_lowercase}.linux]
requires = [
]
[tool.briefcase.app.${project_name_lowercase}.linux.system.debian]
system_requires = [
]
system_runtime_requires = [
# Derived from https://doc.qt.io/qt-6/linux-requirements.html
"libdbus-1-3",
"libegl1",
"libfontconfig1",
"libgl1",
"libglib2.0-0",
"libice6",
"libsm6",
"libx11-xcb1",
"libxcb-cursor0",
"libxcb-icccm4",
"libxcb-image0",
"libxcb-keysyms1",
"libxcb-randr0",
"libxcb-shape0",
"libxcb-sync1",
"libxcb-xfixes0",
"libxext6",
"libxkbcommon-x11-0",
"libxrender1",
]
[tool.briefcase.app.${project_name_lowercase}.linux.system.rhel]
system_requires = [
]
system_runtime_requires = [
# Derived from the Debian \`system_requires\` list
"dbus-libs",
"mesa-libEGL",
"fontconfig",
"mesa-libGL",
"glib2",
"libICE",
"libSM",
"libxcb",
"xcb-util-cursor",
"xcb-util-wm",
"xcb-util-image",
"xcb-util-keysyms",
"libXext",
"libxkbcommon-x11",
"libXrender",
]
[tool.briefcase.app.${project_name_lowercase}.linux.system.suse]
system_requires = [
]
system_runtime_requires = [
# Derived from the Debian \`system_requires\` list
"libdbus-1-3",
"Mesa-libEGL1",
"libfontconfig1",
"Mesa-libGL1",
"glib2",
"libICE6",
"libSM6",
"libx11-xcb1",
"libxcb-cursor0",
"libxcb-icccm4",
"libxcb-image0",
"libxcb-keysyms1",
"libxcb-randr0",
"libxcb-shape0",
"libxcb-sync1",
"libxcb-xfixes0",
"libXext6",
"libxkbcommon-x11-0",
"libXrender1",
]
[tool.briefcase.app.${project_name_lowercase}.linux.system.arch]
system_requires = [
]
system_runtime_requires = [
# Derived from the Debian \`system_requires\` list
"dbus",
"libglvnd",
"fontconfig",
"glib2",
"libice",
"libsm",
"libx11",
"xcb-util-cursor",
"xcb-util-wm",
"xcb-util-image",
"xcb-util-keysyms",
"libxcb",
"libxext",
"libxkbcommon",
"libxrender",
]
[tool.briefcase.app.${project_name_lowercase}.linux.flatpak]
flatpak_runtime = "org.kde.Platform"
flatpak_runtime_version = "6.7"
flatpak_sdk = "org.kde.Sdk"
[tool.briefcase.app.${project_name_lowercase}.macOS]
universal_build = true
requires = [
"std-nslog~=1.0.3",
]
[tool.briefcase.app.${project_name_lowercase}.windows]
requires = [
]
EOF
artifacts:
paths:
- CHANGELOG
- pyproject.toml
- pymoldyn/icon-*.png
.package:debian:
stage: package
needs: ["pre-package"]
variables:
DEBIAN_FRONTEND: noninteractive
before_script:
- apt-get update
- apt-get install -y
build-essential
git
python3-dev
python3-pip
python3-venv
- if ! apt-get install -y pipx; then
python3 -m pip install pipx;
fi
- pipx install "briefcase==${BRIEFCASE_VERSION}"
- export PATH="${HOME}/.local/bin:${PATH}"
- python3 -m venv env
script:
# Install the project in editable mode to force to build all C extenions in-place. Otherwise, they won't be packaged
# by briefcase
- ./env/bin/python3 -m pip install -e .
- briefcase create linux system
- briefcase build linux system
- briefcase package linux system
artifacts:
paths:
- dist/*.deb
package:debian:11:
extends: .package:debian
image: debian:11
package:debian:12:
extends: .package:debian
image: debian:12
package:ubuntu:22.04:
extends: .package:debian
image: ubuntu:22.04
package:ubuntu:24.04:
extends: .package:debian
image: ubuntu:24.04
package:ubuntu:24.10:
extends: .package:debian
image: ubuntu:24.10
.package:rhel:
stage: package
needs: ["pre-package"]
before_script:
- dnf install -y
gcc
git
make
python3-devel
rpm-build
- python3 -m pip install pipx
- pipx install "briefcase==${BRIEFCASE_VERSION}"
- export PATH="${HOME}/.local/bin:${PATH}"
- python3 -m venv env
script:
# Install the project in editable mode to force to build all C extenions in-place. Otherwise, they won't be packaged
# by briefcase
- ./env/bin/python3 -m pip install -e .
- briefcase create linux system
- briefcase build linux system
- briefcase package linux system
artifacts:
paths:
- dist/*.rpm
package:rockylinux:9:
extends: .package:rhel
image: rockylinux:9
package:fedora:41:
extends: .package:rhel
image: fedora:41
package:opensuse:tumbleweed:
stage: package
image: opensuse/tumbleweed
before_script:
- zypper install -y
git
patterns-devel-base-devel_basis
python3-devel
python3-pipx
rpm-build
- pipx install "briefcase==${BRIEFCASE_VERSION}"
- export PATH="${HOME}/.local/bin:${PATH}"
- python3 -m venv env
script:
# Install the project in editable mode to force to build all C extenions in-place. Otherwise, they won't be packaged
# by briefcase
- ./env/bin/python3 -m pip install -e .
- briefcase create linux system
- briefcase build linux system
- briefcase package linux system
artifacts:
paths:
- dist/*.rpm
package:flatpack:
stage: package
image: debian:12-gcc
needs: ["pre-package"]
tags:
- libvirt
before_script:
- sudo apt-get update
- sudo apt-get install -y
build-essential
flatpak
flatpak-builder
git
pipx
python3-dev
python3-pip
python3-venv
- pipx install "briefcase==${BRIEFCASE_VERSION}"
- export PATH="${HOME}/.local/bin:${PATH}"
- python3 -m venv env
script:
# Install the project in editable mode to force to build all C extenions in-place. Otherwise, they won't be packaged
# by briefcase
- ./env/bin/python3 -m pip install -e .
- briefcase create linux flatpak
- briefcase build linux flatpak
- briefcase package linux flatpak
artifacts:
paths:
- dist/*.flatpak
package:macos:
stage: package
image: macos:sonoma-xcode
variables:
PYTHON_VERSION: "3.12.8"
needs: ["pre-package"]
tags:
- utm
before_script:
- curl -fLO "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macos11.pkg"
- sudo installer -pkg "python-${PYTHON_VERSION}-macos11.pkg" -target /
- python3 -m pip install -U
certifi
pipx
- export SSL_CERT_FILE="$(python3 -m certifi)"
- export PATH="${HOME}/.local/bin:/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION%.*}/bin:${PATH}"
- pipx install "briefcase==${BRIEFCASE_VERSION}"
- |
cat <<'EOF' >create_icns.py
#!/usr/bin/env -S pipx run
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "pillow",
# ]
# ///
import os
import subprocess
import sys
from tempfile import TemporaryDirectory
from PIL import Image
def create_iconset(icon_path, iconset_out_path):
with TemporaryDirectory() as tmp_dir:
tmp_icns_dir = os.path.join(tmp_dir, "icon.iconset")
os.mkdir(tmp_icns_dir)
original_icon = Image.open(icon_path)
for name, size in (
("icon_{size}x{size}{suffix}.png".format(size=size, suffix=suffix), factor * size)
for size in (16, 32, 128, 256, 512)
for factor, suffix in ((1, ""), (2, "@2x"))
):
resized_icon = original_icon.resize((size, size), Image.LANCZOS)
resized_icon.save(os.path.join(tmp_icns_dir, name))
subprocess.check_call(("iconutil", "--convert", "icns", tmp_icns_dir, "--output", iconset_out_path))
def main():
create_iconset(sys.argv[1], sys.argv[2])
if __name__ == "__main__":
main()
EOF
- chmod +x create_icns.py
- ./create_icns.py pymoldyn/icon.png pymoldyn/icon.icns
- GR_TEMPDIR="$(mktemp -d)"
- python3 -m venv env
- GR_STABLE_VERSION="$(
git ls-remote --tags "https://github.com/sciapp/gr" |
awk 'match($2, /refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+$/) { print substr($2, RSTART + length("refs/tags/v")) }' |
sort -ruV |
head -1
)"
- curl -fL "https://gr-framework.org/downloads/gr-${GR_STABLE_VERSION}-Darwin-universal.tar.gz" |
tar -C "${GR_TEMPDIR}" -xzf -
- export GRLIB="${GR_TEMPDIR}/gr/lib"
script:
# Install the project in editable mode to force to build all C extenions in-place. Otherwise, they won't be packaged
# by briefcase
- ./env/bin/python3 -m pip install -e .
- briefcase create
# Force to use the universal GR binaries for x86_64 and arm64
- rsync -a "${GR_TEMPDIR}/gr/" --exclude "Applications"
build/pymoldyn/macos/app/Pymoldyn.app/Contents/Resources/app_packages/gr/
- briefcase build
- briefcase package --adhoc-sign
artifacts:
paths:
- dist/*.dmg
package:windows:
stage: package
image: windows:10-python3
needs: ["pre-package"]
tags:
- libvirt
variables:
IMAGE_MAGICK_VERSION: "7.1.1-43"
before_script:
- vcvars_cmd python -m pip install briefcase
- curl -fLO "https://imagemagick.org/archive/binaries/ImageMagick-${IMAGE_MAGICK_VERSION}-portable-Q8-x64.zip"
- unzip "ImageMagick-${IMAGE_MAGICK_VERSION}-portable-Q8-x64.zip"
- ./ImageMagick-${IMAGE_MAGICK_VERSION}-portable-Q8-x64/magick
pymoldyn/icon.png
-define "icon:auto-resize=16,32,48,64,128,256"
pymoldyn/icon.ico
- vcvars_cmd python -m venv env
script:
# Install the project in editable mode to force to build all C extenions in-place. Otherwise, they won't be packaged
# by briefcase
- ./env/Scripts/python -m pip install -e .
- vcvars_cmd python -m briefcase create
- vcvars_cmd python -m briefcase build
- vcvars_cmd python -m briefcase package --adhoc-sign
artifacts:
paths:
- dist/*.msi
deploy-to-github:
stage: deploy
image: python:3-slim
variables:
GIT_STRATEGY: none
only:
- master@Scientific-IT-Systems/pyMolDyn
- develop@Scientific-IT-Systems/pyMolDyn
- tags@Scientific-IT-Systems/pyMolDyn
before_script:
- apt-get update
- apt-get install -y file git
- mkdir --mode=700 ~/.ssh/
- (umask 0377 && echo "${GITHUB_DEPLOY_KEY}" > ~/.ssh/id_rsa
&& echo "github.com ${GITHUB_HOST_KEY}" >> ~/.ssh/known_hosts)
script:
- git clone --mirror "${CI_REPOSITORY_URL}" "${CI_PROJECT_NAME}_mirror"
- cd "${CI_PROJECT_NAME}_mirror";
git push --mirror "git@github.com:sciapp/${CI_PROJECT_NAME}.git";
cd ..
- if echo "${CI_COMMIT_TAG}" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
pip install github-binary-upload;
echo "${GITHUB_ACCESS_TOKEN}" |
github-binary-upload --user IngoMeyer441 "sciapp/${CI_PROJECT_NAME}" "${CI_COMMIT_TAG}" dist/*;
fi
deploy-to-pypi:
stage: deploy
image: python:3-slim
only:
- tags@Scientific-IT-Systems/pyMolDyn
before_script:
- pip install twine
- echo "[distutils]" > ~/.pypirc;
echo "index-servers =" >> ~/.pypirc;
echo " pypi" >> ~/.pypirc;
echo "[pypi]" >> ~/.pypirc;
echo "username = __token__" >> ~/.pypirc;
echo "password = ${PYPI_DEPLOY_KEY}" >> ~/.pypirc;
script:
- twine upload dist/*.tar.gz dist/*.whl
deploy-to-aur:
stage: deploy
needs:
- deploy-to-github
image: archlinux:base-devel
only:
- tags@Scientific-IT-Systems/pyMolDyn
before_script:
- pacman -Syu --noconfirm
- pacman -S --noconfirm --needed git openssh
- useradd -m deploy
- sudo -u deploy bash -c "
git config --global user.name \"AUR updater\" &&
git config --global user.email \"aur@updater.org\" &&
mkdir --mode=700 ~/.ssh/ &&
(
umask 0377 &&
echo \"$AUR_PRIVATE_KEY\" > ~/.ssh/id_rsa &&
echo \"aur.archlinux.org $AUR_HOST_KEY\" >> ~/.ssh/known_hosts
)
"
script:
- sudo -u deploy bash -c "
git clone \"ssh://aur@aur.archlinux.org/${CI_PROJECT_NAME,,}.git\" \"${CI_PROJECT_NAME}-aur\" &&
cd \"${CI_PROJECT_NAME}-aur\" &&
sed
-i
-e \"/^pkgver=/c\pkgver=\\\"${CI_COMMIT_TAG#v}\\\"\"
-e \"/^pkgrel=/c\pkgrel=\\\"1\\\"\"
PKGBUILD &&
(
source PKGBUILD;
curl -o source -L \"\${source[0]}\";
SHA256SUM=\"\$(sha256sum source | awk '{ print \$1 }')\";
sed -i \"/^sha256sums=/c\sha256sums=(\\\"\${SHA256SUM}\\\")\" PKGBUILD;
) &&
makepkg --printsrcinfo > .SRCINFO &&
git commit -a -m \"Update to version ${CI_COMMIT_TAG#v}\" &&
git push
"