-
Notifications
You must be signed in to change notification settings - Fork 23
250 lines (214 loc) · 10.1 KB
/
build-vsix.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
name: Publish
on:
workflow_dispatch:
inputs:
releaseType:
description: "Release Type"
required: true
type: choice
default: "patch"
options:
- patch
- minor
- major
releaseChannel:
description: "Release Channel"
required: true
type: choice
default: stable
options:
- stable
- edge
publishMarketplace:
description: "Publish on Visual Studio Marketplace?"
required: true
type: choice
default: "yes"
options:
- "yes"
- "no"
publishOpenVSX:
description: "Publish on Open VSX Registry?"
required: true
type: choice
default: "yes"
options:
- "yes"
- "no"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check for correct branch (Edge)
if: github.event.inputs.releaseChannel == 'edge'
run: |
if [ "$GITHUB_REF_NAME" = "edge" ]; then
echo "Correct branch was used, proceeding with edge release"
else
echo "The 'edge' release must come from a branch called 'edge'"
echo "(it was: '${GITHUB_REF_NAME}')"
exit 1
fi;
- name: Check for correct branch (Stable)
if: github.event.inputs.releaseChannel == 'stable'
run: |
if [ "$GITHUB_REF_NAME" = "main" ]; then
echo "Correct branch was used, proceeding with stable release"
else
echo "The 'stable' release must come from a branch called 'main'"
echo "(it was: '${GITHUB_REF_NAME}')"
exit 1
fi;
- name: Clone Repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3
with:
fetch-depth: 0
- name: Setup Flux CLI
uses: fluxcd/flux2/action@1730f3c46bddf0a29787d8d4fa5ace283f298e49 # pin@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node version
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # pin@v3
with:
node-version: 19
- name: Install vsce globally
run: npm install -g @vscode/vsce
- name: Install dependencies
run: npm install
- name: Install webview dependencies
run: npm run install:webview
- name: Build webview
run: npm run build:webview
- name: Build Package
run: npm run compile
- name: Setup Kubernetes
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 # [email protected]
with:
version: v0.20.0
image: kindest/node:v1.28.0
- name: Run Tests
uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 # pin@v1
with:
run: npm test
options: "-screen 0 1600x1200x24"
- name: Create Changelog
run: |
git log $(git describe --tags --abbrev=0)..HEAD --oneline &> ${{ github.workspace }}-CHANGELOG.txt
cat ${{ github.workspace }}-CHANGELOG.txt
- name: Setup Git
run: |
git config --global user.name "gitops-release-bot"
git config --global user.email "[email protected]"
- name: Get Current Version Number
run: |
CURRENT_VERSION=$(cat package.json | jq .version | cut -d'"' -f 2)
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Compile New Version (Edge)
run: |
RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i pre${{ github.event.inputs.releaseType }} --preid edge)
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "Bump to $RELEASE_VERSION"
if: ${{ github.event.inputs.releaseChannel == 'edge' && !contains(env.CURRENT_VERSION, 'edge') }}
- name: Compile New Version (Edge)
run: |
RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i prerelease)
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "Bump to $RELEASE_VERSION"
if: ${{ github.event.inputs.releaseChannel == 'edge' && contains(env.CURRENT_VERSION, 'edge') }}
- name: Compile New Version (Stable)
run: |
RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i ${{ github.event.inputs.releaseType }})
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "Bump to $RELEASE_VERSION"
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
- name: Version Package
run: |
git status
git diff && git diff --cached
npm version $RELEASE_VERSION
git tag -a $RELEASE_VERSION -m "$RELEASE_VERSION"
- name: Package Extension (Edge)
if: ${{ github.event.inputs.releaseChannel == 'edge' }}
run: |
node .github/scripts/updateEdgeVersion.js
vsce package --pre-release --no-git-tag-version --no-update-package-json -o "./gitops-tools-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }}
- name: Package Extension (Stable)
run: vsce package $RELEASE_VERSION --no-git-tag-version --no-update-package-json -o "./gitops-tools-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }}
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
- name: Publish to Visual Studio Marketplace (Edge)
run: vsce publish --packagePath "./gitops-tools-$RELEASE_VERSION.vsix" --pre-release --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }}
if: ${{ github.event.inputs.publishMarketplace == 'yes' && github.event.inputs.releaseChannel == 'edge' }}
- name: Publish to Visual Studio Marketplace (Stable)
run: vsce publish --packagePath "./gitops-tools-$RELEASE_VERSION.vsix" --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }}
if: ${{ github.event.inputs.publishMarketplace == 'yes' && github.event.inputs.releaseChannel == 'stable' }}
- name: Publish to Open VSX Registry (Edge)
uses: HaaLeo/publish-vscode-extension@dfe4f6ad46624424fe24cb5bca79839183399045 # pin@v1
if: ${{ github.event.inputs.publishOpenVSX == 'yes' && github.event.inputs.releaseChannel == 'edge' }}
with:
preRelease: true
pat: ${{ secrets.OPEN_VSX_TOKEN }}
extensionFile: ./gitops-tools-${{ env.RELEASE_VERSION }}.vsix
- name: Publish to Open VSX Registry (Stable)
uses: HaaLeo/publish-vscode-extension@dfe4f6ad46624424fe24cb5bca79839183399045 # pin@v1
if: ${{ github.event.inputs.publishOpenVSX == 'yes' && github.event.inputs.releaseChannel == 'stable' }}
with:
preRelease: false
pat: ${{ secrets.OPEN_VSX_TOKEN }}
extensionFile: ./gitops-tools-${{ env.RELEASE_VERSION }}.vsix
- name: Push Tags (Edge)
if: ${{ github.event.inputs.releaseChannel == 'edge' }}
run: |
git log -1 --stat
git push origin --force-with-lease edge:release-pr --tags
- name: Push Tags (Stable)
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
run: |
git log -1 --stat
git push origin --force-with-lease main:release-pr --tags
- run: |
export GIT_TAG=$(git describe --tags --abbrev=0)
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
- name: GitHub Release
uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # pin@v1
with:
artifacts: "./gitops-tools-*"
bodyFile: ${{ github.workspace }}-CHANGELOG.txt
tag: ${{ env.GIT_TAG }}
prerelease: ${{ github.event.inputs.releaseChannel == 'edge' }}
# We need to use a pull request because we need tags to be included in the history of our main
# branch. We don't want to make an exception for our "no pushes without a pull request" security
# policy, even for some robot. So just merge this PR manually to complete each release, or do a
# fast-forward of the edge branch catching it up to the `release-pr` branch, as it won't get the
# PR. (If you have trouble publishing more than one edge release, this mistake is usually why.)
- uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5 # pin@v2
name: Finish Release PR
if: ${{ github.event.inputs.releaseChannel != 'edge' }}
with:
source_branch: "release-pr"
destination_branch: "main"
pr_title: "Release ${{ env.GIT_TAG }}"
pr_body: |-
A release has been tagged and published, ${{ env.GIT_TAG }}! 🎉
Please ensure that \`CHANGELOG.md\` remains current by pushing any needed updates as a commit to this branch.
A CHANGELOG has been generated for this release here, [\`v${{ env.GIT_TAG }}\`](https://github.com/weaveworks/vscode-gitops-tools/releases/tag/${{ env.GIT_TAG }}) – you can copy directly from it, or edit for uniformity and clarity.
When you are done, merge this PR with the tag intact (**Do Not Squash** or rebase! Push new commits and **merge only**).
Feature branches should still be squashed, but \`release-pr\` must always be merged to complete the release.
See the [CONTRIBUTING.md](https://github.com/weaveworks/vscode-gitops-tools/blob/main/CONTRIBUTING.md#releasing) for more information about the release process.
pr_reviewer: ${{ github.actor }}
pr_draft: false
github_token: ${{ secrets.GITHUB_TOKEN }}
# - name: Get the version
# id: version
# run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
# shell: bash
#
# - uses: apexskier/github-semver-parse@671ddf80785e4d721e76723ec1e687317f85bfe9 # pin@v1
# id: semver
# with:
# version: ${{ steps.version.outputs.VERSION }}
#
# - uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # pin@v1
# with:
# artifacts: "vscode-gitops-tools-*.vsix"
# token: ${{ secrets.GITHUB_TOKEN }}
# prerelease: ${{ !!steps.semver.outputs.prerelease }}