-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (165 loc) · 5.14 KB
/
release.yml
File metadata and controls
200 lines (165 loc) · 5.14 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
192
193
194
195
196
197
198
199
200
name: Release
on:
workflow_dispatch:
inputs:
repository:
description: Package index to publish to
required: true
default: testpypi
type: choice
options:
- testpypi
- pypi
version:
description: Optional version to validate against package metadata (for example 0.1.0a1)
required: false
type: string
permissions:
contents: read
jobs:
unit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.13"]
django-version: ["4.2.*", "5.1.*"]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "Django==${{ matrix.django-version }}" -e .[dev]
- name: Ruff
run: ruff check .
- name: Pytest
run: pytest
example-e2e:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
cache-dependency-path: example/package-lock.json
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
- name: Install example dependencies
working-directory: example
run: npm ci
- name: Install Playwright browser
working-directory: example
run: npx playwright install --with-deps chromium
- name: Make example scripts executable
run: chmod +x example/bin/dev example/bin/prod example/bin/test-ci
- name: Run example smoke and Playwright suite
working-directory: example
run: ./bin/test-ci
build:
needs:
- unit
- example-e2e
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- id: version
name: Read package version
shell: bash
run: |
version="$(
python - <<'PY'
from pathlib import Path
import re
text = Path("src/react_on_django/__about__.py").read_text()
match = re.search(r'^__version__ = "([^"]+)"$', text, re.M)
if not match:
raise SystemExit("Could not find __version__ in src/react_on_django/__about__.py")
print(match.group(1))
PY
)"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Validate release version
shell: bash
env:
PACKAGE_VERSION: ${{ steps.version.outputs.version }}
INPUT_VERSION: ${{ inputs.version }}
run: |
expected_tag="v${PACKAGE_VERSION}"
if [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF_NAME}" != "${expected_tag}" ]]; then
echo "Tag ${GITHUB_REF_NAME} does not match package version ${PACKAGE_VERSION}."
exit 1
fi
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && -n "${INPUT_VERSION}" && "${INPUT_VERSION}" != "${PACKAGE_VERSION}" ]]; then
echo "Requested version ${INPUT_VERSION} does not match package version ${PACKAGE_VERSION}."
exit 1
fi
- name: Install build tooling
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distributions
run: python -m build
- name: Check distribution metadata
run: twine check dist/*
- name: Store distributions
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-testpypi:
if: inputs.repository == 'testpypi'
needs: build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/react-on-django
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish-pypi:
if: inputs.repository == 'pypi'
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/react-on-django
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1