Repository navigation
190 lines (159 loc) · 6.11 KB
/
Copy pathpublish.yml
File metadata and controls
190 lines (159 loc) · 6.11 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
name: Publish to PyPI
on:
push:
# Match release tags like v0.26.0 but NOT the extension's vscode-v* tags
# (which also start with "v"). Requiring a digit right after the "v" keeps
# the two tag namespaces from triggering each other.
tags: ['v[0-9]*']
permissions:
contents: write # needed for creating GitHub releases
jobs:
# ---------------------------------------------------------------------------
# Build the Next.js frontend as a standalone tarball
# ---------------------------------------------------------------------------
build-web:
name: Build Web UI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: "20"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci --workspace packages/web
- name: Build Next.js (standalone)
run: npm run build --workspace packages/web
env:
NEXT_PUBLIC_REPOWISE_API_URL: ""
- name: Package standalone output
run: |
STANDALONE=packages/web/.next/standalone
# Copy static assets into standalone (Next.js requirement)
cp -r packages/web/.next/static $STANDALONE/packages/web/.next/static
[ -d packages/web/public ] && cp -r packages/web/public $STANDALONE/packages/web/public || true
# Flatten: move the nested server into a clean directory
mkdir -p /tmp/repowise-web
cp $STANDALONE/packages/web/server.js /tmp/repowise-web/
cp -r $STANDALONE/packages/web/.next /tmp/repowise-web/.next
[ -d $STANDALONE/packages/web/public ] && cp -r $STANDALONE/packages/web/public /tmp/repowise-web/public || true
cp -r $STANDALONE/node_modules /tmp/repowise-web/node_modules 2>/dev/null || true
[ -d $STANDALONE/packages/web/node_modules ] && cp -r $STANDALONE/packages/web/node_modules/* /tmp/repowise-web/node_modules/ 2>/dev/null || true
# Create tarball
cd /tmp/repowise-web && tar -czf /tmp/repowise-web.tar.gz .
- name: Upload web artifact
uses: actions/upload-artifact@v7
with:
name: repowise-web
path: /tmp/repowise-web.tar.gz
# ---------------------------------------------------------------------------
# Build the Python package
# ---------------------------------------------------------------------------
build-python:
name: Build Python package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install build tools
run: pip install build
- name: Build sdist and wheel
run: python -m build
- name: Upload dist artifacts
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
# ---------------------------------------------------------------------------
# Export the server's OpenAPI document, labelled stable or internal per route
# ---------------------------------------------------------------------------
build-openapi:
name: Export OpenAPI document
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v10.3.3
# A release build installs from scratch rather than restore a cache.
with:
version: "latest"
enable-cache: false
- name: Install dependencies
run: uv sync --all-packages
- name: Export openapi.json
run: uv run python scripts/export_openapi.py --out openapi.json
- name: Upload OpenAPI artifact
uses: actions/upload-artifact@v7
with:
name: openapi
path: openapi.json
# ---------------------------------------------------------------------------
# Create GitHub release with web UI tarball
# ---------------------------------------------------------------------------
release:
name: Create GitHub Release
needs: [build-web, build-python]
runs-on: ubuntu-latest
steps:
- name: Download web artifact
uses: actions/download-artifact@v8
with:
name: repowise-web
path: ./artifacts/
- name: Download Python dist
uses: actions/download-artifact@v8
with:
name: dist
path: ./dist/
- name: Create release
uses: softprops/action-gh-release@v3
with:
files: |
artifacts/repowise-web.tar.gz
dist/*
generate_release_notes: true
# ---------------------------------------------------------------------------
# Attach openapi.json after the release exists, so a failed export never
# holds back the web tarball that `repowise serve` downloads
# ---------------------------------------------------------------------------
attach-openapi:
name: Attach OpenAPI document
needs: [release, build-openapi]
runs-on: ubuntu-latest
steps:
- name: Download OpenAPI document
uses: actions/download-artifact@v8
with:
name: openapi
path: ./openapi/
- name: Attach to release
uses: softprops/action-gh-release@v3
with:
files: openapi/openapi.json
# ---------------------------------------------------------------------------
# Publish to PyPI
# ---------------------------------------------------------------------------
publish:
name: Publish to PyPI
# Gate PyPI publish on BOTH builds so a web-build failure can never leave a
# half-shipped release (wheel on PyPI but no GitHub release / web tarball).
needs: [build-web, build-python]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # trusted publishing (OIDC)
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true