-
Notifications
You must be signed in to change notification settings - Fork 9
327 lines (308 loc) · 10.9 KB
/
publish.yml
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
name: Release and Publish extension
on:
push:
branches:
- main
paths:
- package.json
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
jobs:
check-version-change:
env:
EXT_VERSION: ${{ github.event.inputs.version }}
outputs:
changed: ${{ steps.check-version.outputs.result }}
version: ${{ env.EXT_VERSION }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- name: Check if version has changed
id: check-version
uses: actions/github-script@v6
with:
script: |
const version = '${{ github.event.inputs.version }}' || require('./package.json').version;
// Find a release for that version
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: `v${version}`,
}).catch(() => null);
// If the release exists, the version has not changed
if (release) {
console.log(`Version ${version} has an existing release`);
console.log(release.data.html_url);
core.summary.addLink(`Release v${version}`, release.data.html_url);
await core.summary.write();
return "false";
}
console.log(`Version ${version} does not have a release`);
return true;
- name: Export Version
run: |
echo "EXT_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
release:
name: Release extension v${{ needs.check-version-change.outputs.version }} for ${{ matrix.vsce_target }}
needs:
- check-version-change
if: ${{ needs.check-version-change.outputs.changed == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
strategy:
matrix:
include:
- vsce_target: web
ls_target: web_noop
npm_config_arch: x64
- vsce_target: linux-x64
ls_target: linux_amd64
npm_config_arch: x64
- vsce_target: linux-arm64
ls_target: linux_arm64
npm_config_arch: arm64
- vsce_target: linux-armhf
ls_target: linux_arm
npm_config_arch: arm
- vsce_target: darwin-x64
ls_target: darwin_amd64
npm_config_arch: x64
- vsce_target: darwin-arm64
ls_target: darwin_arm64
npm_config_arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- run: npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm_config_arch: ${{ matrix.npm_config_arch }}
ls_target: ${{ matrix.ls_target }}
- name: Create a package.json that actions/upload will like
run: |
cp package.json package.json.real
sed --regexp-extended '/"name"\s*:/ s#@[a-zA-Z\\-]+/##' package.json.real > package.json
- name: Insert Variables
run: |
./.github/workflow_scripts/insert-secrets.sh
env:
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
PARALLELS_CATALOG_URL: ${{ secrets.PARALLELS_CATALOG_URL }}
PARALLELS_CATALOG_BUSINESS_PASSWORD: ${{ secrets.PARALLELS_CATALOG_BUSINESS_PASSWORD }}
PARALLELS_CATALOG_BUSINESS_USER: ${{ secrets.PARALLELS_CATALOG_BUSINESS_USER }}
PARALLELS_CATALOG_PRO_PASSWORD: ${{ secrets.PARALLELS_CATALOG_PRO_PASSWORD }}
PARALLELS_CATALOG_PRO_USER: ${{ secrets.PARALLELS_CATALOG_PRO_USER }}
- run: npm ci
env:
npm_config_arch: ${{ matrix.npm_config_arch }}
ls_target: ${{ matrix.ls_target }}
- name: Package Stable VSIX
run: npm run package -- --target=${{ matrix.vsce_target }}
- name: Upload vsix as artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: ${{ matrix.vsce_target }}
path: "*.vsix"
- name: Restore old package.json
run: mv package.json.real package.json
release-win:
name: Release extension v${{ needs.check-version-change.outputs.version }} for ${{ matrix.vsce_target }}
needs:
- check-version-change
if: ${{ needs.check-version-change.outputs.changed == 'true' }}
runs-on: windows-latest
permissions:
contents: write
packages: read
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
strategy:
matrix:
include:
- vsce_target: win32-x64
ls_target: windows_amd64
npm_config_arch: x64
- vsce_target: win32-arm64
ls_target: windows_arm64
npm_config_arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- name: create a package.json that actions/upload will like
run: |
cp package.json package.json.real
sed --regexp-extended '/"name"\s*:/ s#@[a-zA-Z\\-]+/##' package.json.real > package.json
- name: Install dependencies
run: |
npm ci
env:
npm_config_arch: ${{ matrix.npm_config_arch }}
ls_target: ${{ matrix.ls_target }}
- name: Package stable VSIX
run: npm run package -- --target=${{ matrix.vsce_target }}
- name: Upload vsix as artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: ${{ matrix.vsce_target }}
path: "*.vsix"
- name: Restore old package.json
run: |
del package.json
move package.json.real package.json
create-release:
name: Create release v${{ needs.check-version-change.outputs.version }}
needs:
- release
- release-win
- check-version-change
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
- name: Generate release notes
run: |
./.github/workflow_scripts/get-latest-changelog.sh --output-to-file
cat release_notes.md
- name: Create release and upload release asset
uses: actions/github-script@v6
with:
script: |
const fs = require("fs");
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
body: fs.readFileSync("release_notes.md", "utf8"),
tag_name: "v${{ env.EXT_VERSION }}",
name: "v${{ env.EXT_VERSION }}",
draft: false,
prerelease: false
});
upload-artifacts-to-release:
name: Upload artifacts to release v${{ needs.check-version-change.outputs.version }}
needs:
- create-release
- check-version-change
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
strategy:
matrix:
include:
- vsce_target: web
ls_target: web_noop
npm_config_arch: x64
- vsce_target: win32-x64
ls_target: windows_amd64
npm_config_arch: x64
- vsce_target: win32-arm64
ls_target: windows_arm64
npm_config_arch: arm
- vsce_target: linux-x64
ls_target: linux_amd64
npm_config_arch: x64
- vsce_target: linux-arm64
ls_target: linux_arm64
npm_config_arch: arm64
- vsce_target: linux-armhf
ls_target: linux_arm
npm_config_arch: arm
- vsce_target: darwin-x64
ls_target: darwin_amd64
npm_config_arch: x64
- vsce_target: darwin-arm64
ls_target: darwin_arm64
npm_config_arch: arm64
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.vsce_target }}
- name: Upload artifact to release
env:
GH_TOKEN: ${{ secrets.GHUB_PAT }}
run: |
ls -la
gh release upload v${{ env.EXT_VERSION }} *.vsix
- name: Create release and upload release asset
if: false
uses: actions/github-script@v6
with:
script: |
const fs = require("fs");
const path = "./parallels-desktop-${{ matrix.vsce_target }}-${{ env.EXT_VERSION }}.vsix";
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
data: fs.readFileSync(path),
name: "parallels-desktop-${{ matrix.vsce_target }}-${{ env.EXT_VERSION }}.vsix",
headers: {
"content-type": "application/vsix",
"content-length": fs.statSync(path).size
}
});
core.summary.addLink(`Release v${{ env.EXT_VERSION }}`, release.data.html_url);
await core.summary.write();
publish:
name: Publish extension v${{ needs.check-version-change.outputs.version }}
# environment: publish
needs:
- check-version-change
- upload-artifacts-to-release
runs-on: ubuntu-latest
permissions: {}
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
steps:
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
- name: Publish Stable to Marketplace
run: npx vsce publish --no-git-tag-version --packagePath $(find . -iname *.vsix)
env:
VSCE_PAT: ${{ secrets.PUBLISHER_KEY }}
discord-announce:
needs:
- publish
- check-version-change
name: Announce on Discord
runs-on: ubuntu-latest
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
VERSION: ${{ needs.check-version-change.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Announce on discord
id: announce_discord
run: |
./.github/workflow_scripts/announce_discord.sh --repo ${{ github.repository }} --webhook-url $DISCORD_WEBHOOK --version ${{ env.VERSION }}
env:
SLACK_WEBHOOKS: ${{ env.DISCORD_WEBHOOK }}