-
Notifications
You must be signed in to change notification settings - Fork 32
106 lines (90 loc) · 2.93 KB
/
Copy pathwidget-release.yml
File metadata and controls
106 lines (90 loc) · 2.93 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
name: Widget release
on:
push:
tags:
- "widget-v*"
permissions:
contents: read
id-token: write
concurrency:
group: widget-release-${{ github.ref }}
cancel-in-progress: false
jobs:
testpypi:
name: Build and publish quantem.widget
runs-on: ubuntu-latest
environment: testpypi
defaults:
run:
shell: bash -el {0}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v4
with:
activate-environment: quantem-widget-release
environment-file: widget/environment.yml
auto-update-conda: true
channel-priority: strict
conda-remove-defaults: true
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: "22.x"
check-latest: true
cache: npm
cache-dependency-path: widget/package-lock.json
- name: Resolve widget version from tag
id: version
run: |
python - <<'PY'
import os
import re
tag = os.environ["GITHUB_REF_NAME"]
match = re.fullmatch(r"widget-v(?P<version>\d+\.\d+\.\d+(?:rc\d+|\.post\d+)?)", tag)
if match is None:
raise SystemExit(
f"Expected tag widget-vX.Y.Z, widget-vX.Y.ZrcN, or widget-vX.Y.Z.postN; got {tag!r}"
)
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
print(f"version={match.group('version')}", file=output)
PY
- name: Build frontend assets
working-directory: widget
run: |
npm ci
npm run typecheck
npm run build
test -s src/quantem/widget/static/show2d.js
test -s src/quantem/widget/static/show4dstem.js
- name: Stamp widget package version
env:
WIDGET_VERSION: ${{ steps.version.outputs.version }}
run: |
python - <<'PY'
import os
import pathlib
import re
path = pathlib.Path("widget/pyproject.toml")
text = path.read_text(encoding="utf-8")
version = os.environ["WIDGET_VERSION"]
updated, count = re.subn(
r'(?m)^version = "[^"]+"$',
f'version = "{version}"',
text,
count=1,
)
if count != 1:
raise SystemExit("Expected exactly one project.version field")
path.write_text(updated, encoding="utf-8")
PY
- name: Build widget distributions
run: python -m build widget --no-isolation --outdir dist/widget
- name: Check widget distributions
run: python -m twine check dist/widget/*
- name: Publish widget to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/widget/