-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (166 loc) · 6.76 KB
/
Copy pathrelease.yml
File metadata and controls
184 lines (166 loc) · 6.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
name: Release
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run: package and upload the VSIX artifacts only, skip publishing'
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
# A real release may only be dispatched from `main`: `gh workflow run --ref`
# accepts any branch or tag, and publishing plus tagging from anywhere else
# would permanently release the wrong commit. Dry runs are allowed from any
# ref so a branch can rehearse the packaging matrix. Failing here (instead
# of silently skipping the publish steps) makes the mistake visible.
preflight:
name: Preflight
if: github.repository == 'rstackjs/rstack-editor'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Require main for a real release
if: ${{ !inputs.dry_run && github.ref != 'refs/heads/main' }}
run: |
echo "::error::A real release must be dispatched from main (got ${GITHUB_REF}). Re-run with dry run enabled, or dispatch from main."
exit 1
release_vscode_extension:
name: Release VS Code Extension (${{ matrix.vsce-target }})
needs: preflight
runs-on: ${{ matrix.runner }}
environment: vscode-marketplace
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
vsce-target: linux-x64
arch: x64
- runner: ubuntu-22.04
vsce-target: linux-arm64
arch: arm64
- runner: macos-15
vsce-target: darwin-x64
arch: x64
- runner: macos-15
vsce-target: darwin-arm64
arch: arm64
- runner: windows-2022
vsce-target: win32-x64
arch: x64
- runner: windows-latest
vsce-target: win32-arm64
arch: arm64
defaults:
run:
shell: bash
env:
# rslib.config.mts keys the staged `@yuku-parser/binding-*` napi payload
# off this variable (Linux targets get a `-gnu` suffix appended there).
VSCE_TARGET: ${{ matrix.vsce-target }}
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
fetch-depth: 1
- name: Setup pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- name: Setup Node.js
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
# `supportedArchitectures` must be set BEFORE `pnpm install` so pnpm also
# fetches the cross-target optional `@yuku-parser/binding-*` package (the
# Linux runners' current libc is glibc, matching the `-gnu` bindings the
# linux-* VSIX targets need).
- name: Install Dependencies
run: |
pnpm config set --location=project --json supportedArchitectures '{"cpu":["current","${{ matrix.arch }}"]}'
pnpm install
- name: Build
run: pnpm run build
- name: Package VS Code Extension
working-directory: packages/vscode
run: pnpm exec vsce package --target ${{ matrix.vsce-target }} -o rstack-${{ matrix.vsce-target }}.vsix
- name: Upload VSIX Artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: rstack-${{ matrix.vsce-target }}
path: packages/vscode/rstack-${{ matrix.vsce-target }}.vsix
if-no-files-found: error
- name: Publish VS Code Extension
if: ${{ !inputs.dry_run }}
working-directory: packages/vscode
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: pnpm exec vsce publish --target ${{ matrix.vsce-target }} --skip-duplicate
- name: Publish OVSX Extension
if: ${{ !inputs.dry_run }}
working-directory: packages/vscode
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
run: pnpm exec ovsx publish --target ${{ matrix.vsce-target }} --skip-duplicate
# Runs only for a real release: a dry run must leave no tag behind. The tag
# points at the commit that was actually published (github.sha), the release
# notes come from the conventional commits since the previous tag, and the
# VSIX of every matrix target is attached as an asset so a release can be
# installed by hand (`code --install-extension`) without either marketplace.
github_release:
name: Tag and GitHub Release
needs: release_vscode_extension
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
# changelogithub needs the tags and history to find the previous
# release and list the commits since it; the tag step compares an
# existing tag's target against this commit.
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: 22
- name: Download VSIX Artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: rstack-*
path: vsix
merge-multiple: true
- name: Read Version
id: version
run: echo "tag=v$(node -p "require('./packages/vscode/package.json').version")" >> "$GITHUB_OUTPUT"
# Idempotent for a re-run of the same commit (e.g. after one marketplace
# publish flaked and `--skip-duplicate` covered the rest), but a tag that
# already points at a *different* commit means the version was never
# bumped after the last release: fail instead of attaching VSIX files
# built from this commit to a release tagged at another one.
- name: Push Tag
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
existing=$(git rev-parse --verify --quiet "refs/tags/$TAG^{commit}" || true)
if [ -z "$existing" ]; then
git tag "$TAG" "$GITHUB_SHA"
git push origin "refs/tags/$TAG"
elif [ "$existing" = "$GITHUB_SHA" ]; then
echo "tag $TAG already points at $GITHUB_SHA, leaving it as is"
else
echo "::error::tag $TAG already exists at $existing but this run is at $GITHUB_SHA — bump the version (pnpm bump) before releasing again."
exit 1
fi
- name: GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
run: |
npx changelogithub@15.0.4 --to "$TAG" --assets 'vsix/*.vsix'