-
Notifications
You must be signed in to change notification settings - Fork 87
328 lines (274 loc) · 11.6 KB
/
Copy pathrunner-publish.yaml
File metadata and controls
328 lines (274 loc) · 11.6 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
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
328
name: 🚀 Publish ExTester Runner
on:
workflow_dispatch:
inputs:
tag:
description: "Version tag to publish (runner-vX.X.X)"
required: true
skipPublish:
description: "Skip publish into marketplaces step"
default: false
type: boolean
permissions:
contents: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: 👷🏻 Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ✅ Validate and extract tag
run: |
TAG=${{ github.event.inputs.tag }}
if [[ ! "$TAG" =~ ^runner-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Invalid tag format: $TAG. Use format like 'runner-v1.2.3'"
exit 1
fi
echo "TAG=$TAG" >> $GITHUB_ENV
echo "VERSION=${TAG#runner-v}" >> $GITHUB_ENV
- name: ⚙️ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: 📦 Install tools
run: |
npm install -g @vscode/vsce ovsx
sudo apt-get install -y gh
- name: 🔧 Install deps and build
run: |
npm ci
npm run build
- name: 🛠 Package extension
working-directory: packages/extester-runner
run: |
vsce package -o extester-runner-${VERSION}.vsix
vsce ls extester-runner-${VERSION}.vsix
- name: 📝 Generate changelog
working-directory: packages/extester-runner
run: |
PREV_TAG=$(git tag --list "runner-v*" --sort=-creatordate | grep -v "$TAG" | head -n 1)
echo "Comparing changes from $PREV_TAG to $TAG"
if [ -z "$PREV_TAG" ]; then
LOG=$(git log "$TAG" --reverse -- . --no-merges --pretty=format:'%s (%h)')
[ -z "$LOG" ] && LOG=$(git log --reverse -- . --no-merges --pretty=format:'%s (%h)')
else
LOG=$(git log "$PREV_TAG..$TAG" -- . --no-merges --pretty=format:'%s (%h)')
fi
if [ -z "$LOG" ]; then
LOG="Initial release (first tag)"
fi
format_section() {
local pattern="$1"
local title="$2"
local content=$(echo "$LOG" | grep -iE "$pattern" || true)
if [[ -n "$content" ]]; then
echo "### $title"
echo "$content"
echo
fi
}
format_other_section() {
local title="🧼 Other Changes"
local content=$(echo "$LOG" | grep -vE '^(feat|feature|fix|test|chore|refactor|internal|ci|docs|deps|dependencies)' || true)
if [[ -n "$content" ]]; then
echo "### $title"
echo "$content"
echo
fi
}
{
format_section 'feat|feature' "🚀 Features"
format_section 'fix' "🚫 Bugs"
format_section 'test' "🔎 Tests"
format_section 'chore|refactor|internal|ci|docs' "🔧 Maintenance"
format_section 'deps|dependencies' "📦 Dependencies"
format_other_section
} > CHANGELOG.md
echo "Generated CHANGELOG.md"
cat CHANGELOG.md
- name: 🚀 Publish to VS Code Marketplace
if: ${{ github.event.inputs.skipPublish != 'true' }}
working-directory: packages/extester-runner
run: |
vsce publish --pat ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} \
--packagePath extester-runner-${VERSION}.vsix
- name: 🚀 Publish to Open VSX Registry
if: ${{ github.event.inputs.skipPublish != 'true' }}
working-directory: packages/extester-runner
run: |
ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} extester-runner-${VERSION}.vsix
- name: 📣 Add summary
if: ${{ github.event.inputs.skipPublish != 'true' }}
run: |
echo "#### ✅ Published \`extester-runner-${VERSION}.vsix\` to VS Code Marketplace" >> $GITHUB_STEP_SUMMARY
echo "#### ✅ Published \`extester-runner-${VERSION}.vsix\` to Open VSX Registry" >> $GITHUB_STEP_SUMMARY
- name: 💾 Upload VSIX
uses: actions/upload-artifact@v4
with:
name: extester-runner-${{ env.VERSION }}.vsix
path: packages/extester-runner/extester-runner-${{ env.VERSION }}.vsix
- name: 🚀 Publish GitHub Release
working-directory: packages/extester-runner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$TAG" \
--title "ExTester Runner v${VERSION}" \
--notes-file CHANGELOG.md \
extester-runner-${VERSION}.vsix
# name: 🚀 Publish ExTester Runner
# on:
# workflow_dispatch:
# inputs:
# tag:
# description: "Version tag to publish (runner-vX.X.X)"
# required: true
# skipPublish:
# description: "Skip publish into marketplaces step"
# default: false
# type: boolean
# permissions:
# contents: write
# jobs:
# build-and-publish:
# runs-on: ubuntu-latest
# steps:
# - name: 🔖 Show input tag
# run: echo "Publishing version ${{ github.event.inputs.tag }}"
# - name: ✅ Validate tag format
# run: |
# TAG=${{ github.event.inputs.tag }}
# if [[ ! "$TAG" =~ ^runner-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# echo "❌ Invalid tag format: $TAG. Use format like 'runner-v1.2.3'"
# exit 1
# fi
# - name: 👷🏻 Checkout Repository
# uses: actions/checkout@v4
# - name: ✅ Verify Git tag exists
# run: |
# git fetch --tags
# if ! git rev-parse "refs/tags/${{ github.event.inputs.tag }}" >/dev/null 2>&1; then
# echo "❌ Tag '${{ github.event.inputs.tag }}' does not exist!"
# exit 1
# fi
# # - name: ✅ Ensure tag matches package.json version
# # working-directory: packages/extester-runner
# # run: |
# # PKG_VERSION=$(node -p "require('./package.json').version")
# # TAG=${{ github.event.inputs.tag }}
# # TAG_VERSION=${TAG#runner-v}
# # echo "Package version: $PKG_VERSION"
# # echo "Input tag version: $TAG_VERSION"
# # if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
# # echo "❌ Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)!"
# # exit 1
# # fi
# - name: 👷🏻 Checkout the tag
# uses: actions/checkout@v4
# with:
# ref: ${{ github.event.inputs.tag }}
# fetch-depth: 0 # Important! Fetch full history
# - name: ⚙️ Setup NodeJS
# uses: actions/setup-node@v4
# with:
# node-version: 20
# - name: 📦 Install vsce
# run: npm install -g @vscode/vsce
# - name: 📦 Install ovsx
# run: npm install -g ovsx
# - name: 📦 Install GitHub CLI
# run: sudo apt-get install gh -y
# - name: 🔧 Install
# run: npm ci
# - name: 🔧 Build
# run: npm run build
# - name: 🛠 Extract version from a tag
# id: version
# run: |
# TAG=${{ github.event.inputs.tag }}
# VER=$(echo "$TAG" | sed 's/^runner-v//')
# echo "VERSION=$VER" >> $GITHUB_OUTPUT
# - name: 🛠 Package extension
# working-directory: packages/extester-runner
# run: vsce package -o extester-runner-${{ steps.version.outputs.VERSION }}.vsix
# - name: 🧾 Inspect packaged contents
# working-directory: packages/extester-runner
# run: vsce ls extester-runner-${{ steps.version.outputs.VERSION }}.vsix
# - name: 🚀 Publish to VS Code Marketplace
# if: ${{ github.event.inputs.skipPublish != 'true' }}
# working-directory: packages/extester-runner
# run: vsce publish --pat ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath extester-runner-${{ steps.version.outputs.VERSION }}.vsix
# - name: 🚀 Publish to Open VSX Registry
# if: ${{ github.event.inputs.skipPublish != 'true' }}
# working-directory: packages/extester-runner
# run: ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} extester-runner-${{ steps.version.outputs.VERSION }}.vsix
# - name: 📣 Add summary
# if: ${{ github.event.inputs.skipPublish != 'true' }}
# run: |
# echo "#### ✅ Published \`extester-runner-${{ steps.version.outputs.VERSION }}.vsix\` to VS Code Marketplace" >> $GITHUB_STEP_SUMMARY
# echo "#### ✅ Published \`extester-runner-${{ steps.version.outputs.VERSION }}.vsix\` to Open VSX Registry" >> $GITHUB_STEP_SUMMARY
# - name: 💾 Upload VSIX
# uses: actions/upload-artifact@v4
# with:
# name: extester-runner-${{ steps.version.outputs.VERSION }}.vsix
# path: "packages/extester-runner/extester-runner-${{ steps.version.outputs.VERSION }}.vsix"
# - name: 📝 Generate changelog
# id: changelog
# working-directory: packages/extester-runner
# run: |
# TAG=${{ github.event.inputs.tag }}
# VERSION=${TAG#runner-v}
# PREV_TAG=$(git tag --list "runner-v*" --sort=-creatordate | grep -v "$TAG" | head -n 1)
# echo "Comparing changes from $PREV_TAG to $TAG in packages/extester-runner"
# git fetch --unshallow || true
# if [ -z "$PREV_TAG" ]; then
# # First tag: include everything reachable from it
# LOG=$(git log "$TAG" --reverse -- packages/extester-runner --no-merges --pretty=format:'%s (%h)')
# if [ -z "$LOG" ]; then
# # Still empty? Fallback to full history
# LOG=$(git log --reverse -- packages/extester-runner --no-merges --pretty=format:'%s (%h)')
# fi
# else
# LOG=$(git log "$PREV_TAG..$TAG" -- packages/extester-runner --no-merges --pretty=format:'%s (%h)')
# fi
# if [ -z "$LOG" ]; then
# LOG="Initial release (first tag)"
# fi
# # Helper to format sections
# format_section() {
# local pattern="$1"
# local title="$2"
# local content=$(echo "$LOG" | grep -iE "$pattern" || true)
# if [[ -n "$content" ]]; then
# echo "### $title"
# echo "$content"
# echo ""
# fi
# }
# {
# format_section 'feat|feature' "🚀 Features"
# format_section 'fix' "🚫 Bugs"
# format_section 'test' "🔎 Tests"
# format_section 'chore|refactor|internal|ci|docs' "🔧 Maintenance"
# format_section 'deps|dependencies' "📦 Dependencies"
# # Other commits not matching any above
# OTHER=$(echo "$LOG" | grep -vE 'feat|feature|fix|test|chore|refactor|internal|ci|docs|deps|dependencies' || true)
# if [[ -n "$OTHER" ]]; then
# echo "### 🧼 Other Changes"
# echo "$OTHER"
# echo ""
# fi
# } > CHANGELOG.md
# echo "Generated CHANGELOG.md:"
# cat CHANGELOG.md
# - name: 🚀 Publish GitHub Release with VSIX
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# working-directory: packages/extester-runner
# run: |
# TAG=${{ github.event.inputs.tag }}
# gh release create "$TAG" --title "ExTester Runner v${{ steps.version.outputs.VERSION }}" \
# --notes-file CHANGELOG.md \
# "extester-runner-${{ steps.version.outputs.VERSION }}.vsix"