Repository navigation
Moved release automation from Ghost-Release into Ghost monorepo - #26760
Conversation
🤖 Velo CI Failure AnalysisClassification: 🔴 HARD FAIL
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26760 +/- ##
==========================================
- Coverage 73.27% 73.25% -0.03%
==========================================
Files 1530 1530
Lines 121732 121761 +29
Branches 14706 14706
==========================================
- Hits 89203 89199 -4
- Misses 31514 31545 +31
- Partials 1015 1017 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ff85320 to
f56135f
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughGitHub Actions workflows were changed to detect semantic-version tag pushes and set an IS_TAG flag so many lint/test/E2E jobs skip on tag runs. The Docker build job was replaced by Build & Publish Artifacts which verifies tag↔ghost/core/package.json alignment, produces/uploads an npm tarball, and adjusts Docker publish/tagging for tags. New tag-only jobs publish the tarball to npm via OIDC and create a GitHub Release with Slack notification. release.yml was converted to a scheduled/manual workflow invoking scripts/release.js. New release tooling and helpers, tests, ESLint for scripts, and package.json/pack changes were added. 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f56135f to
721617e
Compare
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (3)
.github/workflows/ci.yml (2)
1751-1766: Slack notification should handle missing webhook gracefully.The
|| echo "Slack notification failed (non-fatal)"fallback is good, but ifRELEASE_NOTIFICATION_URLis empty or unset,curlmay behave unexpectedly. Consider adding explicit validation.🛡️ Optional: Guard against missing webhook URL
- name: Notify Slack if: always() && steps.notes.outcome == 'success' run: | + if [ -z "${{ secrets.RELEASE_NOTIFICATION_URL }}" ]; then + echo "::warning::RELEASE_NOTIFICATION_URL not configured, skipping Slack notification" + exit 0 + fi + VERSION="${GITHUB_REF_NAME}" RELEASE_URL="https://github.com/TryGhost/Ghost/releases/tag/${VERSION}" CHANGELOG=$(cat /tmp/release-notes.md | head -c 3000)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml around lines 1751 - 1766, The Slack notify step should validate the webhook URL before calling curl; update the "Notify Slack" step to check the RELEASE_NOTIFICATION_URL secret (the variable used in the curl call) is set and non-empty and if missing skip the curl and echo a clear warning (e.g., "Slack webhook not configured, skipping notification") instead of invoking curl with an empty URL; keep the existing PAYLOAD/JQ generation (PAYLOAD, CHANGELOG, VERSION, RELEASE_URL) but gate the curl invocation on the presence of RELEASE_NOTIFICATION_URL to fail-safe the workflow.
1730-1737: Previous tag resolution may miss tags on divergent branches.The
git tag --list ... --sort=-version:refnameapproach lists tags globally sorted by version, not by ancestry from the current tag. If tags were created out-of-order or on different branches, this could resolve to an unexpected "previous" tag.Consider using
git describe --tags --abbrev=0 --match 'v[0-9]*' --exclude 'v*-*' "${GITHUB_REF_NAME}^"to find the most recent stable tag reachable from the parent of the current tag, ensuring it respects commit ancestry.♻️ Suggested improvement for ancestor-aware tag resolution
- name: Resolve previous tag id: prev_tag run: | CURRENT_TAG="${GITHUB_REF_NAME}" - # Find the tag immediately before this one (excluding pre-releases) - PREV_TAG=$(git tag --list 'v[0-9]*' --sort=-version:refname | grep -v '-' | grep -v "^${CURRENT_TAG}$" | head -n 1) + # Find the most recent stable tag reachable from the parent of this tag + PREV_TAG=$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' --exclude 'v*-*' "${CURRENT_TAG}^" 2>/dev/null || echo "") + if [ -z "$PREV_TAG" ]; then + echo "::warning::No previous stable tag found; release notes will be empty" + fi echo "tag=${PREV_TAG}" >> "$GITHUB_OUTPUT" echo "Previous tag: ${PREV_TAG}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml around lines 1730 - 1737, The current PREV_TAG resolution using the global sort (variables CURRENT_TAG and PREV_TAG in the step with id prev_tag) can pick tags not ancestored by the current tag; replace the git tag pipeline with an ancestor-aware command such as using git describe --tags --abbrev=0 --match 'v[0-9]*' --exclude 'v*-*' "${CURRENT_TAG}^" to find the most recent stable tag reachable from the parent of the current tag, and add a safe fallback (empty or explicit message) if git describe fails so the step still sets GITHUB_OUTPUT consistently; ensure you update the step that echoes "tag=${PREV_TAG}" to use the new PREV_TAG value..github/workflows/release.yml (1)
57-72: Consider consolidating environment variable setup.The two steps for setting up schedule defaults and workflow_dispatch inputs could be combined into a single step with conditional logic, reducing duplication. However, the current approach is clear and works correctly.
♻️ Optional: Consolidate env setup into one step
- - name: Set up schedule defaults - if: github.event_name == 'schedule' - run: | - echo "RELEASE_BRANCH=main" >> "$GITHUB_ENV" - echo "RELEASE_BUMP_TYPE=auto" >> "$GITHUB_ENV" - echo "RELEASE_DRY_RUN=" >> "$GITHUB_ENV" - echo "RELEASE_SKIP_CHECKS=" >> "$GITHUB_ENV" - - - name: Set up workflow_dispatch inputs - if: github.event_name == 'workflow_dispatch' - run: | - echo "RELEASE_BRANCH=${{ inputs.branch }}" >> "$GITHUB_ENV" - echo "RELEASE_BUMP_TYPE=${{ inputs.bump-type }}" >> "$GITHUB_ENV" - echo "RELEASE_DRY_RUN=${{ inputs.dry-run }}" >> "$GITHUB_ENV" - echo "RELEASE_SKIP_CHECKS=${{ inputs.skip-checks }}" >> "$GITHUB_ENV" + - name: Set up release parameters + run: | + if [ "${{ github.event_name }}" = "schedule" ]; then + echo "RELEASE_BRANCH=main" >> "$GITHUB_ENV" + echo "RELEASE_BUMP_TYPE=auto" >> "$GITHUB_ENV" + echo "RELEASE_DRY_RUN=" >> "$GITHUB_ENV" + echo "RELEASE_SKIP_CHECKS=" >> "$GITHUB_ENV" + else + echo "RELEASE_BRANCH=${{ inputs.branch }}" >> "$GITHUB_ENV" + echo "RELEASE_BUMP_TYPE=${{ inputs.bump-type }}" >> "$GITHUB_ENV" + echo "RELEASE_DRY_RUN=${{ inputs.dry-run }}" >> "$GITHUB_ENV" + echo "RELEASE_SKIP_CHECKS=${{ inputs.skip-checks }}" >> "$GITHUB_ENV" + fi🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 57 - 72, Duplicate environment setup exists across the two job steps named "Set up schedule defaults" and "Set up workflow_dispatch inputs"; consolidate them into a single step that sets RELEASE_BRANCH, RELEASE_BUMP_TYPE, RELEASE_DRY_RUN, and RELEASE_SKIP_CHECKS and uses conditional logic on github.event_name to decide whether to use hard-coded defaults or the workflow_dispatch inputs (inputs.branch, inputs.bump-type, inputs.dry-run, inputs.skip-checks), so you remove the duplicated echo lines and centralize env export while preserving the same variable names and behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/lib/release-notes.js`:
- Around line 36-40: The regex in extractCommitMessage rejects authors with
hyphens because it uses [^-]+$ for the author; update the pattern to capture the
commit message non-greedily and allow any characters for the author so the first
" - " is used as the separator (e.g., change the regex in extractCommitMessage
to use a non-greedy message capture like (.+?) and an author capture like
(.+)$), then return match[1].trim() as before; this ensures names like
"Mary-Jane Watson" no longer break the match.
- Around line 48-57: The emoji sort in emojiLines.sort currently computes
(indexB - indexA) and treats unknown emojis as -Infinity, which inverts the
documented priority and produces NaN when both are unknown; update the
comparator to compute orderA and orderB from EMOJI_ORDER (using indexA =
EMOJI_ORDER.indexOf(emojiA) and indexB = EMOJI_ORDER.indexOf(emojiB)), map
unknown indices (-1) to Infinity so they sort last, then return orderA - orderB
so lower indices (higher priority per EMOJI_ORDER) come first, and return 0 for
equal orders to preserve original order; references: emojiLines.sort,
extractCommitMessage, LEADING_EMOJI_RE, EMOJI_ORDER.
In `@scripts/release.js`:
- Around line 291-299: The release script's --dry-run currently only skips
pushes but still mutates the working tree; change the logic so all mutating
steps are skipped when opts.dryRun is true (or rename the flag to --skip-push if
you prefer the current behavior). Concretely, wrap calls that mutate the
repo—updateThemeSubmodule(CASPER_DIR,...), updateThemeSubmodule(SOURCE_DIR,...),
any package rewrite routines (e.g. rewritePackageFiles / functions that update
package.json), createReleaseCommit / tag creation, and createRCCommit—behind a
conditional that checks opts.dryRun (or opts.skipPush) and only runs them when
false; keep logStep and non-mutating checks outside so the script reports
actions but does not change the checkout during a dry run.
- Around line 209-223: The git checkout logic can pick the newest tagged commit
rather than the highest stable semver and also never fetches remote tags; update
the flow in the release script so you first run a fetch of tags (e.g., git fetch
--tags) before any tag resolution, then enumerate remote tags and select the
highest non-prerelease semver tag (exclude tags that contain prerelease
identifiers) instead of using git describe on the newest commit; implement this
by replacing the git describe checkout step with code that lists tags (git tag
-l --sort=-v:refname or fetch tags and use the semver module to parse/sort/tag
names) and then checkout the chosen stable tag, ensuring the chosen tag is
guaranteed to be > currentVersion before proceeding (references: the git
checkout command currently used, and the variables updatedPkg/newVersion and
currentVersion).
- Around line 272-280: The catch block around the run(`git ls-remote --tags
origin refs/tags/v${newVersion}`) call is currently swallowing all errors;
change it to re-throw connectivity/auth errors and only treat the specific "tag
not found" message as expected. In the catch for the run(...) call (the block
that currently has the comment about ls-remote returning non-zero), inspect the
thrown error's stderr/message (and status if present) and: if it indicates
"fatal: couldn't find remote ref" / "no matching" / "remote ref not found" (the
git message when the tag is absent) then swallow and continue, otherwise
re-throw the error so network/auth/origin connectivity failures surface
immediately; keep references to newVersion and tagCheck unchanged. Ensure you
still exit with code 1 when tagCheck returns truthy as before.
- Around line 138-175: The fetch of GitHub check-runs in scripts/release.js must
handle pagination and avoid hard-failing on potentially-empty first-page
results: modify the request logic that calls fetch(...) for the
/commits/${commit}/check-runs to iterate pages (use per_page up to 100 and loop
over page=1..N while collecting check_runs into the existing checkRuns array)
until no more results or the Link header indicates last page; then apply the
existing filtering loop over the aggregated checkRuns (the for...of run loop) to
set pending/failed. Also relax the current throw on an empty checkRuns (where it
currently does throw new Error('No checks found for this commit')) to treat an
empty initial response as "pending" or retry a few times before failing to avoid
race conditions. Ensure you preserve skipping logic for release/stale/[Optional]
names and skipped successes in the same loop.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 1751-1766: The Slack notify step should validate the webhook URL
before calling curl; update the "Notify Slack" step to check the
RELEASE_NOTIFICATION_URL secret (the variable used in the curl call) is set and
non-empty and if missing skip the curl and echo a clear warning (e.g., "Slack
webhook not configured, skipping notification") instead of invoking curl with an
empty URL; keep the existing PAYLOAD/JQ generation (PAYLOAD, CHANGELOG, VERSION,
RELEASE_URL) but gate the curl invocation on the presence of
RELEASE_NOTIFICATION_URL to fail-safe the workflow.
- Around line 1730-1737: The current PREV_TAG resolution using the global sort
(variables CURRENT_TAG and PREV_TAG in the step with id prev_tag) can pick tags
not ancestored by the current tag; replace the git tag pipeline with an
ancestor-aware command such as using git describe --tags --abbrev=0 --match
'v[0-9]*' --exclude 'v*-*' "${CURRENT_TAG}^" to find the most recent stable tag
reachable from the parent of the current tag, and add a safe fallback (empty or
explicit message) if git describe fails so the step still sets GITHUB_OUTPUT
consistently; ensure you update the step that echoes "tag=${PREV_TAG}" to use
the new PREV_TAG value.
In @.github/workflows/release.yml:
- Around line 57-72: Duplicate environment setup exists across the two job steps
named "Set up schedule defaults" and "Set up workflow_dispatch inputs";
consolidate them into a single step that sets RELEASE_BRANCH, RELEASE_BUMP_TYPE,
RELEASE_DRY_RUN, and RELEASE_SKIP_CHECKS and uses conditional logic on
github.event_name to decide whether to use hard-coded defaults or the
workflow_dispatch inputs (inputs.branch, inputs.bump-type, inputs.dry-run,
inputs.skip-checks), so you remove the duplicated echo lines and centralize env
export while preserving the same variable names and behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7cc12396-fa0d-41ae-bdde-bd800e91957e
📒 Files selected for processing (10)
.github/workflows/ci.yml.github/workflows/deploy-to-staging.yml.github/workflows/pr-preview.yml.github/workflows/release.ymlghost/core/package.jsonpackage.jsonscripts/lib/release-notes.jsscripts/lib/resolve-base-tag.jsscripts/release.jsscripts/test/resolve-base-tag.test.js
721617e to
e51cf4a
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release.yml:
- Around line 86-92: The "Notify on failure" workflow step currently uses the
mutable ref tryghost/actions/actions/slack-build@main; replace that with a full
immutable commit SHA for the slack-build action (update the uses value to
tryghost/actions/actions/slack-build@<COMMIT_SHA>) so the workflow cannot be
hijacked to access secrets; ensure you copy the exact commit SHA from the action
repo’s commit history and keep the rest of the step (status input and
SLACK_WEBHOOK_URL secret) unchanged.
- Around line 28-35: Add a workflow-level concurrency guard to prevent
overlapping runs: add a top-level concurrency block (outside jobs) with a unique
group name such as "release-${{ github.ref }}-${{ github.event_name }}" and set
cancel-in-progress: true so that when the release job (jobs: release) is
triggered manually or by schedule it will not run concurrently with another run;
place this concurrency stanza alongside the existing env/top-level keys to
protect the Prepare & Push Release job from race conditions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 333ab0a3-f72b-420b-b014-0d1cb4a6b070
📒 Files selected for processing (4)
.github/workflows/ci.yml.github/workflows/deploy-to-staging.yml.github/workflows/pr-preview.yml.github/workflows/release.yml
✅ Files skipped from review due to trivial changes (1)
- .github/workflows/ci.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/pr-preview.yml
e51cf4a to
9c09671
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
1724-1725: Consider gating Slack notification on release creation success.The condition
always() && steps.notes.outcome == 'success'will send the Slack notification even if the GitHub Release creation step fails (as long as release notes were generated). This could notify the team about a "release" that wasn't actually published.Consider also checking the release creation step outcome:
Suggested fix
- name: Notify Slack - if: always() && steps.notes.outcome == 'success' + if: success() run: |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml around lines 1724 - 1725, The Slack notification step ("Notify Slack") currently uses the condition always() && steps.notes.outcome == 'success', which can fire even if the release creation fails; update the step condition to also verify the release creation step's outcome (e.g., check steps.create_release.outcome == 'success' or the actual job/step id that performs release creation) so the Slack notification only runs when both notes generation and the release creation step succeeded.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 1703-1710: The workflow currently sets PREV_TAG to empty if no
prior semver tag exists which breaks release-notes.js; update the Resolve
previous tag step so PREV_TAG falls back to the repository root commit when no
tag is found (e.g. use PREV_TAG=$(git tag --list 'v[0-9]*'
--sort=-version:refname | grep -v '-' | grep -v "^${CURRENT_TAG}$" | head -n 1
|| true) and if PREV_TAG is empty set it to the initial commit via git rev-list
--max-parents=0 HEAD) and then emit that value to GITHUB_OUTPUT so the later
invocation of release-notes.js receives a valid fromTag instead of an empty
string; reference the CURRENT_TAG and PREV_TAG variables in the Resolve previous
tag step.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 1724-1725: The Slack notification step ("Notify Slack") currently
uses the condition always() && steps.notes.outcome == 'success', which can fire
even if the release creation fails; update the step condition to also verify the
release creation step's outcome (e.g., check steps.create_release.outcome ==
'success' or the actual job/step id that performs release creation) so the Slack
notification only runs when both notes generation and the release creation step
succeeded.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d5acb87b-a9d4-44c6-8b58-479305e3f057
📒 Files selected for processing (11)
.github/workflows/ci.yml.github/workflows/deploy-to-staging.yml.github/workflows/pr-preview.yml.github/workflows/release.ymlghost/core/package.jsonpackage.jsonscripts/.eslintrc.jsscripts/lib/release-notes.jsscripts/lib/resolve-base-tag.jsscripts/release.jsscripts/test/resolve-base-tag.test.js
✅ Files skipped from review due to trivial changes (4)
- .github/workflows/pr-preview.yml
- scripts/.eslintrc.js
- package.json
- scripts/lib/resolve-base-tag.js
🚧 Files skipped from review as they are similar to previous changes (4)
- ghost/core/package.json
- scripts/test/resolve-base-tag.test.js
- scripts/lib/release-notes.js
- scripts/release.js
9c09671 to
1c6a28c
Compare
1c6a28c to
0b6e365
Compare
0b6e365 to
ad9947b
Compare
ref https://linear.app/ghost/issue/BER-3313/ Consolidates the Ghost-Release private repo into the Ghost monorepo. The release orchestration (version bumping, theme updates, tag creation) becomes scripts/release.js, triggered by a workflow_dispatch + scheduled workflow in release.yml. Tag-triggered npm publishing via OIDC and GitHub Release creation are absorbed into ci.yml, eliminating the redundant full rebuild that Ghost-Release performed. The npm package published to self-hosters is now the same artifact that CI tested.
ad9947b to
8438f6b
Compare
|
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
.github/workflows/release.yml (1)
61-93:⚠️ Potential issue | 🔴 Critical
workflow_dispatchinput is still reaching the shell unsafely.Lines 72-75 write raw input into
$GITHUB_ENV, and Lines 84-91 still splice${{ env.* }}directly into the shell script. A craftedbranchorbump-typecan still break out of the command line in a job that holdsCANARY_DOCKER_BUILD.🔒 Proposed fix
- - name: Set up schedule defaults - if: github.event_name == 'schedule' - run: | - echo "RELEASE_BRANCH=main" >> "$GITHUB_ENV" - echo "RELEASE_BUMP_TYPE=auto" >> "$GITHUB_ENV" - echo "RELEASE_DRY_RUN=" >> "$GITHUB_ENV" - echo "RELEASE_SKIP_CHECKS=" >> "$GITHUB_ENV" - - - name: Set up workflow_dispatch inputs - if: github.event_name == 'workflow_dispatch' - run: | - echo "RELEASE_BRANCH=${INPUT_BRANCH}" >> "$GITHUB_ENV" - echo "RELEASE_BUMP_TYPE=${INPUT_BUMP_TYPE}" >> "$GITHUB_ENV" - echo "RELEASE_DRY_RUN=${INPUT_DRY_RUN}" >> "$GITHUB_ENV" - echo "RELEASE_SKIP_CHECKS=${INPUT_SKIP_CHECKS}" >> "$GITHUB_ENV" - env: - INPUT_BRANCH: ${{ inputs.branch }} - INPUT_BUMP_TYPE: ${{ inputs.bump-type }} - INPUT_DRY_RUN: ${{ inputs.dry-run }} - INPUT_SKIP_CHECKS: ${{ inputs.skip-checks }} - - name: Run release script + env: + GITHUB_TOKEN: ${{ secrets.CANARY_DOCKER_BUILD }} + RELEASE_BRANCH: ${{ github.event_name == 'schedule' && 'main' || inputs.branch }} + RELEASE_BUMP_TYPE: ${{ github.event_name == 'schedule' && 'auto' || inputs.bump-type }} + RELEASE_DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || 'false' }} + RELEASE_SKIP_CHECKS: ${{ github.event_name == 'workflow_dispatch' && inputs.skip-checks || 'false' }} run: | - ARGS="--branch=${{ env.RELEASE_BRANCH }} --bump-type=${{ env.RELEASE_BUMP_TYPE }}" - if [ "${{ env.RELEASE_DRY_RUN }}" = "true" ]; then - ARGS="$ARGS --dry-run" + args=( "--branch=$RELEASE_BRANCH" "--bump-type=$RELEASE_BUMP_TYPE" ) + if [ "$RELEASE_DRY_RUN" = "true" ]; then + args+=( "--dry-run" ) fi - if [ "${{ env.RELEASE_SKIP_CHECKS }}" = "true" ]; then - ARGS="$ARGS --skip-checks" + if [ "$RELEASE_SKIP_CHECKS" = "true" ]; then + args+=( "--skip-checks" ) fi - node scripts/release.js $ARGS - env: - GITHUB_TOKEN: ${{ secrets.CANARY_DOCKER_BUILD }} + node scripts/release.js "${args[@]}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 61 - 93, The workflow unsafely injects raw inputs into the shell by writing unescaped values to GITHUB_ENV and concatenating them into a single ARGS string; fix by (1) writing inputs to GITHUB_ENV safely (use a heredoc/EOF or printf '%s' to avoid interpreting newlines or special chars when setting RELEASE_BRANCH, RELEASE_BUMP_TYPE, RELEASE_DRY_RUN, RELEASE_SKIP_CHECKS) and (2) avoid building a single unquoted ARGS string in the Run release script step — call node scripts/release.js with explicit, individually quoted arguments (e.g. node scripts/release.js --branch="$RELEASE_BRANCH" --bump-type="$RELEASE_BUMP_TYPE" and conditionally append --dry-run and --skip-checks as separate quoted args) so inputs cannot break out of the command line.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/lib/release-notes.js`:
- Around line 21-25: The catch block swallowing execSync errors makes git-log
failures return an empty changelog; instead, modify the catch around
execSync(cmd, {cwd: ROOT, encoding: 'utf8'}) so it surfaces the real error
(either rethrow the caught Error or call process.exit(1) after logging) rather
than returning []; include the original error and the failing cmd in the message
to aid debugging and keep the surrounding variables 'cmd' and 'log' intact.
In `@scripts/release.js`:
- Around line 81-115: The try/catch blocks that probe git (the blocks calling
run(...) to compute addedFiles and commits) currently swallow errors which lets
bumpType 'auto' fall back to patch; change the catch handlers so that if
bumpType === 'auto' they do not silently continue but instead surface the
failure (e.g., rethrow the caught error or call process.exit(1) after logging)
so automated releases fail fast; reference the same variables used in the diff
(run, baseTag, migrationsPath, addedFiles, commits, featureCommits, bumpType,
log) when locating and updating the catch behavior.
- Around line 21-49: parseArgs() currently accepts any --bump-type value;
validate opts.bumpType after parsing (or while parsing) and reject anything not
in the supported set ['auto','patch','minor'] by printing an error and exiting
non-zero. Update the parsing logic that sets opts.bumpType (reference: function
parseArgs(), opts.bumpType) to check the value and call console.error(...) +
process.exit(1) for invalid values so the script fails fast before performing
git mutations.
---
Duplicate comments:
In @.github/workflows/release.yml:
- Around line 61-93: The workflow unsafely injects raw inputs into the shell by
writing unescaped values to GITHUB_ENV and concatenating them into a single ARGS
string; fix by (1) writing inputs to GITHUB_ENV safely (use a heredoc/EOF or
printf '%s' to avoid interpreting newlines or special chars when setting
RELEASE_BRANCH, RELEASE_BUMP_TYPE, RELEASE_DRY_RUN, RELEASE_SKIP_CHECKS) and (2)
avoid building a single unquoted ARGS string in the Run release script step —
call node scripts/release.js with explicit, individually quoted arguments (e.g.
node scripts/release.js --branch="$RELEASE_BRANCH"
--bump-type="$RELEASE_BUMP_TYPE" and conditionally append --dry-run and
--skip-checks as separate quoted args) so inputs cannot break out of the command
line.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b7f8f4d6-d9b0-44b0-be87-6fc7a179befb
📒 Files selected for processing (11)
.github/workflows/ci.yml.github/workflows/deploy-to-staging.yml.github/workflows/pr-preview.yml.github/workflows/release.ymlghost/core/package.jsonpackage.jsonscripts/.eslintrc.jsscripts/lib/release-notes.jsscripts/lib/resolve-base-tag.jsscripts/release.jsscripts/test/resolve-base-tag.test.js
✅ Files skipped from review due to trivial changes (3)
- package.json
- scripts/.eslintrc.js
- .github/workflows/ci.yml
🚧 Files skipped from review as they are similar to previous changes (3)
- .github/workflows/pr-preview.yml
- .github/workflows/deploy-to-staging.yml
- scripts/test/resolve-base-tag.test.js
| let log; | ||
| try { | ||
| log = execSync(cmd, {cwd: ROOT, encoding: 'utf8'}).trim(); | ||
| } catch { | ||
| return []; |
There was a problem hiding this comment.
Fail this step when the compare range cannot be read.
On Lines 23-25, any git log failure is treated as an empty changelog, so an invalid or missing tag range turns into the generic fallback body instead of surfacing the real error. That would publish misleading GitHub Release/Slack notes.
🐛 Proposed fix
let log;
try {
log = execSync(cmd, {cwd: ROOT, encoding: 'utf8'}).trim();
- } catch {
- return [];
+ } catch (err) {
+ throw new Error(`Failed to read git log for ${range}: ${err.message}`);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let log; | |
| try { | |
| log = execSync(cmd, {cwd: ROOT, encoding: 'utf8'}).trim(); | |
| } catch { | |
| return []; | |
| let log; | |
| try { | |
| log = execSync(cmd, {cwd: ROOT, encoding: 'utf8'}).trim(); | |
| } catch (err) { | |
| throw new Error(`Failed to read git log for ${range}: ${err.message}`); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/lib/release-notes.js` around lines 21 - 25, The catch block
swallowing execSync errors makes git-log failures return an empty changelog;
instead, modify the catch around execSync(cmd, {cwd: ROOT, encoding: 'utf8'}) so
it surfaces the real error (either rethrow the caught Error or call
process.exit(1) after logging) rather than returning []; include the original
error and the failing cmd in the message to aid debugging and keep the
surrounding variables 'cmd' and 'log' intact.
| function parseArgs() { | ||
| const args = process.argv.slice(2); | ||
| const opts = { | ||
| bumpType: 'auto', | ||
| branch: 'main', | ||
| dryRun: false, | ||
| skipChecks: false, | ||
| waitForChecks: false | ||
| }; | ||
|
|
||
| for (const arg of args) { | ||
| if (arg.startsWith('--bump-type=')) { | ||
| opts.bumpType = arg.split('=')[1]; | ||
| } else if (arg.startsWith('--branch=')) { | ||
| opts.branch = arg.split('=')[1]; | ||
| } else if (arg === '--dry-run') { | ||
| opts.dryRun = true; | ||
| } else if (arg === '--skip-checks') { | ||
| opts.skipChecks = true; | ||
| } else if (arg === '--wait-for-checks') { | ||
| opts.waitForChecks = true; | ||
| } else { | ||
| console.error(`Unknown argument: ${arg}`); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| return opts; | ||
| } |
There was a problem hiding this comment.
Reject unsupported --bump-type values up front.
parseArgs() currently accepts any string, even though this release flow only supports auto, patch, and minor. A typo or unexpected value can send the script down the wrong version series instead of failing fast before any git mutations.
🐛 Proposed fix
function parseArgs() {
const args = process.argv.slice(2);
+ const validBumpTypes = new Set(['auto', 'patch', 'minor']);
const opts = {
bumpType: 'auto',
branch: 'main',
dryRun: false,
skipChecks: false,
@@
}
}
+ if (!validBumpTypes.has(opts.bumpType)) {
+ console.error(`Invalid --bump-type "${opts.bumpType}". Expected one of: auto, patch, minor.`);
+ process.exit(1);
+ }
+
return opts;
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/release.js` around lines 21 - 49, parseArgs() currently accepts any
--bump-type value; validate opts.bumpType after parsing (or while parsing) and
reject anything not in the supported set ['auto','patch','minor'] by printing an
error and exiting non-zero. Update the parsing logic that sets opts.bumpType
(reference: function parseArgs(), opts.bumpType) to check the value and call
console.error(...) + process.exit(1) for invalid values so the script fails fast
before performing git mutations.
| try { | ||
| const addedFiles = run(`git diff --diff-filter=A --name-only ${baseTag} HEAD -- ${migrationsPath}`); | ||
| if (addedFiles?.includes('core/')) { | ||
| log('New migrations detected'); | ||
| if (bumpType === 'auto') { | ||
| log('Auto-detecting: bumping to minor'); | ||
| bumpType = 'minor'; | ||
| } | ||
| } else { | ||
| log('No new migrations detected'); | ||
| } | ||
| } catch { | ||
| log('Warning: could not diff migrations'); | ||
| } | ||
|
|
||
| // Check for feature commits (✨ or 🎉) | ||
| try { | ||
| const commits = run(`git log --oneline ${baseTag}..HEAD`); | ||
| if (commits) { | ||
| const featureCommits = commits.split('\n').filter(c => c.includes('✨') || c.includes('🎉') || c.includes(':sparkles:')); | ||
| if (featureCommits.length) { | ||
| log(`Feature commits detected (${featureCommits.length})`); | ||
| if (bumpType === 'auto') { | ||
| log('Auto-detecting: bumping to minor'); | ||
| bumpType = 'minor'; | ||
| } | ||
| } else { | ||
| log('No feature commits detected'); | ||
| } | ||
| } else { | ||
| log('No commits since base tag'); | ||
| } | ||
| } catch { | ||
| log('Warning: could not read commit log'); | ||
| } |
There was a problem hiding this comment.
Don't silently downgrade auto-detection failures to a patch release.
On Lines 81-115, both git probes swallow errors and auto eventually falls through to patch. Because scheduled/manual releases default to auto, a broken tag range or history lookup can cut the wrong version instead of stopping.
🐛 Proposed fix
- } catch {
- log('Warning: could not diff migrations');
+ } catch (err) {
+ if (bumpType === 'auto') {
+ throw new Error(`Could not inspect migrations since ${baseTag}: ${err.message}`);
+ }
+ log('Warning: could not diff migrations');
}
@@
- } catch {
- log('Warning: could not read commit log');
+ } catch (err) {
+ if (bumpType === 'auto') {
+ throw new Error(`Could not inspect commits since ${baseTag}: ${err.message}`);
+ }
+ log('Warning: could not read commit log');
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| try { | |
| const addedFiles = run(`git diff --diff-filter=A --name-only ${baseTag} HEAD -- ${migrationsPath}`); | |
| if (addedFiles?.includes('core/')) { | |
| log('New migrations detected'); | |
| if (bumpType === 'auto') { | |
| log('Auto-detecting: bumping to minor'); | |
| bumpType = 'minor'; | |
| } | |
| } else { | |
| log('No new migrations detected'); | |
| } | |
| } catch { | |
| log('Warning: could not diff migrations'); | |
| } | |
| // Check for feature commits (✨ or 🎉) | |
| try { | |
| const commits = run(`git log --oneline ${baseTag}..HEAD`); | |
| if (commits) { | |
| const featureCommits = commits.split('\n').filter(c => c.includes('✨') || c.includes('🎉') || c.includes(':sparkles:')); | |
| if (featureCommits.length) { | |
| log(`Feature commits detected (${featureCommits.length})`); | |
| if (bumpType === 'auto') { | |
| log('Auto-detecting: bumping to minor'); | |
| bumpType = 'minor'; | |
| } | |
| } else { | |
| log('No feature commits detected'); | |
| } | |
| } else { | |
| log('No commits since base tag'); | |
| } | |
| } catch { | |
| log('Warning: could not read commit log'); | |
| } | |
| try { | |
| const addedFiles = run(`git diff --diff-filter=A --name-only ${baseTag} HEAD -- ${migrationsPath}`); | |
| if (addedFiles?.includes('core/')) { | |
| log('New migrations detected'); | |
| if (bumpType === 'auto') { | |
| log('Auto-detecting: bumping to minor'); | |
| bumpType = 'minor'; | |
| } | |
| } else { | |
| log('No new migrations detected'); | |
| } | |
| } catch (err) { | |
| if (bumpType === 'auto') { | |
| throw new Error(`Could not inspect migrations since ${baseTag}: ${err.message}`); | |
| } | |
| log('Warning: could not diff migrations'); | |
| } | |
| // Check for feature commits (✨ or 🎉) | |
| try { | |
| const commits = run(`git log --oneline ${baseTag}..HEAD`); | |
| if (commits) { | |
| const featureCommits = commits.split('\n').filter(c => c.includes('✨') || c.includes('🎉') || c.includes(':sparkles:')); | |
| if (featureCommits.length) { | |
| log(`Feature commits detected (${featureCommits.length})`); | |
| if (bumpType === 'auto') { | |
| log('Auto-detecting: bumping to minor'); | |
| bumpType = 'minor'; | |
| } | |
| } else { | |
| log('No feature commits detected'); | |
| } | |
| } else { | |
| log('No commits since base tag'); | |
| } | |
| } catch (err) { | |
| if (bumpType === 'auto') { | |
| throw new Error(`Could not inspect commits since ${baseTag}: ${err.message}`); | |
| } | |
| log('Warning: could not read commit log'); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/release.js` around lines 81 - 115, The try/catch blocks that probe
git (the blocks calling run(...) to compute addedFiles and commits) currently
swallow errors which lets bumpType 'auto' fall back to patch; change the catch
handlers so that if bumpType === 'auto' they do not silently continue but
instead surface the failure (e.g., rethrow the caught error or call
process.exit(1) after logging) so automated releases fail fast; reference the
same variables used in the diff (run, baseTag, migrationsPath, addedFiles,
commits, featureCommits, bumpType, log) when locating and updating the catch
behavior.
Ghost-Release used to send an on-call-paging Slack alert when a release failed (grunt notify-release-failure). After the release flow moved into Ghost, release.yml and ci.yml fell back to the generic slack-build "Test failure" message, which doesn't page on-call or link to remediation docs. Restores the original messages, posting to the existing RELEASE_NOTIFICATION_URL secret: - release.yml: "status checks were not green" alert with on-call ping, triggered-by line, and re-trigger/docs links - ci.yml (publish_ghost, create_github_release): generic publish-failure alert covering npm publish + GitHub Release creation Also gates the create_github_release "is loose!" announcement on the release step itself, so a failed GitHub Release can't announce success. refs #26760
When the release flow lived in Ghost-Release it sent an on-call-paging Slack alert on failure (grunt notify-release-failure). After the flow moved into Ghost, release.yml and ci.yml fell back to the generic slack-build "Test failure" message, which doesn't page on-call, explain the cause, or link to remediation docs. Restores the original messages, posting to the existing RELEASE_NOTIFICATION_URL secret, covering every stage of a release: - release.yml: on a failed prepare/tag run, posts the "status checks were not green" alert with the on-call ping, triggered-by line, and re-trigger/docs links. - ci.yml: adds a terminal notify_release_failure job that needs the whole publish chain (job_setup -> job_build_artifacts -> job_ghost-cli -> publish_ghost -> create_github_release) and fires on any failure within it. A single aggregator job catches jobs skipped by an upstream failure (e.g. a build failure skips publish_ghost entirely), which a per-job `if: failure()` step cannot. Replaces the per-job slack-build steps. Also gates the create_github_release "is loose!" announcement on the release step itself, so a failed GitHub Release can no longer announce a false success. refs #26760
When the release flow lived in Ghost-Release it sent an on-call Slack alert on failure (grunt notify-release-failure). After the flow moved into Ghost, release.yml and ci.yml fell back to the generic slack-build "Test failure" message, which doesn't page on-call. Restores an on-call alert at every stage of a release, posting to the existing RELEASE_NOTIFICATION_URL secret. Both stages send the same message — "🚨 Ghost release failed", an @on-call-product page, and a link to the failed run: - release.yml: on a failed prepare/tag run. - ci.yml: a terminal notify_release_failure job that needs the whole publish chain (job_setup -> job_build_artifacts -> job_ghost-cli -> publish_ghost -> create_github_release) and fires on any failure within it. A single aggregator job catches jobs skipped by an upstream failure (e.g. a build failure skips publish_ghost entirely), which a per-job `if: failure()` step cannot. Replaces the per-job slack-build steps. Also gates the create_github_release "is loose!" announcement on the release step itself, so a failed GitHub Release can no longer announce a false success. refs #26760
When the release flow lived in Ghost-Release it sent an on-call Slack alert on failure (grunt notify-release-failure). After the flow moved into Ghost, release.yml and ci.yml fell back to the generic slack-build "Test failure" message, which doesn't page on-call. Restores an on-call alert at every stage of a release, posting to the existing RELEASE_NOTIFICATION_URL secret. Both stages send the same message — "🚨 Ghost release failed", an @on-call-product page, and a link to the failed run: - release.yml: on a failed prepare/tag run. - ci.yml: a terminal notify_release_failure job that needs the whole publish chain (job_setup -> job_build_artifacts -> job_ghost-cli -> publish_ghost -> create_github_release) and fires on any failure within it. A single aggregator job catches jobs skipped by an upstream failure (e.g. a build failure skips publish_ghost entirely), which a per-job `if: failure()` step cannot. Replaces the per-job slack-build steps. Also gates the create_github_release "is loose!" announcement on the release step itself, so a failed GitHub Release can no longer announce a false success. refs #26760
When the release flow lived in Ghost-Release it sent an on-call Slack alert on failure (grunt notify-release-failure). After the flow moved into Ghost, release.yml and ci.yml fell back to the generic slack-build "Test failure" message, which doesn't page on-call. Restores an on-call alert at every stage of a release, posting to the existing RELEASE_NOTIFICATION_URL secret. Both stages send the same message — "🚨 Ghost release failed", an @on-call-product page, and a link to the failed run: - release.yml: on a failed prepare/tag run. - ci.yml: a terminal notify_release_failure job that needs the whole publish chain (job_setup -> job_build_artifacts -> job_ghost-cli -> publish_ghost -> create_github_release) and fires on any failure within it. A single aggregator job catches jobs skipped by an upstream failure (e.g. a build failure skips publish_ghost entirely), which a per-job `if: failure()` step cannot. Replaces the per-job slack-build steps. Also gates the create_github_release "is loose!" announcement on the release step itself, so a failed GitHub Release can no longer announce a false success. refs #26760



Consolidates release automation from the private Ghost-Release repo into the Ghost monorepo, eliminating the redundant full rebuild that Ghost-Release performed for npm publishing.
The release orchestration logic (version bump auto-detection, theme submodule updates, tag creation, RC advancement) becomes
scripts/release.js, triggered by a manualworkflow_dispatchinrelease.yml. The scheduled Friday cron is commented out until cutover from Ghost-Release (BER-3313). Tag-triggered npm publishing via OIDC trusted publishing and GitHub Release creation are absorbed intoci.ymlas new jobs that only run on version tags.The
publish_ghostjob is gated by annpm-releaseGitHub environment, so it won't fire until that environment is created — this prevents interference with Ghost-Release during the transition period.create_github_releasedepends onpublish_ghost, so it also stays inert.The
create_github_releasejob replaces thetryghost/actions/actions/ghost-release@mainaction with a self-containedscripts/lib/release-notes.jsscript that replicates the existing emoji-filtered changelog generation and Slack notification. This eliminates the dependency on the archived Utils repo and its vulnerablerequest/request-promisetransitive dependencies.The key improvement is that the
ghostnpm package published to self-hosted users is now the same artifact that CI built and tested, rather than a second independent build of the same source. npm provenance links the published package to the exact CI run and source commit.The CI build job is renamed from
job_docker_build_productiontojob_build_artifactsto reflect that it now produces both Docker images and the npm tarball.deploy-to-staging.ymlandpr-preview.ymlare updated to match the new job name.This PR is inert on merge — no automatic releases will fire. The cron is disabled and
publish_ghostis gated by a non-existent environment. Ghost-Release continues to be the active release path.Setup required before first release through the new pipeline:
ghostpackage on npmjs.comnpm-releaseGitHub environment in the Ghost repoRELEASE_NOTIFICATION_URLsecret to Ghost repo (for Slack release notifications — degrades gracefully if missing)Build & Publish Artifacts)After validation (1-2 successful releases):
release.ymlactions/ghost-release/from the Actions repo