-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (159 loc) · 5.18 KB
/
release.yml
File metadata and controls
191 lines (159 loc) · 5.18 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
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
name: Release tarballs
# Trigger on tags ``vX.Y.Z`` and on manual dispatch (for re-runs).
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
jobs:
verify:
name: Verify versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check tag matches package.json and SDK versions
run: |
APP_VERSION=$(node -p "require('./package.json').version")
SDK_VERSION=$(node -p "require('./packages/sdk/package.json').version")
echo "app=$APP_VERSION sdk=$SDK_VERSION"
if [ "$APP_VERSION" != "$SDK_VERSION" ]; then
echo "::error::package.json ($APP_VERSION) and packages/sdk/package.json ($SDK_VERSION) versions disagree."
exit 1
fi
# On a tag push, additionally enforce that the tag matches the
# package version. Skipped on workflow_dispatch (manual re-run).
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "$APP_VERSION" != "$TAG_VERSION" ]; then
echo "::error::tag ${GITHUB_REF_NAME} does not match package.json version ${APP_VERSION}."
exit 1
fi
echo "Tag ${GITHUB_REF_NAME} matches package version ${APP_VERSION}."
fi
python-tests:
name: Python ${{ matrix.python-version }} (pytest)
runs-on: ubuntu-latest
needs: verify
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements-dev.txt
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run pytest
run: python -m pytest tests/python
e2e:
name: End-to-end (Playwright)
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install npm dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
run: npm run test:e2e
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 14
pack:
name: Build & pack (app + SDK)
runs-on: ubuntu-latest
needs: [verify, python-tests, e2e]
outputs:
app-version: ${{ steps.versions.outputs.app }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Read app version
id: versions
run: echo "app=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
- name: Lint
run: npm run lint
- name: Unit tests (Vitest)
run: npm run test
- name: Build app bundle
run: npm run build
- name: Pack SDK tarball
run: npm run sdk:pack
- name: Pack app tarball
run: npm run app:pack
- name: List release artefacts
run: ls -lh release/
- name: Upload tarballs as workflow artefacts
uses: actions/upload-artifact@v4
with:
name: datalab-web-release
path: release/*.tgz
if-no-files-found: error
retention-days: 30
- name: Upload built bundle for Pages deploy
uses: actions/upload-artifact@v4
with:
name: datalab-web-dist
path: dist/
if-no-files-found: error
retention-days: 7
- name: Extract release notes from CHANGELOG
if: startsWith(github.ref, 'refs/tags/v')
run: node scripts/extract-changelog.mjs "$GITHUB_REF_NAME" -o release-notes.md
- name: Attach tarballs to GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: release/*.tgz
fail_on_unmatched_files: true
body_path: release-notes.md
generate_release_notes: true
deploy-pages:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: pack
# Only deploy on actual tag pushes; skip on workflow_dispatch re-runs.
if: startsWith(github.ref, 'refs/tags/v')
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
concurrency:
group: pages
cancel-in-progress: false
steps:
- name: Download built bundle
uses: actions/download-artifact@v4
with:
name: datalab-web-dist
path: dist
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: dist
- id: deployment
uses: actions/deploy-pages@v4