Skip to content

Commit fe31555

Browse files
committed
fix: use highest semver tag for stable docs, not most recent
The deploy-docs workflow previously picked the release tag with the most recent creation date. A maintenance patch on an older minor (e.g. 0.4.3 after 0.5.0) would cause stable docs to regress to that older codebase. Switch to sorting by semver version so stable docs always reflect the latest release line.
1 parent 0a7c204 commit fe31555

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,35 @@ jobs:
5454
- name: Get latest release tag
5555
id: release
5656
run: |
57-
# Find the most recent package tag and docs tag across all branches
58-
# (git describe only finds ancestor tags; git tag --list finds all)
59-
PKG_TAG=$(git tag --list '@salesforce/*' --sort=-creatordate | head -n1)
60-
DOCS_TAG=$(git tag --list 'docs@*' --sort=-creatordate | head -n1)
61-
62-
# Pick whichever tag was created most recently
57+
# Find the highest-versioned package tag and docs tag (by semver, not
58+
# creation date) so that maintenance patches on older minors never
59+
# cause stable docs to regress to an older codebase.
60+
pick_highest() {
61+
node -e "
62+
const lines = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n').filter(Boolean);
63+
const parsed = lines.map(tag => {
64+
const ver = tag.split('@').pop();
65+
const [major, minor, patch] = ver.split('.').map(Number);
66+
return { tag, major, minor, patch };
67+
}).filter(t => !isNaN(t.major));
68+
parsed.sort((a, b) => b.major - a.major || b.minor - a.minor || b.patch - a.patch);
69+
if (parsed.length) console.log(parsed[0].tag);
70+
"
71+
}
72+
73+
PKG_TAG=$(git tag --list '@salesforce/*' | pick_highest)
74+
DOCS_TAG=$(git tag --list 'docs@*' | pick_highest)
75+
76+
# Pick whichever tag has the higher semver version
6377
LATEST_TAG=""
6478
if [[ -n "$PKG_TAG" && -n "$DOCS_TAG" ]]; then
65-
PKG_TS=$(git for-each-ref --format='%(creatordate:unix)' "refs/tags/${PKG_TAG}")
66-
DOCS_TS=$(git for-each-ref --format='%(creatordate:unix)' "refs/tags/${DOCS_TAG}")
67-
if [[ "$DOCS_TS" -ge "$PKG_TS" ]]; then
68-
LATEST_TAG="$DOCS_TAG"
69-
else
70-
LATEST_TAG="$PKG_TAG"
71-
fi
79+
WINNER=$(node -e "
80+
const a = '${PKG_TAG}'.split('@').pop().split('.').map(Number);
81+
const b = '${DOCS_TAG}'.split('@').pop().split('.').map(Number);
82+
const cmp = a[0]-b[0] || a[1]-b[1] || a[2]-b[2];
83+
console.log(cmp >= 0 ? '${PKG_TAG}' : '${DOCS_TAG}');
84+
")
85+
LATEST_TAG="$WINNER"
7286
elif [[ -n "$PKG_TAG" ]]; then
7387
LATEST_TAG="$PKG_TAG"
7488
elif [[ -n "$DOCS_TAG" ]]; then

PUBLISHING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ The documentation site serves two versions:
152152
- **Stable** (root URL) — built from the most recent release tag (across all branches)
153153
- **Dev** (`/dev/`) — built from `main`, updated on every push
154154

155-
Stable docs are rebuilt after every stable or release branch publish. The `deploy-docs.yml` workflow finds the most recent release tag by creation date across all branches, so tags from release branches are picked up automatically.
155+
Stable docs are rebuilt after every stable or release branch publish. The `deploy-docs.yml` workflow builds from the highest semver release tag, so stable docs always reflect the latest release line. Maintenance patches on older minors do not affect stable docs.
156156

157157
## Local Testing
158158

0 commit comments

Comments
 (0)