-
Notifications
You must be signed in to change notification settings - Fork 34
286 lines (244 loc) · 10.3 KB
/
release.yml
File metadata and controls
286 lines (244 loc) · 10.3 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
# Multi-Repo Release Workflow
# Generates SDKs and pushes to separate SDK repositories
# SDK repos auto-publish when they detect a version change
#
# Required Secrets:
# - SDK_DEPLOY_KEY_PYTHON: SSH deploy key for xdk-python repo
# - SDK_DEPLOY_KEY_TYPESCRIPT: SSH deploy key for xdk-typescript repo
name: Release SDK
on:
workflow_dispatch:
inputs:
sdk:
description: 'SDK to release'
required: true
type: choice
options:
- python
- typescript
- all
bump:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
- beta
dry_run:
description: 'Dry run (generate and test, but do not push)'
type: boolean
default: false
skip_publish:
description: 'Push to SDK repos but skip publishing (no version bump)'
type: boolean
default: false
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
# ============================================
# Prepare: Bump version and commit
# ============================================
prepare:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
python_version: ${{ steps.versions.outputs.python }}
typescript_version: ${{ steps.versions.outputs.typescript }}
release_python: ${{ steps.matrix.outputs.python }}
release_typescript: ${{ steps.matrix.outputs.typescript }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.XDK_PAT }}
- name: Bump version
if: ${{ !inputs.skip_publish }}
run: |
chmod +x ./scripts/version.sh
./scripts/version.sh ${{ inputs.sdk }} ${{ inputs.bump }}
- name: Read versions
id: versions
run: |
echo "python=$(grep '^python = ' xdk-config.toml | sed 's/.*= "\(.*\)"/\1/')" >> $GITHUB_OUTPUT
echo "typescript=$(grep '^typescript = ' xdk-config.toml | sed 's/.*= "\(.*\)"/\1/')" >> $GITHUB_OUTPUT
- name: Determine which SDKs to release
id: matrix
run: |
if [ "${{ inputs.sdk }}" = "all" ] || [ "${{ inputs.sdk }}" = "python" ]; then
echo "python=true" >> $GITHUB_OUTPUT
else
echo "python=false" >> $GITHUB_OUTPUT
fi
if [ "${{ inputs.sdk }}" = "all" ] || [ "${{ inputs.sdk }}" = "typescript" ]; then
echo "typescript=true" >> $GITHUB_OUTPUT
else
echo "typescript=false" >> $GITHUB_OUTPUT
fi
- name: Commit version bump
if: ${{ !inputs.dry_run && !inputs.skip_publish }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add xdk-config.toml
if [ "${{ inputs.sdk }}" = "all" ]; then
git commit -m "chore: bump SDK versions - Python v${{ steps.versions.outputs.python }}, TypeScript v${{ steps.versions.outputs.typescript }}"
elif [ "${{ inputs.sdk }}" = "python" ]; then
git commit -m "chore: bump Python SDK to v${{ steps.versions.outputs.python }}"
else
git commit -m "chore: bump TypeScript SDK to v${{ steps.versions.outputs.typescript }}"
fi
git push
- name: Release Summary
run: |
echo "## 📦 Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Setting | Value |" >> $GITHUB_STEP_SUMMARY
echo "|---------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| SDK | ${{ inputs.sdk }} |" >> $GITHUB_STEP_SUMMARY
echo "| Bump | ${{ inputs.bump }} |" >> $GITHUB_STEP_SUMMARY
echo "| Dry Run | ${{ inputs.dry_run }} |" >> $GITHUB_STEP_SUMMARY
echo "| Skip Publish | ${{ inputs.skip_publish }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Versions" >> $GITHUB_STEP_SUMMARY
echo "- Python: \`${{ steps.versions.outputs.python }}\`" >> $GITHUB_STEP_SUMMARY
echo "- TypeScript: \`${{ steps.versions.outputs.typescript }}\`" >> $GITHUB_STEP_SUMMARY
# ============================================
# Release Python SDK
# ============================================
release-python:
name: Release Python SDK
needs: prepare
if: needs.prepare.outputs.release_python == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.dry_run && github.ref || 'main' }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Generate Python SDK
run: cargo run -- python --latest true
- name: Run tests
run: |
cd xdk/python
uv sync
uv run pytest tests/ -v
- name: Prepare SDK for push
run: |
cd xdk/python
rm -rf .venv __pycache__ .pytest_cache *.egg-info dist/
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
- name: Push to SDK repository
if: ${{ !inputs.dry_run }}
env:
SSH_DEPLOY_KEY: ${{ secrets.SDK_DEPLOY_KEY_PYTHON }}
run: |
# Setup SSH
mkdir -p ~/.ssh
echo "$SSH_DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan github.com >> ~/.ssh/known_hosts
# Clone SDK repo
GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key" git clone git@github.com:xdevplatform/xdk-python.git /tmp/sdk-repo
# Preserve .github folder
cp -r /tmp/sdk-repo/.github xdk/python/.github 2>/dev/null || true
# Copy generated files to SDK repo (preserve .git)
rm -rf /tmp/sdk-repo/*
cp -r xdk/python/* /tmp/sdk-repo/
cp -r xdk/python/.* /tmp/sdk-repo/ 2>/dev/null || true
# Commit and push
cd /tmp/sdk-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: update SDK to v${{ needs.prepare.outputs.python_version }}" || echo "No changes"
GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key" git push
- name: Summary
run: |
if [ "${{ inputs.dry_run }}" = "true" ]; then
echo "## 🧪 Python SDK Dry Run" >> $GITHUB_STEP_SUMMARY
echo "Would push v${{ needs.prepare.outputs.python_version }} to xdk-python" >> $GITHUB_STEP_SUMMARY
else
echo "## ✅ Python SDK Released" >> $GITHUB_STEP_SUMMARY
echo "Pushed v${{ needs.prepare.outputs.python_version }} to [xdk-python](https://github.com/xdevplatform/xdk-python)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "SDK repo will auto-publish to PyPI" >> $GITHUB_STEP_SUMMARY
fi
# ============================================
# Release TypeScript SDK
# ============================================
release-typescript:
name: Release TypeScript SDK
needs: prepare
if: needs.prepare.outputs.release_typescript == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.dry_run && github.ref || 'main' }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Generate TypeScript SDK
run: cargo run -- typescript --latest true
- name: Install dependencies
run: cd xdk/typescript && npm ci
- name: Build
run: cd xdk/typescript && npm run build
- name: Type check
run: cd xdk/typescript && npm run type-check
- name: Run tests
run: cd xdk/typescript && npm test
- name: Prepare SDK for push
run: |
cd xdk/typescript
rm -rf node_modules
- name: Push to SDK repository
if: ${{ !inputs.dry_run }}
env:
SSH_DEPLOY_KEY: ${{ secrets.SDK_DEPLOY_KEY_TYPESCRIPT }}
run: |
# Setup SSH
mkdir -p ~/.ssh
echo "$SSH_DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan github.com >> ~/.ssh/known_hosts
# Clone SDK repo
GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key" git clone git@github.com:xdevplatform/xdk-typescript.git /tmp/sdk-repo
# Preserve .github folder
cp -r /tmp/sdk-repo/.github xdk/typescript/.github 2>/dev/null || true
# Copy generated files to SDK repo (preserve .git)
rm -rf /tmp/sdk-repo/*
cp -r xdk/typescript/* /tmp/sdk-repo/
cp -r xdk/typescript/.* /tmp/sdk-repo/ 2>/dev/null || true
# Commit and push
cd /tmp/sdk-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: update SDK to v${{ needs.prepare.outputs.typescript_version }}" || echo "No changes"
GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key" git push
- name: Summary
run: |
if [ "${{ inputs.dry_run }}" = "true" ]; then
echo "## 🧪 TypeScript SDK Dry Run" >> $GITHUB_STEP_SUMMARY
echo "Would push v${{ needs.prepare.outputs.typescript_version }} to xdk-typescript" >> $GITHUB_STEP_SUMMARY
else
echo "## ✅ TypeScript SDK Released" >> $GITHUB_STEP_SUMMARY
echo "Pushed v${{ needs.prepare.outputs.typescript_version }} to [xdk-typescript](https://github.com/xdevplatform/xdk-typescript)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "SDK repo will auto-publish to npm" >> $GITHUB_STEP_SUMMARY
fi