-
Notifications
You must be signed in to change notification settings - Fork 131
336 lines (292 loc) · 11.9 KB
/
release.yml
File metadata and controls
336 lines (292 loc) · 11.9 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
name: Release
on:
workflow_dispatch:
inputs:
npm_tag:
description: 'npm tag for publish'
required: true
default: 'latest'
type: choice
options:
- latest
- alpha
version:
description: 'Override version (leave empty to auto-compute). Use when retrying a failed publish.'
required: false
default: ''
type: string
permissions: {}
env:
RELEASE_BUILD: 'true'
DEBUG: 'napi:*'
NPM_TAG: ${{ inputs.npm_tag }}
jobs:
prepare:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/set-snapshot-version
if: ${{ inputs.version == '' }}
id: computed
with:
npm_tag: ${{ inputs.npm_tag }}
- name: Set final version
id: version
run: echo "version=${{ inputs.version || steps.computed.outputs.version }}" >> $GITHUB_OUTPUT
build-rust:
runs-on: ${{ matrix.settings.os }}
needs: prepare
permissions:
contents: read
env:
VERSION: ${{ needs.prepare.outputs.version }}
strategy:
fail-fast: false
matrix:
settings:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: aarch64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/clone
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.2
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: release
- name: Rustup Adds Target
run: rustup target add ${{ matrix.settings.target }}
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
- name: Set binding version
shell: bash
run: |
pnpm exec tool replace-file-content packages/cli/binding/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"'
pnpm exec tool replace-file-content crates/vite_global_cli/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"'
cat crates/vite_global_cli/Cargo.toml
- name: Verify version replacement
shell: bash
run: |
if grep -q 'version = "0.0.0"' crates/vite_global_cli/Cargo.toml; then
echo "ERROR: Version replacement failed for crates/vite_global_cli/Cargo.toml"
head -5 crates/vite_global_cli/Cargo.toml
exit 1
fi
if grep -q 'version = "0.0.0"' packages/cli/binding/Cargo.toml; then
echo "ERROR: Version replacement failed for packages/cli/binding/Cargo.toml"
head -5 packages/cli/binding/Cargo.toml
exit 1
fi
echo "Version replacement verified successfully"
- name: Build
uses: ./.github/actions/build-upstream
with:
target: ${{ matrix.settings.target }}
- name: Upload Vite+ native artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: vite-plus-native-${{ matrix.settings.target }}
path: ./packages/cli/binding/*.node
if-no-files-found: error
- name: Upload Rust CLI binary artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: vite-global-cli-${{ matrix.settings.target }}
path: |
./target/${{ matrix.settings.target }}/release/vp
./target/${{ matrix.settings.target }}/release/vp.exe
./target/${{ matrix.settings.target }}/release/vp-shim.exe
if-no-files-found: error
- name: Remove .node files before upload dist
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
run: |
rm ./packages/core/dist/**/*.node
- name: Upload core dist
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
with:
name: core
path: ./packages/core/dist
if-no-files-found: error
- name: Upload cli dist
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
with:
name: cli
path: ./packages/cli/dist
if-no-files-found: error
- name: Upload cli skills (docs for agent integration)
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
with:
name: cli-skills
path: ./packages/cli/skills
if-no-files-found: error
Release:
runs-on: ubuntu-latest
needs: [prepare, build-rust]
permissions:
contents: write
packages: write
id-token: write # Required for OIDC
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/clone
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .node-version
package-manager-cache: false
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Download cli dist
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/cli/dist
pattern: cli
merge-multiple: true
- name: Download cli skills
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/cli/skills
pattern: cli-skills
merge-multiple: true
- name: Download cli binding
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/cli/artifacts
pattern: vite-plus-native-*
- name: Download core dist
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/core/dist
pattern: core
merge-multiple: true
- uses: ./.github/actions/download-rolldown-binaries
with:
github-token: ${{ github.token }}
target: x86_64-unknown-linux-gnu
upload: 'false'
- name: Download Rust CLI binaries
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: rust-cli-artifacts
pattern: vite-global-cli-*
- name: Move Rust CLI binaries to target directories
run: |
# Move each artifact's binary to the correct target directory
for artifact_dir in rust-cli-artifacts/vite-global-cli-*/; do
if [ -d "$artifact_dir" ]; then
# Extract target name from directory (e.g., vite-global-cli-x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
dir_name=$(basename "$artifact_dir")
target_name=${dir_name#vite-global-cli-}
# Create target directory and copy binary
mkdir -p "target/${target_name}/release"
cp -r "$artifact_dir"* "target/${target_name}/release/"
fi
done
# Show what we have (fail if no binaries found)
vp_files=$(find target -name "vp*" -type f 2>/dev/null || echo "")
if [ -z "$vp_files" ]; then
echo "Error: No vp binaries found in target directory"
echo "Artifact contents:"
find rust-cli-artifacts -type f || true
exit 1
fi
echo "Found binaries:"
echo "$vp_files"
- name: Set npm packages version
run: |
sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/core/package.json
sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/test/package.json
sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/cli/package.json
- name: Build test
run: pnpm --filter=@voidzero-dev/vite-plus-test build
- name: 'Setup npm'
run: |
npm install -g npm@latest
- name: Publish native addons
run: |
node ./packages/cli/publish-native-addons.ts
- name: Publish
run: |
pnpm publish --filter=./packages/core --tag ${{ inputs.npm_tag }} --access public --no-git-checks
pnpm publish --filter=./packages/test --tag ${{ inputs.npm_tag }} --access public --no-git-checks
pnpm publish --filter=./packages/cli --tag ${{ inputs.npm_tag }} --access public --no-git-checks
- name: Create release body
run: |
if [[ "${{ inputs.npm_tag }}" == "latest" ]]; then
INSTALL_BASH="curl -fsSL https://vite.plus | bash"
INSTALL_PS1="irm https://vite.plus/ps1 | iex"
else
INSTALL_BASH="curl -fsSL https://vite.plus | VITE_PLUS_VERSION=${{ env.VERSION }} bash"
INSTALL_PS1="\\\$env:VITE_PLUS_VERSION=\\\"${{ env.VERSION }}\\\"; irm https://vite.plus/ps1 | iex"
fi
cat > ./RELEASE_BODY.md <<EOF
## vite-plus v${{ env.VERSION }}
### Published Packages
- \`@voidzero-dev/vite-plus-core@${{ env.VERSION }}\`
- \`@voidzero-dev/vite-plus-test@${{ env.VERSION }}\`
- \`vite-plus@${{ env.VERSION }}\`
### Installation
**macOS/Linux:**
\`\`\`bash
${INSTALL_BASH}
\`\`\`
**Windows:**
\`\`\`powershell
${INSTALL_PS1}
\`\`\`
View the full commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
id: release
with:
body_path: ./RELEASE_BODY.md
draft: false
make_latest: ${{ inputs.npm_tag == 'latest' }}
prerelease: ${{ inputs.npm_tag == 'alpha' }}
name: vite-plus v${{ env.VERSION }}
tag_name: v${{ env.VERSION }}
target_commitish: ${{ github.sha }}
- name: Send Discord notification
if: ${{ inputs.npm_tag == 'latest' }}
uses: tsickert/discord-webhook@b217a69502f52803de774ded2b1ab7c282e99645 # v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_RELEASES_WEBHOOK_URL }}
embed-title: vite-plus v${{ env.VERSION }}
embed-description: |
A new release is available!
**Published Packages:**
• @voidzero-dev/vite-plus-core@${{ env.VERSION }}
• @voidzero-dev/vite-plus-test@${{ env.VERSION }}
• vite-plus@${{ env.VERSION }}
**Install:**
• macOS/Linux: `curl -fsSL https://vite.plus | bash`
• Windows: `irm https://vite.plus/ps1 | iex`
embed-url: https://github.com/${{ github.repository }}/releases/tag/v${{ env.VERSION }}