-
Notifications
You must be signed in to change notification settings - Fork 4
92 lines (76 loc) · 3.04 KB
/
Copy pathbuild-vsix.yml
File metadata and controls
92 lines (76 loc) · 3.04 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
name: Build VSIX
on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
jobs:
build-vsix:
name: Build installable VSIX
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Sanitize branch name
id: branch
run: echo "name=$(echo '${{ github.head_ref }}' | tr '/' '-')" >> "$GITHUB_OUTPUT"
- name: Stamp pre-release version
run: |
BASE=$(node -p "require('./package.json').version")
jq ".version = \"${BASE}-pr.${{ github.event.pull_request.number }}\"" package.json > package.tmp.json
mv package.tmp.json package.json
- name: Package extension
run: npx @vscode/vsce package --no-dependencies -o cloudinary-${{ steps.branch.outputs.name }}.vsix
- name: Upload VSIX artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: cloudinary-${{ steps.branch.outputs.name }}
path: cloudinary-${{ steps.branch.outputs.name }}.vsix
retention-days: 14
- name: Update PR description with VSIX link
uses: actions/github-script@v7
with:
script: |
const markerStart = '<!-- vsix-build -->';
const markerEnd = '<!-- /vsix-build -->';
const version = require('./package.json').version;
const artifactUrl = '${{ steps.upload.outputs.artifact-url }}';
const artifactName = 'cloudinary-${{ steps.branch.outputs.name }}.vsix';
const section = [
markerStart,
`> **📦 Test build · v${version}** — [Download VSIX](${artifactUrl}) _(expires in 14 days, requires GitHub login)_`,
`> To install: **Extensions → ··· → Install from VSIX…** or \`code --install-extension ${artifactName}\``,
markerEnd,
].join('\n');
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const currentBody = pr.body || '';
let newBody;
if (currentBody.includes(markerStart)) {
const startIdx = currentBody.indexOf(markerStart);
const endIdx = currentBody.indexOf(markerEnd) + markerEnd.length;
newBody = currentBody.slice(0, startIdx) + section + currentBody.slice(endIdx);
} else {
newBody = currentBody ? currentBody + '\n\n' + section : section;
}
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: newBody,
});