Skip to content

Commit 60d2322

Browse files
committed
docs and publish protection
1 parent b324de6 commit 60d2322

2 files changed

Lines changed: 24 additions & 33 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Deploy Documentation
22

33
on:
4-
push:
5-
branches: [main]
64
workflow_dispatch:
75

86
permissions:
@@ -52,14 +50,9 @@ jobs:
5250
- name: Get latest release tag
5351
id: release
5452
run: |
55-
# Find the most recent package tag and docs tag by creation date.
56-
# This is safe because only @latest publishes and doc-only releases
57-
# trigger this workflow — maintenance patches on older minors are
58-
# excluded by the publish workflow gate.
5953
PKG_TAG=$(git tag --list '@salesforce/*' --sort=-creatordate | head -n1)
6054
DOCS_TAG=$(git tag --list 'docs@*' --sort=-creatordate | head -n1)
6155
62-
# Pick whichever tag was created more recently
6356
LATEST_TAG=""
6457
if [[ -n "$PKG_TAG" && -n "$DOCS_TAG" ]]; then
6558
LATEST_TAG=$(git tag --list '@salesforce/*' --list 'docs@*' --sort=-creatordate | head -n1)
@@ -69,58 +62,38 @@ jobs:
6962
LATEST_TAG="$DOCS_TAG"
7063
fi
7164
72-
echo "Latest package tag: ${PKG_TAG:-<none>}"
73-
echo "Latest docs tag: ${DOCS_TAG:-<none>}"
74-
echo "Building stable docs from: ${LATEST_TAG:-<none>}"
75-
65+
echo "Building docs from: ${LATEST_TAG:-<none>}"
7666
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
77-
echo "exists=$([[ -n $LATEST_TAG ]] && echo true || echo false)" >> $GITHUB_OUTPUT
78-
79-
- name: Build dev documentation
80-
run: |
81-
IS_DEV_BUILD=true pnpm run docs:build
82-
mv docs/.vitepress/dist docs/.vitepress/dist-dev
8367
84-
- name: Build stable documentation from release tag
85-
if: steps.release.outputs.exists == 'true'
68+
- name: Build documentation from release tag
8669
run: |
87-
# Save docs build files from main (config has version dropdown/dynamic
88-
# base path, and package.json/lockfile have its dependencies)
70+
# Save config and deps from main (has version dropdown and latest dependencies)
8971
cp docs/.vitepress/config.mts /tmp/config.mts
9072
cp docs/package.json /tmp/docs-package.json
9173
cp pnpm-lock.yaml /tmp/pnpm-lock.yaml
9274
9375
# Remove S3-extracted uxstudio files before checkout to avoid conflicts
94-
# (older tags still have these files tracked in git)
9576
rm -rf docs/public/uxstudio
9677
9778
# Checkout release tag
9879
git checkout ${{ steps.release.outputs.tag }}
9980
100-
# Ensure UX Studio artifacts are present (older tags have them in git,
101-
# future tags won't — always extract from S3 to be safe)
81+
# Restore UX Studio artifacts
10282
rm -rf docs/public/uxstudio
10383
mkdir -p docs/public/uxstudio
10484
tar -xzf /tmp/uxstudio-4.5.tar.gz -C docs/public/uxstudio
10585
tar -xzf /tmp/uxstudio-4.6.tar.gz -C docs/public/uxstudio
10686
107-
# Restore docs build files from main so dependencies match the config
87+
# Restore config and deps from main
10888
cp /tmp/config.mts docs/.vitepress/config.mts
10989
cp /tmp/docs-package.json docs/package.json
11090
cp /tmp/pnpm-lock.yaml pnpm-lock.yaml
11191
112-
# Build at release tag with main's config (no IS_DEV_BUILD = stable at root)
92+
# Build docs
11393
pnpm install --frozen-lockfile
11494
pnpm -r run build
11595
pnpm run docs:build
11696
117-
# Combine: stable at root, dev in /dev/
118-
mv docs/.vitepress/dist-dev docs/.vitepress/dist/dev
119-
120-
- name: Use dev as root when no release exists
121-
if: steps.release.outputs.exists != 'true'
122-
run: mv docs/.vitepress/dist-dev docs/.vitepress/dist
123-
12497
- name: Upload artifact
12598
uses: actions/upload-pages-artifact@v4
12699
with:

.github/workflows/publish.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,24 +226,32 @@ jobs:
226226

227227
- name: Publish SDK to npm
228228
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_sdk == 'true'
229+
id: publish-sdk
230+
continue-on-error: true
229231
run: >-
230232
pnpm --filter @salesforce/b2c-tooling-sdk publish --provenance --no-git-checks
231233
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_sdk }}
232234
233235
- name: Publish CLI to npm
234236
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_cli == 'true'
237+
id: publish-cli
238+
continue-on-error: true
235239
run: >-
236240
pnpm --filter @salesforce/b2c-cli publish --provenance --no-git-checks
237241
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_cli }}
238242
239243
- name: Publish MCP to npm
240244
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_mcp == 'true'
245+
id: publish-mcp
246+
continue-on-error: true
241247
run: >-
242248
pnpm --filter @salesforce/b2c-dx-mcp publish --provenance --no-git-checks
243249
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_mcp }}
244250
245251
- name: Publish MRT Utilities to npm
246252
if: steps.release-type.outputs.type == 'nightly' || steps.packages.outputs.publish_mrt == 'true'
253+
id: publish-mrt
254+
continue-on-error: true
247255
run: >-
248256
pnpm --filter @salesforce/mrt-utilities publish --provenance --no-git-checks
249257
--tag ${{ steps.release-type.outputs.type == 'nightly' && 'nightly' || steps.packages.outputs.tag_mrt }}
@@ -536,3 +544,13 @@ jobs:
536544
fi
537545
env:
538546
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
547+
548+
- name: Fail if any publish failed
549+
if: always() && (steps.publish-sdk.outcome == 'failure' || steps.publish-cli.outcome == 'failure' || steps.publish-mcp.outcome == 'failure' || steps.publish-mrt.outcome == 'failure')
550+
run: |
551+
echo "::error::One or more npm publishes failed:"
552+
[[ "${{ steps.publish-sdk.outcome }}" == "failure" ]] && echo " - SDK"
553+
[[ "${{ steps.publish-cli.outcome }}" == "failure" ]] && echo " - CLI"
554+
[[ "${{ steps.publish-mcp.outcome }}" == "failure" ]] && echo " - MCP"
555+
[[ "${{ steps.publish-mrt.outcome }}" == "failure" ]] && echo " - MRT"
556+
exit 1

0 commit comments

Comments
 (0)