-
Notifications
You must be signed in to change notification settings - Fork 10
551 lines (482 loc) · 25.3 KB
/
publish.yml
File metadata and controls
551 lines (482 loc) · 25.3 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
name: Publish to npm
on:
workflow_run:
workflows: ["CI"]
types: [completed]
branches: ['release/**']
schedule:
- cron: '0 2 * * 1-5' # Weekdays at 2 AM UTC (Mon-Fri)
workflow_dispatch:
inputs:
release_type:
description: 'Release type (ignored for release branch workflow_run — always stable)'
required: true
default: 'nightly'
type: choice
options:
- nightly
- stable
env:
SFCC_DISABLE_TELEMETRY: ${{ vars.SFCC_DISABLE_TELEMETRY }}
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
if: >-
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
permissions:
actions: write # For triggering deploy-docs.yml via workflow_dispatch
contents: write # For creating GitHub releases and tags
id-token: write # Required for npm OIDC trusted publishers
pull-requests: write # For creating merge-back PRs
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || '' }}
fetch-depth: 0 # Needed for docs tag detection
- name: Determine release type
id: release-type
run: |
if [[ "${{ github.event.inputs.release_type }}" == "stable" ]] || [[ "${{ github.event_name }}" == "workflow_run" ]]; then
echo "type=stable" >> $GITHUB_OUTPUT
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "type=nightly" >> $GITHUB_OUTPUT
echo "tag=nightly" >> $GITHUB_OUTPUT
fi
- name: Check for pending changesets
if: steps.release-type.outputs.type == 'stable'
id: changesets
run: |
PENDING=$(find .changeset -name '*.md' ! -name 'README.md' 2>/dev/null | wc -l | tr -d ' ')
if [[ "$PENDING" -gt 0 ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "::notice::Found $PENDING pending changeset(s) — skipping publish"
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Quick version check
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true'
id: quick-check
run: |
HAS_CHANGES=false
for spec in "@salesforce/b2c-tooling-sdk:packages/b2c-tooling-sdk" \
"@salesforce/b2c-cli:packages/b2c-cli" \
"@salesforce/b2c-dx-mcp:packages/b2c-dx-mcp" \
"@salesforce/mrt-utilities:packages/mrt-utilities"; do
PKG_NAME="${spec%%:*}"
PKG_PATH="${spec##*:}"
LOCAL=$(node -p "require('./${PKG_PATH}/package.json').version")
NPM=$(npm view "$PKG_NAME" version 2>/dev/null || echo "0.0.0")
if [ "$LOCAL" != "$NPM" ]; then
HAS_CHANGES=true
break
fi
done
# Also check VS extension tag
if [ "$HAS_CHANGES" = "false" ]; then
VSX_VERSION=$(node -p "require('./packages/b2c-vs-extension/package.json').version")
LAST_VSX_TAG=$(git tag -l "b2c-vs-extension@*" --sort=-v:refname | grep -v '@latest$' | head -1 | sed 's/b2c-vs-extension@//')
if [ "$VSX_VERSION" != "$LAST_VSX_TAG" ]; then
HAS_CHANGES=true
fi
fi
# Also check docs tag
if [ "$HAS_CHANGES" = "false" ]; then
DOCS_VERSION=$(node -p "require('./docs/package.json').version")
if ! git rev-parse "docs@${DOCS_VERSION}" >/dev/null 2>&1; then
HAS_CHANGES=true
fi
fi
# Also check agent-plugins tag
if [ "$HAS_CHANGES" = "false" ]; then
PLUGINS_VERSION=$(node -p "require('./skills/package.json').version")
if ! git rev-parse "b2c-agent-plugins@${PLUGINS_VERSION}" >/dev/null 2>&1; then
HAS_CHANGES=true
fi
fi
if [ "$HAS_CHANGES" = "false" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "::notice::All package versions match npm — nothing to publish"
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Setup pnpm
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
- name: Setup Node.js
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: '22.22.1'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Upgrade npm for trusted publishing
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')
run: npm install -g npm@latest
- name: Install dependencies
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')
run: pnpm install --frozen-lockfile
- name: Determine packages to publish
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true'
id: packages
run: |
check_package() {
local pkg_name=$1
local pkg_path=$2
local output_key=$3
LOCAL_VERSION=$(node -p "require('./${pkg_path}/package.json').version")
NPM_VERSION=$(npm view "$pkg_name" version 2>/dev/null || echo "0.0.0")
echo "${pkg_name}: local=${LOCAL_VERSION} npm=${NPM_VERSION}"
if [ "$LOCAL_VERSION" != "$NPM_VERSION" ]; then
echo "publish_${output_key}=true" >> $GITHUB_OUTPUT
echo "version_${output_key}=${LOCAL_VERSION}" >> $GITHUB_OUTPUT
# Determine appropriate npm dist-tag via semver comparison
IS_NEWER=$(node -e "
const [a,b,c] = '${LOCAL_VERSION}'.split('.').map(Number);
const [x,y,z] = '${NPM_VERSION}'.split('.').map(Number);
console.log(a>x||(a===x&&(b>y||(b===y&&c>z))));
")
if [ "$IS_NEWER" = "true" ]; then
echo "tag_${output_key}=latest" >> $GITHUB_OUTPUT
else
MINOR=$(echo "$LOCAL_VERSION" | sed 's/\.[0-9]*$//')
echo "tag_${output_key}=release-${MINOR}" >> $GITHUB_OUTPUT
fi
else
echo "publish_${output_key}=false" >> $GITHUB_OUTPUT
fi
}
check_package "@salesforce/b2c-tooling-sdk" "packages/b2c-tooling-sdk" "sdk"
check_package "@salesforce/b2c-cli" "packages/b2c-cli" "cli"
check_package "@salesforce/b2c-dx-mcp" "packages/b2c-dx-mcp" "mcp"
check_package "@salesforce/mrt-utilities" "packages/mrt-utilities" "mrt"
# VS Code extension — compare against git tags (not npm)
LOCAL_VSX_VERSION=$(node -p "require('./packages/b2c-vs-extension/package.json').version")
LAST_VSX_TAG=$(git tag -l "b2c-vs-extension@*" --sort=-v:refname | grep -v '@latest$' | head -1 | sed 's/b2c-vs-extension@//')
echo "b2c-vs-extension: local=${LOCAL_VSX_VERSION} tag=${LAST_VSX_TAG:-none}"
if [ "$LOCAL_VSX_VERSION" != "$LAST_VSX_TAG" ]; then
echo "publish_vsx=true" >> $GITHUB_OUTPUT
echo "version_vsx=${LOCAL_VSX_VERSION}" >> $GITHUB_OUTPUT
else
echo "publish_vsx=false" >> $GITHUB_OUTPUT
fi
# Check if docs version changed (private package — not published to npm, uses git tag)
DOCS_VERSION=$(node -p "require('./docs/package.json').version")
if git rev-parse "docs@${DOCS_VERSION}" >/dev/null 2>&1; then
echo "publish_docs=false" >> $GITHUB_OUTPUT
else
echo "publish_docs=true" >> $GITHUB_OUTPUT
echo "version_docs=${DOCS_VERSION}" >> $GITHUB_OUTPUT
fi
echo "@salesforce/b2c-docs: version=${DOCS_VERSION}"
# Check if agent-plugins version changed (private package — uses git tag)
PLUGINS_VERSION=$(node -p "require('./skills/package.json').version")
if git rev-parse "b2c-agent-plugins@${PLUGINS_VERSION}" >/dev/null 2>&1; then
echo "publish_plugins=false" >> $GITHUB_OUTPUT
else
echo "publish_plugins=true" >> $GITHUB_OUTPUT
echo "version_plugins=${PLUGINS_VERSION}" >> $GITHUB_OUTPUT
fi
echo "@salesforce/b2c-agent-plugins: version=${PLUGINS_VERSION}"
- name: Create snapshot versions
if: steps.release-type.outputs.type == 'nightly'
run: |
SNAPSHOT="0.0.0-nightly.$(date +%Y%m%d%H%M%S)"
for pkg in packages/b2c-tooling-sdk packages/b2c-cli packages/b2c-dx-mcp packages/mrt-utilities; do
node -e "
const fs = require('fs');
const path = '$pkg/package.json';
const pkg = JSON.parse(fs.readFileSync(path));
pkg.version = '$SNAPSHOT';
fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n');
"
done
echo "Set snapshot version: $SNAPSHOT"
- name: Build packages
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')
run: pnpm run build
- name: Run tests
if: steps.release-type.outputs.type == 'nightly' || (steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true')
run: pnpm --filter '!b2c-vs-extension' run test
- name: Publish SDK to npm
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_sdk == 'true'
id: publish-sdk
continue-on-error: true
run: >-
pnpm --filter @salesforce/b2c-tooling-sdk publish --provenance --no-git-checks
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_sdk }}
- name: Publish CLI to npm
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_cli == 'true'
id: publish-cli
continue-on-error: true
run: >-
pnpm --filter @salesforce/b2c-cli publish --provenance --no-git-checks
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_cli }}
- name: Publish MCP to npm
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_mcp == 'true'
id: publish-mcp
continue-on-error: true
run: >-
pnpm --filter @salesforce/b2c-dx-mcp publish --provenance --no-git-checks
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_mcp }}
- name: Publish MRT Utilities to npm
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_mrt == 'true'
id: publish-mrt
continue-on-error: true
run: >-
pnpm --filter @salesforce/mrt-utilities publish --provenance --no-git-checks
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_mrt }}
- name: Package VS Code extension
if: steps.release-type.outputs.type == 'stable' && steps.packages.outputs.publish_vsx == 'true'
working-directory: packages/b2c-vs-extension
run: pnpm run package
- name: Create git tags
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
TAGS_CREATED=""
if [[ "${{ steps.packages.outputs.publish_sdk }}" == "true" ]]; then
TAG="@salesforce/b2c-tooling-sdk@${{ steps.packages.outputs.version_sdk }}"
git tag "$TAG"
TAGS_CREATED="$TAGS_CREATED $TAG"
fi
if [[ "${{ steps.packages.outputs.publish_cli }}" == "true" ]]; then
TAG="@salesforce/b2c-cli@${{ steps.packages.outputs.version_cli }}"
git tag "$TAG"
TAGS_CREATED="$TAGS_CREATED $TAG"
fi
if [[ "${{ steps.packages.outputs.publish_mcp }}" == "true" ]]; then
TAG="@salesforce/b2c-dx-mcp@${{ steps.packages.outputs.version_mcp }}"
git tag "$TAG"
TAGS_CREATED="$TAGS_CREATED $TAG"
fi
if [[ "${{ steps.packages.outputs.publish_mrt }}" == "true" ]]; then
TAG="@salesforce/mrt-utilities@${{ steps.packages.outputs.version_mrt }}"
git tag "$TAG"
TAGS_CREATED="$TAGS_CREATED $TAG"
fi
if [[ "${{ steps.packages.outputs.publish_vsx }}" == "true" ]]; then
TAG="b2c-vs-extension@${{ steps.packages.outputs.version_vsx }}"
git tag "$TAG"
TAGS_CREATED="$TAGS_CREATED $TAG"
fi
if [ -n "$TAGS_CREATED" ]; then
git push origin $TAGS_CREATED
echo "Created tags:$TAGS_CREATED"
else
echo "No tags to create"
fi
- name: Update b2c-vs-extension@latest tag
if: steps.release-type.outputs.type == 'stable' && steps.packages.outputs.publish_vsx == 'true'
run: |
git tag -f b2c-vs-extension@latest
git push origin b2c-vs-extension@latest --force
echo "Updated b2c-vs-extension@latest tag to $(git rev-parse HEAD)"
- name: Update v1 Actions tag
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true'
run: |
git tag -f v1
git push origin v1 --force
echo "Updated v1 tag to $(git rev-parse HEAD)"
- name: Create docs tag if version changed
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true' && steps.packages.outputs.publish_docs == 'true'
run: |
DOCS_TAG="docs@${{ steps.packages.outputs.version_docs }}"
git tag "$DOCS_TAG"
git push origin "$DOCS_TAG"
echo "Created docs tag: $DOCS_TAG"
- name: Extract changelogs for release
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true'
run: |
# Function to extract the latest version section from a changelog
extract_latest() {
awk '
/^## / { if (found) exit; found=1; next }
found { print }
' "$1"
}
# Build combined release notes for published packages
{
if [[ "${{ steps.packages.outputs.publish_cli }}" == "true" ]]; then
echo "## @salesforce/b2c-cli@${{ steps.packages.outputs.version_cli }}"
echo ""
extract_latest packages/b2c-cli/CHANGELOG.md
echo ""
fi
if [[ "${{ steps.packages.outputs.publish_mcp }}" == "true" ]]; then
echo "## @salesforce/b2c-dx-mcp@${{ steps.packages.outputs.version_mcp }}"
echo ""
extract_latest packages/b2c-dx-mcp/CHANGELOG.md
echo ""
fi
if [[ "${{ steps.packages.outputs.publish_sdk }}" == "true" ]]; then
echo "## @salesforce/b2c-tooling-sdk@${{ steps.packages.outputs.version_sdk }}"
echo ""
extract_latest packages/b2c-tooling-sdk/CHANGELOG.md
echo ""
fi
if [[ "${{ steps.packages.outputs.publish_mrt }}" == "true" ]]; then
echo "## @salesforce/mrt-utilities@${{ steps.packages.outputs.version_mrt }}"
echo ""
extract_latest packages/mrt-utilities/CHANGELOG.md
echo ""
fi
if [[ "${{ steps.packages.outputs.publish_vsx }}" == "true" ]]; then
echo "## b2c-vs-extension@${{ steps.packages.outputs.version_vsx }}"
echo ""
extract_latest packages/b2c-vs-extension/CHANGELOG.md
echo ""
fi
if [[ "${{ steps.packages.outputs.publish_docs }}" == "true" && -f docs/CHANGELOG.md ]]; then
echo "## Documentation"
echo ""
extract_latest docs/CHANGELOG.md
echo ""
fi
if [[ "${{ steps.packages.outputs.publish_plugins }}" == "true" && -f skills/CHANGELOG.md ]]; then
echo "## Agent Skills Plugins"
echo ""
extract_latest skills/CHANGELOG.md
echo ""
fi
} > /tmp/release-notes.md
- name: Create GitHub Release
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true'
run: |
# Determine the release tag — prefer CLI as the user-facing product.
# Plugins and VSX get their own dedicated releases, so they are excluded here.
if [[ "${{ steps.packages.outputs.publish_cli }}" == "true" ]]; then
RELEASE_TAG="@salesforce/b2c-cli@${{ steps.packages.outputs.version_cli }}"
elif [[ "${{ steps.packages.outputs.publish_sdk }}" == "true" ]]; then
RELEASE_TAG="@salesforce/b2c-tooling-sdk@${{ steps.packages.outputs.version_sdk }}"
elif [[ "${{ steps.packages.outputs.publish_mcp }}" == "true" ]]; then
RELEASE_TAG="@salesforce/b2c-dx-mcp@${{ steps.packages.outputs.version_mcp }}"
elif [[ "${{ steps.packages.outputs.publish_mrt }}" == "true" ]]; then
RELEASE_TAG="@salesforce/mrt-utilities@${{ steps.packages.outputs.version_mrt }}"
elif [[ "${{ steps.packages.outputs.publish_docs }}" == "true" ]]; then
RELEASE_TAG="docs@${{ steps.packages.outputs.version_docs }}"
else
echo "No non-VSX/non-plugins packages published, skipping main release"
exit 0
fi
# Build a human-readable title from published package versions
TITLE_PARTS=()
[[ "${{ steps.packages.outputs.publish_cli }}" == "true" ]] && TITLE_PARTS+=("b2c-cli ${{ steps.packages.outputs.version_cli }}")
[[ "${{ steps.packages.outputs.publish_sdk }}" == "true" ]] && TITLE_PARTS+=("b2c-tooling-sdk ${{ steps.packages.outputs.version_sdk }}")
[[ "${{ steps.packages.outputs.publish_mcp }}" == "true" ]] && TITLE_PARTS+=("b2c-dx-mcp ${{ steps.packages.outputs.version_mcp }}")
[[ "${{ steps.packages.outputs.publish_mrt }}" == "true" ]] && TITLE_PARTS+=("mrt-utilities ${{ steps.packages.outputs.version_mrt }}")
[[ "${{ steps.packages.outputs.publish_vsx }}" == "true" ]] && TITLE_PARTS+=("b2c-vs-extension ${{ steps.packages.outputs.version_vsx }}")
[[ "${{ steps.packages.outputs.publish_docs }}" == "true" ]] && TITLE_PARTS+=("docs ${{ steps.packages.outputs.version_docs }}")
RELEASE_TITLE="Version Packages — $(IFS=', '; echo "${TITLE_PARTS[*]}")"
gh release create "$RELEASE_TAG" --title "$RELEASE_TITLE" --notes-file /tmp/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Package skills artifacts
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true' && steps.packages.outputs.publish_plugins == 'true'
run: |
# Create b2c-skills.zip containing skills/b2c/skills/
cd skills/b2c && zip -r ../../b2c-skills.zip skills/
cd ../..
# Create b2c-cli-skills.zip containing skills/b2c-cli/skills/
cd skills/b2c-cli && zip -r ../../b2c-cli-skills.zip skills/
cd ../..
# Create storefront-next-skills.zip containing skills/storefront-next/skills/
cd skills/storefront-next && zip -r ../../storefront-next-skills.zip skills/
cd ../..
echo "Created skills artifacts:"
ls -la *.zip
- name: Upload skills to release
if: steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true' && steps.packages.outputs.publish_plugins == 'true'
run: |
RELEASE_TAG="b2c-agent-plugins@${{ steps.packages.outputs.version_plugins }}"
gh release create "$RELEASE_TAG" \
--title "Agent Plugins ${{ steps.packages.outputs.version_plugins }}" \
--notes "Skills artifacts for b2c-agent-plugins v${{ steps.packages.outputs.version_plugins }}"
gh release upload "$RELEASE_TAG" b2c-skills.zip b2c-cli-skills.zip storefront-next-skills.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create VS Code extension release
if: >-
steps.release-type.outputs.type == 'stable'
&& steps.packages.outputs.publish_vsx == 'true'
run: |
VSX_TAG="b2c-vs-extension@${{ steps.packages.outputs.version_vsx }}"
VSX_VERSION="${{ steps.packages.outputs.version_vsx }}"
# Extract extension changelog for the dedicated release
extract_latest() {
awk '
/^## / { if (found) exit; found=1; next }
found { print }
' "$1"
}
VSX_CHANGELOG=$(extract_latest packages/b2c-vs-extension/CHANGELOG.md)
{
cat <<HEADER
## B2C DX VS Code Extension v${VSX_VERSION}
Download the \`.vsix\` file below and install via:
\`\`\`
code --install-extension b2c-vs-extension-${VSX_VERSION}.vsix
\`\`\`
Or in VS Code: Extensions → ⋯ → Install from VSIX...
---
### Changelog
HEADER
echo "$VSX_CHANGELOG"
} | sed 's/^ //' > /tmp/vsx-release-notes.md
# Create a dedicated release for the extension (not latest — main releases own that)
# Use --clobber on upload in case a previous run partially completed
if gh release view "$VSX_TAG" >/dev/null 2>&1; then
echo "Release $VSX_TAG already exists, uploading VSIX to it"
gh release upload "$VSX_TAG" packages/b2c-vs-extension/*.vsix --clobber
else
gh release create "$VSX_TAG" \
--title "VS Code Extension ${VSX_VERSION}" \
--latest=false \
--notes-file /tmp/vsx-release-notes.md
gh release upload "$VSX_TAG" packages/b2c-vs-extension/*.vsix
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger documentation deployment
if: >-
steps.release-type.outputs.type == 'stable' && steps.changesets.outputs.skip != 'true' && steps.quick-check.outputs.skip != 'true'
&& (steps.packages.outputs.tag_cli == 'latest' || steps.packages.outputs.tag_sdk == 'latest' || steps.packages.outputs.tag_mcp == 'latest' || steps.packages.outputs.publish_docs == 'true')
run: gh workflow run deploy-docs.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR to merge version bumps back to main
if: github.event_name == 'workflow_run'
run: |
if [[ "${{ steps.packages.outputs.publish_sdk }}" == "true" ]] || \
[[ "${{ steps.packages.outputs.publish_cli }}" == "true" ]] || \
[[ "${{ steps.packages.outputs.publish_mcp }}" == "true" ]] || \
[[ "${{ steps.packages.outputs.publish_mrt }}" == "true" ]] || \
[[ "${{ steps.packages.outputs.publish_docs }}" == "true" ]]; then
BRANCH="${{ github.event.workflow_run.head_branch }}"
gh pr create --base main --head "$BRANCH" \
--title "Merge version bumps from ${BRANCH}" \
--body "$(cat <<'EOF'
Auto-created after release branch publish from `'"${BRANCH}"'`.
Merges version bump commits back to main to prevent version collisions on the next regular release.
**Review checklist:**
- [ ] Version bumps in package.json files look correct
- [ ] CHANGELOG entries are accurate
- [ ] No merge conflicts with pending changesets on main
EOF
)" || echo "::warning::PR already exists or could not be created"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail if any publish failed
if: always() && (steps.publish-sdk.outcome == 'failure' || steps.publish-cli.outcome == 'failure' || steps.publish-mcp.outcome == 'failure' || steps.publish-mrt.outcome == 'failure')
run: |
echo "::error::One or more npm publishes failed:"
[[ "${{ steps.publish-sdk.outcome }}" == "failure" ]] && echo " - SDK"
[[ "${{ steps.publish-cli.outcome }}" == "failure" ]] && echo " - CLI"
[[ "${{ steps.publish-mcp.outcome }}" == "failure" ]] && echo " - MCP"
[[ "${{ steps.publish-mrt.outcome }}" == "failure" ]] && echo " - MRT"
exit 1