Skip to content

ci(publish): auto-tag + GitHub Release on each npm publish#104

Merged
naorsabag merged 3 commits into
masterfrom
chore/publish-auto-release
May 10, 2026
Merged

ci(publish): auto-tag + GitHub Release on each npm publish#104
naorsabag merged 3 commits into
masterfrom
chore/publish-auto-release

Conversation

@naorsabag
Copy link
Copy Markdown
Owner

@naorsabag naorsabag commented May 10, 2026

Extends `.github/workflows/publish.yml` so every successful npm publish is also recorded as a git tag and a GitHub Release. Without this, npm publishes leave no trace on github.com beyond the bump commit — and the Releases tab stays empty (which is what you noticed after the repo went public).

Behavior

  • Triggered when either web OR cli successfully publishes.
  • Tag name: `v$(cli version)` — e.g. `v0.1.0-beta.6`. The CLI version is what users `npx`, so it's the most recognizable handle.
  • Release body lists whichever package(s) shipped on that run, so web-only or cli-only bumps still produce a record.
  • `--generate-notes` appends GitHub's auto-summarized commit history since the prior tag.
  • Skips cleanly if the tag already exists (re-runs are idempotent).

Required permission bump: `contents: read` → `contents: write` on the workflow.

Test plan

  • One-shot `v0.1.0-beta.5` release created retroactively for the current beta state.
  • On the next beta bump, confirm the workflow tags + releases automatically.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • CI now creates GitHub releases and tags automatically when packages are published.
    • Tag names are chosen dynamically depending on which packages published (combined, CLI-only, or web-only).
    • Release creation is skipped if a matching tag/release already exists.
    • Generated release notes include npm beta package links and an example npx usage.
    • CI permissions updated to allow release/tag creation.

Review Change Stack

Triggered when either web or cli publishes. Tag uses the CLI version
(v0.1.0-beta.5 etc) since that's what users `npx`. Release body lists
whichever package(s) shipped this run, so a web-only or cli-only bump
still produces a record. --generate-notes appends auto-summarized
commit history.

This is what populates the Releases tab on the GitHub repo — without
this, npm publishes leave no trace on github.com beyond the bump
commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9fc1d630-38fd-4191-a37f-bdb953a8f39b

📥 Commits

Reviewing files that changed from the base of the PR and between 2d544e1 and 54b0a0e.

📒 Files selected for processing (1)
  • .github/workflows/publish.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/publish.yml

Walkthrough

The publish workflow grants contents: write, adds stable id fields to publish steps, and adds a conditional "Create tag + GitHub Release" step that computes a tag from published packages, skips existing tags, and creates a release with generated notes and npm links.

Changes

GitHub Release Automation

Layer / File(s) Summary
Permissions Update
.github/workflows/publish.yml
Job contents permission changed from read to write to allow GitHub release/tag creation.
Publish Step IDs
.github/workflows/publish.yml
Adds id: publish_web and id: publish_cli to conditional npm publish steps so downstream steps can inspect outcomes.
Release Creation Step
.github/workflows/publish.yml
New conditional step determines a release tag based on which packages published (both, CLI-only, or web-only), skips if the release exists, and calls gh release create with generated notes including npm beta links and an npx usage example plus --generate-notes for commit history.

Sequence Diagram(s)

sequenceDiagram
  participant PublishJob as Publish Job
  participant npm as npm registry
  participant GH as GitHub CLI
  PublishJob->>npm: publish `@openhop/web` and openhop CLI (conditional)
  PublishJob->>PublishJob: compute tag (v$CLI_VERSION / cli/v$CLI_VERSION / web/v$WEB_VERSION)
  PublishJob->>GH: gh release view <tag>
  GH-->>PublishJob: exists? (yes/no)
  alt not exists
    PublishJob->>GH: gh release create --title --notes --generate-notes
  else exists
    PublishJob-->>PublishJob: skip release creation
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • naorsabag/openhop#103: Related — also modifies .github/workflows/publish.yml to add npm publish steps that this release creation step runs after.
  • naorsabag/openhop#73: Related — bumps package versions (beta) that the workflow publishes and that the release tag computation depends on.
🚥 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 accurately describes the primary change: adding automatic GitHub tag and release creation on successful npm publishes to the publish workflow.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/publish-auto-release

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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.yml:
- Around line 100-106: The workflow always sets tag="v$CLI_VERSION" and then
skips the run if that tag exists, which causes web-only publishes to be dropped
when CLI_VERSION is unchanged; update the tag/collision check to use the correct
publish target: compute the tag based on which publish is being performed (e.g.,
use v$WEB_VERSION when only web publish is enabled, or guard the gh release view
check behind the CLI publish condition), and only run the gh release view + exit
branch when the tag variable corresponds to the current publish (reference the
tag variable and the gh release view conditional in the existing step).
🪄 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 Plus

Run ID: 91c13f4b-ce67-4f0d-aa32-e3de1cfeb3a8

📥 Commits

Reviewing files that changed from the base of the PR and between 7e204d6 and 32eae1d.

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

Comment thread .github/workflows/publish.yml Outdated
Previously the workflow always tagged v$CLI_VERSION. A web-only bump
(CLI version unchanged) would match an existing tag from a prior
combined release and skip — leaving the web-only publish without a
GitHub Release record. (Caught by CodeRabbit on #104.)

New scheme:
  both shipped → v$CLI_VERSION         (combined)
  cli only     → cli/v$CLI_VERSION
  web only     → web/v$WEB_VERSION

The skip-if-exists check now runs against the tag we're actually
about to create, not an unrelated one.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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.yml:
- Around line 93-101: Add stable IDs to the actual publish steps (set id:
publish_web on the web publish step and id: publish_cli on the CLI publish
step), then change the release job's if condition to gate on actual publish
outcomes using always() && (steps.publish_web.outcome == 'success' ||
steps.publish_cli.outcome == 'success'); also update the WEB_PUBLISHED and
CLI_PUBLISHED environment variables in the release step to reference
steps.publish_web.outcome and steps.publish_cli.outcome respectively instead of
the pre-check outputs so the release only runs when a publish step truly
succeeded.
🪄 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 Plus

Run ID: 41e408af-a65d-42c4-967e-d2312439b02c

📥 Commits

Reviewing files that changed from the base of the PR and between 32eae1d and 2d544e1.

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

Comment thread .github/workflows/publish.yml Outdated
…ck intent

Previously the release step gated on whether we planned to publish
(`steps.<>_status.outputs.publish == 'true'`). A failed `npm publish`
(network, auth, registry rejection) would still trigger the release
step and produce a "successful publish" record on GitHub.

Now:
- The publish steps have stable ids (`publish_web`, `publish_cli`).
- The release step's `if:` keys off `steps.publish_*.outcome ==
  'success'`, with `always()` so it stays eligible after a
  conditionally-skipped publish.
- WEB_PUBLISHED / CLI_PUBLISHED env vars come from the same outcome
  expressions, so the release notes only list packages that actually
  shipped.

(Caught by CodeRabbit on #104.)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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