Repository navigation
237 lines (223 loc) · 8.67 KB
/
Copy pathrelease.yml
File metadata and controls
237 lines (223 loc) · 8.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
name: release
# Runs when a tag v* is pushed (stable release) or on the daily schedule /
# manual dispatch on main (Marketplace and Open VSX pre-release).
# Stable and pre-release publishing live in a single workflow file so Open VSX
# Trusted Publishing (which allows one workflow file per extension) covers both.
on:
push:
tags:
- "v*"
schedule:
- cron: '23 3 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.event_name == 'push' && format('stable-publishing-{0}', github.ref) || 'marketplace-pre-release' }}
cancel-in-progress: false
permissions:
contents: read
actions: read
jobs:
check-version:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- name: Check stable version and release tag
env:
RELEASE_TAG: ${{ github.ref_name }}
run: node .github/scripts/extension-version.js check-stable "$RELEASE_TAG"
verify:
needs: check-version
uses: ./.github/workflows/main.yml
release:
name: Release
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Independent of the registry jobs so the VSIX stays available as a
# fallback when a registry is down.
needs: verify
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Download artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: vscode-R.vsix
path: artifacts/
- name: Create release
run: |
VERSION=${GITHUB_REF#refs/tags/v}
ASSET="r-$VERSION.vsix"
mv artifacts/vscode-R.vsix "artifacts/$ASSET"
if RELEASE=$(gh release view "v$VERSION" --json isDraft,assets 2>/dev/null); then
# A previous attempt may have created the release without the asset.
# Keep a completed asset: --clobber deletes it before uploading, so
# a failed upload would remove the existing download.
if jq -e --arg name "$ASSET" \
'.assets | any(.name == $name and .state == "uploaded")' \
<<<"$RELEASE" >/dev/null; then
echo "Release v$VERSION already has $ASSET; skipping the upload."
else
echo "Release v$VERSION already exists; uploading $ASSET."
# --clobber replaces an incomplete asset with the same name.
gh release upload "v$VERSION" "artifacts/$ASSET" --clobber
fi
# gh release create uploads assets to a draft before publishing it,
# so an interrupted attempt can leave the release as a draft.
if [ "$(jq -r .isDraft <<<"$RELEASE")" = "true" ]; then
echo "Release v$VERSION is a draft; publishing it."
gh release edit "v$VERSION" --draft=false
fi
else
gh release create "v$VERSION" "artifacts/$ASSET" \
--title "v$VERSION" \
--notes "Release v$VERSION" \
--generate-notes
fi
publish-vs-marketplace:
name: Publish to Visual Studio Marketplace
if: github.event_name == 'push'
environment: vs-marketplace
permissions:
contents: read
id-token: write
timeout-minutes: 30
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: Download artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: vscode-R.vsix
path: artifacts/
- name: Publish to Visual Studio Marketplace
run: pnpm exec vsce publish --oidc --skip-duplicate --packagePath artifacts/*.vsix
publish-open-vsx:
name: Publish to Open VSX Registry
if: github.event_name == 'push'
environment: open-vsx
permissions:
contents: read
id-token: write
timeout-minutes: 30
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: Download artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: vscode-R.vsix
path: artifacts/
- name: Publish to Open VSX Registry
run: pnpm exec ovsx publish --trusted-publishing --skip-duplicate --packagePath artifacts/*.vsix
prerelease-prepare:
if: github.event_name != 'push' && github.repository == 'REditorSupport/vscode-R' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
publish: ${{ steps.previous.outputs.publish }}
date: ${{ steps.previous.outputs.date }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- name: Check publication history
id: previous
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
node .github/scripts/marketplace-pre-release-history.js
prerelease-verify:
needs: prerelease-prepare
if: needs.prerelease-prepare.outputs.publish == 'true'
uses: ./.github/workflows/main.yml
with:
prerelease-date: ${{ needs.prerelease-prepare.outputs.date }}
prerelease-publish-vs-marketplace:
environment: vs-marketplace
permissions:
actions: read
contents: read
id-token: write
needs:
- prerelease-prepare
- prerelease-verify
if: github.event_name != 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: Download verified pre-release
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: vscode-R.vsix
path: artifacts/
- name: Recheck publication eligibility
id: eligibility
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node .github/scripts/marketplace-pre-release-history.js
- name: Publish to Visual Studio Marketplace
if: steps.eligibility.outputs.publish == 'true'
run: pnpm exec vsce publish --oidc --pre-release --skip-duplicate --packagePath artifacts/vscode-R.vsix
prerelease-publish-open-vsx:
environment: open-vsx
permissions:
actions: read
contents: read
id-token: write
needs:
- prerelease-prepare
- prerelease-verify
if: github.event_name != 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: Download verified pre-release
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: vscode-R.vsix
path: artifacts/
- name: Recheck publication eligibility
id: eligibility
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node .github/scripts/marketplace-pre-release-history.js
- name: Publish to Open VSX Registry
if: steps.eligibility.outputs.publish == 'true'
run: pnpm exec ovsx publish --trusted-publishing --skip-duplicate --packagePath artifacts/vscode-R.vsix