Skip to content

ci: skip staging when the version is already on npm - #1

Merged
akin-oz merged 1 commit into
mainfrom
ci/idempotent-release-staging
Aug 8, 2026
Merged

akin-oz merged 1 commit into
mainfrom
ci/idempotent-release-staging

Conversation

@akin-oz

@akin-oz akin-oz commented Aug 8, 2026 •

Copy link
Copy Markdown
Owner

Reruns of a Release workflow run after the version has already been published (e.g. after the GitHub Actions outage on Aug 6) fail with You cannot publish over the previously published versions, leaving the run red even though the release is fine.

This makes the "Stage the npm release for approval" step idempotent: it queries the registry with npm view and exits cleanly with a log message when the version already exists. Only npm and shell parameter expansion execute in the publish job, preserving the job's nothing-but-npm constraint.

Verified locally: the guard correctly detects the published 0.2.0, and zizmor reports no findings.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented duplicate package publishing when a release version already exists.
    • Existing published versions now finish successfully without triggering another release.

A rerun of a Release run after the version has been published failed
with "cannot publish over the previously published versions", leaving
the run red even though the release was fine. Check the registry first
and exit cleanly when there is nothing to stage.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The publish workflow now reads the package name and version. It skips staging when that exact version exists on npm. Otherwise, it runs the existing staging command.

Changes

Publish workflow

Layer / File(s) Summary
npm version check and conditional staging
.github/workflows/publish.yaml
The workflow derives the package name and version, checks npm for the exact version, and runs npm stage publish --ignore-scripts only when the version is not published.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the workflow change to skip staging when the package version already exists on npm.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/idempotent-release-staging

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/publish.yaml:
- Around line 112-115: Update the pre-staging logic in the publish workflow to
recognize versions already in npm’s staging queue and exit successfully without
issuing a second npm stage request. Distinguish a genuine version-not-found
response from registry, network, or authentication failures instead of treating
all errors as absent; fail the workflow for unknown lookup states. Add a
staged-version lookup using the OIDC token when supported, or implement/document
an equivalent reliable alternative.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 42c76569-0c6f-4521-88d5-9da9cbbd6241

📥 Commits

Reviewing files that changed from the base of the PR and between fdeb789 and e7d1637.

📒 Files selected for processing (1)
  • .github/workflows/publish.yaml

Comment thread .github/workflows/publish.yaml Resolved
@akin-oz
akin-oz merged commit 052b794 into main Aug 8, 2026
12 checks passed
@akin-oz
akin-oz deleted the ci/idempotent-release-staging branch August 8, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant