Repository navigation
209 lines (178 loc) · 5.76 KB
/
Copy pathpublish.yml
File metadata and controls
209 lines (178 loc) · 5.76 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
201
202
203
204
205
206
207
208
209
name: Release and publish to PyPI
on:
push:
tags:
- "v*"
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
build:
name: Build and verify distribution
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install Python
run: uv python install 3.12
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- name: Verify release tag matches package version
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
PACKAGE_VERSION="$(uv run --no-project python -c \
'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
test "${RELEASE_TAG#v}" = "$PACKAGE_VERSION" || {
echo "Release tag $RELEASE_TAG does not match package version $PACKAGE_VERSION"
exit 1
}
- name: Install locked dependencies
run: |
uv sync --frozen --all-groups
pnpm install --frozen-lockfile
- name: Verify runtime version
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
uv run python - <<'PY'
import os
import windcode
expected = os.environ["RELEASE_TAG"].removeprefix("v")
if windcode.__version__ != expected:
raise SystemExit(
f"windcode.__version__={windcode.__version__} does not match {expected}"
)
PY
- name: Run quality checks
run: |
uv run ruff format --check .
uv run ruff check .
uv run pyright
pnpm web:test
pnpm web:build
git diff --exit-code -- src/windcode/web/static
- name: Build distributions
run: uv build --no-sources
- name: Verify distribution contents
run: |
uv run --with twine twine check dist/*
uv run --no-project python - <<'PY'
from pathlib import Path
import zipfile
wheel = next(Path("dist").glob("*.whl"))
with zipfile.ZipFile(wheel) as archive:
names = archive.namelist()
required = (
"windcode/__init__.py",
"windcode/tui/styles.tcss",
"windcode/web/static/index.html",
"windcode/web/static/assets/app.js",
"windcode/web/static/assets/app.css",
)
missing = [item for item in required if not any(name.endswith(item) for name in names)]
if missing:
raise SystemExit(f"Wheel is missing required files: {', '.join(missing)}")
PY
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: python-distributions
path: dist/
if-no-files-found: error
release:
name: Create GitHub release
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create or update GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release edit "$RELEASE_TAG" --title "$RELEASE_TAG"
else
gh release create "$RELEASE_TAG" --title "$RELEASE_TAG" --generate-notes
fi
publish:
name: Publish distribution
needs: [build, release]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/windcode/
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
attestations: false
publish-npm:
name: Publish npm CLI wrapper
needs: [publish]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: pnpm
- name: Install locked dependencies
run: pnpm install --frozen-lockfile
- name: Verify release versions
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
NPM_VERSION="$(node -p 'require("./package.json").version')"
PYTHON_VERSION="$(sed -n 's/^version = "\([^"]*\)"/\1/p' pyproject.toml | head -n 1)"
TAG_VERSION="${RELEASE_TAG#v}"
test "$RELEASE_TAG" = "v$TAG_VERSION" \
&& test -n "$TAG_VERSION" \
&& test "$TAG_VERSION" = "$NPM_VERSION" \
&& test "$TAG_VERSION" = "$PYTHON_VERSION" || {
echo "Version mismatch: tag=$TAG_VERSION npm=$NPM_VERSION python=$PYTHON_VERSION"
exit 1
}
- name: Test CLI wrapper
run: pnpm test
- name: Verify package contents
run: pnpm run pack:check
- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: "true"
run: pnpm publish --access public --no-git-checks