-
-
Notifications
You must be signed in to change notification settings - Fork 218
291 lines (237 loc) · 9.67 KB
/
publish.yml
File metadata and controls
291 lines (237 loc) · 9.67 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
name: Publish Packages
on:
push:
tags:
- 'v*'
jobs:
publish-npm:
name: Publish NPM Packages
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
# Detect force release (skip tests)
# We strip the 'f' suffix for the actual version
if [[ "$VERSION" == *f ]]; then
echo "skip_tests=true" >> $GITHUB_OUTPUT
echo "Force release detected (tag ends in 'f') - skipping tests"
VERSION=${VERSION%f}
else
echo "skip_tests=false" >> $GITHUB_OUTPUT
echo "Normal release - running tests"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Final publish version: $VERSION"
# Detect if this is a pre-release (beta, alpha, rc)
if [[ "$VERSION" =~ (alpha|beta|rc|a|b) ]]; then
echo "npm_tag=beta" >> $GITHUB_OUTPUT
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "Pre-release detected - will publish with 'beta' tag"
else
echo "npm_tag=latest" >> $GITHUB_OUTPUT
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "Stable release - will publish with 'latest' tag"
fi
- name: Update package versions
run: node scripts/update-versions.js ${{ steps.get_version.outputs.version }}
- name: Install dependencies
run: npm install
- name: Fetch OpenAPI Specs
run: npm run fetch:openapi --workspace=pmxt-core
- name: Regenerate OpenAPI spec
run: npm run generate:openapi --workspace=pmxt-core
- name: Generate SDKs
run: npm run generate:sdk:all --workspace=pmxt-core
- name: Build Core
run: npm run build --workspace=pmxt-core
- name: Generate Mintlify docs
run: npm run generate:mintlify --workspace=pmxt-core
- name: Generate llms.txt
run: npm run docs:llms
- name: Commit updated docs
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/docs.json docs/api-reference/openapi.json docs/concepts/venues.mdx docs/llms.txt docs/llms-full.txt
if ! git diff --cached --quiet; then
git stash --include-untracked
git pull --rebase origin main
git stash pop
git add docs/docs.json docs/api-reference/openapi.json docs/concepts/venues.mdx docs/llms.txt docs/llms-full.txt
git commit -m "docs: auto-update for v${{ steps.get_version.outputs.version }}"
git push origin HEAD:main
fi
- name: Bundle Sidecar Server
run: npm run bundle:server --workspace=pmxt-core
- name: Start PMXT Server
run: |
npm run server --workspace=pmxt-core &
timeout 30 bash -c 'until curl -s http://localhost:3847/health > /dev/null; do sleep 1; done'
- name: Run Tests (All Workspaces)
if: steps.get_version.outputs.skip_tests != 'true'
run: npm test --workspaces
- name: Build (All Workspaces)
run: npm run build --workspaces
- name: Publish npm packages
shell: bash
run: |
set -euo pipefail
publish_workspace() {
local workspace="$1"
local package_name="$2"
local log_file
log_file="$(mktemp)"
echo "Publishing ${package_name}@${VERSION} from ${workspace}"
if npm publish --workspace="${workspace}" --provenance --access public --tag "${NPM_TAG}" 2>&1 | tee "${log_file}"; then
return 0
fi
if npm view "${package_name}@${VERSION}" version --silent >/dev/null 2>&1; then
echo "${package_name}@${VERSION} is already published; continuing."
return 0
fi
if grep -Eq 'IDENTITY_TOKEN_READ_ERROR|TLOG_CREATE_ENTRY_ERROR|provenance|transparency log' "${log_file}"; then
echo "Provenance publish failed for ${package_name}; retrying without provenance."
npm publish --workspace="${workspace}" --access public --tag "${NPM_TAG}"
return 0
fi
cat "${log_file}"
return 1
}
publish_workspace "pmxt-core" "pmxt-core"
publish_workspace "pmxtjs" "pmxtjs"
publish_workspace "@pmxt/cli" "@pmxt/cli"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TAG: ${{ steps.get_version.outputs.npm_tag }}
VERSION: ${{ steps.get_version.outputs.version }}
publish-python:
name: Publish pmxt (Python)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Detect force release (skip tests)
# We strip the 'f' suffix for the actual version
if [[ "$VERSION" == *f ]]; then
echo "skip_tests=true" >> $GITHUB_OUTPUT
echo "Force release detected (tag ends in 'f') - skipping tests"
VERSION=${VERSION%f}
else
echo "skip_tests=false" >> $GITHUB_OUTPUT
echo "Normal release - running tests"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Update package versions
run: node scripts/update-versions.js ${{ steps.get_version.outputs.version }}
- name: Install and Fetch OpenAPI Specs
run: |
npm install
npm run fetch:openapi --workspace=pmxt-core
- name: Generate SDKs
run: npm run generate:sdk:all --workspace=pmxt-core
- name: Install build tools & dependencies
run: pip install build twine pytest .
working-directory: sdks/python
- name: Run tests
if: steps.get_version.outputs.skip_tests != 'true'
run: |
npm run build --workspace=pmxt-core
npm run server --workspace=pmxt-core &
timeout 30 bash -c 'until curl -s http://localhost:3847/health > /dev/null; do sleep 1; done'
pytest
working-directory: sdks/python
- name: Bundle Server for Python
run: |
npm run bundle:server --workspace=pmxt-core
python sdks/python/bundle_server.py
- name: Build package
run: python -m build
working-directory: sdks/python
- name: Publish to PyPI
run: twine upload dist/*
working-directory: sdks/python
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [publish-npm, publish-python]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Strip 'f' suffix if present (force release)
if [[ "$VERSION" == *f ]]; then
VERSION=${VERSION%f}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Release version: $VERSION"
# Detect if this is a pre-release (beta, alpha, rc)
if [[ "$VERSION" =~ (alpha|beta|rc|a|b) ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "Pre-release detected"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "Stable release"
fi
- name: Extract Release Notes from Changelog
id: extract_notes
uses: ffurrer2/extract-release-notes@v2
with:
changelog_file: changelog.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: "v${{ steps.get_version.outputs.version }}"
body: |
${{ steps.extract_notes.outputs.release_notes }}
---
## Installation
**npm:**
```bash
npm install pmxtjs@${{ steps.get_version.outputs.version }}
npm install -g @pmxt/cli@${{ steps.get_version.outputs.version }}
```
**PyPI:**
```bash
pip install pmxt==${{ steps.get_version.outputs.version }}
```
## Links
- [npm: pmxtjs](https://www.npmjs.com/package/pmxtjs/v/${{ steps.get_version.outputs.version }})
- [npm: @pmxt/cli](https://www.npmjs.com/package/@pmxt/cli/v/${{ steps.get_version.outputs.version }})
- [npm: pmxt-core](https://www.npmjs.com/package/pmxt-core/v/${{ steps.get_version.outputs.version }})
- [PyPI: pmxt](https://pypi.org/project/pmxt/${{ steps.get_version.outputs.version }}/)
prerelease: ${{ steps.get_version.outputs.is_prerelease }}
generate_release_notes: true
make_latest: ${{ steps.get_version.outputs.is_prerelease == 'false' }}