Skip to content

chore(ci): trigger release workflow by git tag push#721

Merged
fengmk2 merged 5 commits intomasterfrom
release-by-tag
Mar 29, 2026
Merged

chore(ci): trigger release workflow by git tag push#721
fengmk2 merged 5 commits intomasterfrom
release-by-tag

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 29, 2026

Summary

  • Replace semantic-release (triggered on master push) with a self-contained tag-triggered release workflow
  • Supports pre-release dist-tags: v5.0.0-beta.0 publishes with --tag beta, v5.0.0-alpha.1 with --tag alpha, etc.
  • Adds version-tag mismatch guard to prevent accidental publishes
  • Creates GitHub Releases automatically (with prerelease flag for non-stable versions)

Release process after merge

# Stable release
npm version patch  # or minor/major
git push origin master --tags

# Pre-release
npm version 5.0.0-beta.0
git push origin master --tags

Note

Update the OIDC Trusted Publisher configuration on npmjs.com to point to release.yml in this repo.

Closes #719

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Release workflow now runs on pushed version tags, builds the project, enforces exact version/tag matching, maps prerelease tags to npm dist-tags, publishes to npm, creates GitHub Releases (marking prereleases), and tightens workflow permissions.
  • Documentation
    • README updated with release instructions and examples for bumping versions, tagging, and publishing stable and prerelease releases.

Replace semantic-release on master push with a self-contained
tag-triggered workflow. Supports pre-release dist-tags (beta, alpha,
rc, next, dev) and creates GitHub Releases automatically.

Release process: `npm version <version>` then `git push --tags`

Closes #719
@fengmk2 fengmk2 self-assigned this Mar 29, 2026
Copilot AI review requested due to automatic review settings March 29, 2026 10:26
@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Release workflow now triggers on pushed Git tags v*, runs inline build and strict tag vs package.json version validation, derives an npm dist-tag from the tag, publishes to npm, and creates a GitHub Release (marked prerelease when appropriate). README adds release instructions and examples.

Changes

Cohort / File(s) Summary
Release workflow
\.github/workflows/release.yml
Trigger changed to tag pushes matching v*; replaced reusable workflow with inline steps on ubuntu-latest; sets up Node 22; derives dist-tag from tag suffix or uses latest; validates that tag (without v) equals package.json.version; publishes with npm publish --access public --tag <dist-tag>; creates GitHub Release (sets prerelease when dist-tag != latest); tightened workflow permissions.
Documentation
README.md
Added "Release" section describing use of npm version, creating and pushing v* tags to trigger the workflow, examples for stable and pre-releases, and note on tag→dist-tag mapping and prerelease flag.

Sequence Diagram

sequenceDiagram
    participant Git as Git (tag push)
    participant GH as GitHub Actions
    participant Val as Validation
    participant Build as Build job
    participant NPM as npm Registry
    participant Release as GitHub Release

    Git->>GH: Push tag matching v*
    GH->>Val: extract tag, strip "v", read package.json
    Val->>Val: compare tag-version vs package.json.version
    alt versions match
        GH->>Build: run build (vp run build)
        Build->>GH: return build/artifacts
        GH->>NPM: npm publish --access public --tag <dist-tag>
        NPM-->>GH: publish result
        GH->>Release: create GitHub Release (prerelease if dist-tag != latest)
    else mismatch
        Val-->>GH: fail job with validation error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I found a tag upon the vine,
I trimmed the v and checked the sign.
Build hopped quick, the publish hums,
Pre or stable — carrots come.
A tidy release, hoppity drums.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #719: replacing automatic master-branch publishing with manual tag-push-triggered releases, supporting pre-release versions and version validation.
Out of Scope Changes check ✅ Passed All changes are in scope: workflow refactoring aligns with linked issue #719, README updates document the new release process, and no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: switching from semantic-release (on master push) to a git tag-triggered release workflow.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release-by-tag

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 and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 29, 2026

Open in StackBlitz

npm i https://pkg.pr.new/node-modules/urllib@721

commit: e39e7d2

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.77%. Comparing base (182fabe) to head (e39e7d2).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #721   +/-   ##
=======================================
  Coverage   92.77%   92.77%           
=======================================
  Files          10       10           
  Lines         747      747           
  Branches      233      233           
=======================================
  Hits          693      693           
  Misses         51       51           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the existing branch-push-driven release automation with a self-contained GitHub Actions workflow that publishes to npm and creates a GitHub Release when a v* git tag is pushed, including prerelease dist-tag handling and a tag↔package.json version guard.

Changes:

  • Switch release trigger from push on master to push on v* tags.
  • Add in-workflow build, version/tag validation, npm dist-tag selection, npm publish, and GitHub Release creation.
  • Remove use of the external reusable workflow previously used for npm releases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +29
- name: Build
run: vp run build

Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The repo’s prepublishOnly script runs vp run build, and npm publish runs prepublishOnly by default. With the separate "Build" step here, the workflow will build twice unnecessarily. Consider removing this Build step (rely on prepublishOnly) or publish with scripts disabled if you want to build explicitly.

Suggested change
- name: Build
run: vp run build

Copilot uses AI. Check for mistakes.
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: 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 39-49: The dist-tag step (id: dist-tag) currently falls back to
"latest" for any prerelease it doesn't explicitly allow; update the logic so
that if TAG_VERSION (from GITHUB_REF_NAME) matches a prerelease pattern (the
grep -qE '-(alpha|beta|rc|next|dev)' check) you always extract the prerelease
identifier into PRE_TAG and emit that as the tag (do not default to "latest" for
unknown identifiers like "preview"), and ensure the subsequent release creation
step uses that tag to mark the GitHub Release as prerelease rather than stable
(i.e., use PRE_TAG/GITHUB_OUTPUT from dist-tag to decide prerelease status).
- Around line 57-64: The publish step ("Publish to npm") must be made rerun-safe
so a successful publish followed by a failing release step won't block later
reruns; modify the "Publish to npm" step to first check npm for the target
version (e.g., run npm view ${{ env.PACKAGE_NAME }}@${{
steps.dist-tag.outputs.tag }} or use npm info) and skip publishing if that
version already exists, then let the "Create GitHub Release" step run
unconditionally (or move "Create GitHub Release" into its own downstream job
that depends on the publish job); update the workflow to use the package
name/version outputs (steps/dist-tag.outputs.tag or your get_version step) to
perform the check and only run npm publish when the version is absent.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6f4801a5-38e0-4ecd-881b-9a07e77e3478

📥 Commits

Reviewing files that changed from the base of the PR and between 182fabe and 560b272.

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

Copilot AI review requested due to automatic review settings March 29, 2026 11:18
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.

🧹 Nitpick comments (1)
README.md (1)

360-360: Document the npm Trusted Publisher prerequisite

Please add a short note near Line 360 that npm Trusted Publisher must target .github/workflows/release.yml; otherwise publish can fail even when tags are pushed correctly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` at line 360, Add a short note near the release workflow
description around the paragraph referencing .github/workflows/release.yml
(around the existing text about publishing on v* tags) stating that npm Trusted
Publisher must be configured to target .github/workflows/release.yml; include a
brief warning that if the Trusted Publisher target is not set to that specific
workflow file, npm publish can fail even when tags are pushed correctly. Make
the note one sentence and place it immediately after the sentence about
automatic publishing and pre-release dist-tags.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@README.md`:
- Line 360: Add a short note near the release workflow description around the
paragraph referencing .github/workflows/release.yml (around the existing text
about publishing on v* tags) stating that npm Trusted Publisher must be
configured to target .github/workflows/release.yml; include a brief warning that
if the Trusted Publisher target is not set to that specific workflow file, npm
publish can fail even when tags are pushed correctly. Make the note one sentence
and place it immediately after the sentence about automatic publishing and
pre-release dist-tags.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b39e4ed-0eb8-456c-adba-7def87c8611d

📥 Commits

Reviewing files that changed from the base of the PR and between 560b272 and 921997e.

📒 Files selected for processing (1)
  • README.md

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

♻️ Duplicate comments (2)
.github/workflows/release.yml (2)

39-49: ⚠️ Potential issue | 🟠 Major

Unknown prerelease identifiers will incorrectly publish as latest.

The grep pattern only recognizes alpha|beta|rc|next|dev. A tag like v5.0.0-preview.0 or v5.0.0-canary.1 would fall through to the else branch and publish with --tag latest, which contradicts the prerelease intent.

Consider failing closed on unrecognized prerelease identifiers rather than defaulting to latest.

,

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release.yml around lines 39 - 49, The current dist-tag
step uses a fixed grep for alpha|beta|rc|next|dev and will default unknown
prerelease identifiers to "latest"; update the logic in the "Determine npm
dist-tag" step to detect any prerelease (check if TAG_VERSION contains a '-'),
extract the prerelease identifier into PRE_TAG (as already done with sed), then
if PRE_TAG is one of the allowed set keep echo "tag=$PRE_TAG", otherwise fail
closed by printing an error referencing TAG_VERSION/PRE_TAG to stderr and
exiting non‑zero (so the workflow stops instead of publishing with --tag
latest); reference the variables TAG_VERSION and PRE_TAG in your change.

51-58: ⚠️ Potential issue | 🟠 Major

Publish step is not rerun-safe.

If npm publish succeeds but the subsequent "Create GitHub Release" step fails, rerunning the workflow will fail because npm rejects duplicate version publishes. This leaves the release in a broken state where the npm package exists but the GitHub Release doesn't.

Consider checking if the version already exists on npm before publishing.

,

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release.yml around lines 51 - 58, The "Publish to npm"
step can cause unrecoverable failures if "Create GitHub Release" later fails;
modify the workflow so the Publish to npm step first checks if the version
already exists on npm (using the dist tag from steps.dist-tag.outputs.tag and
the package version) and only runs npm publish when the package/version is not
present, or make publishing idempotent by moving npm publish after a safe check
step; update the steps named "Publish to npm" and the preceding logic that reads
steps.dist-tag.outputs.tag to add an npm view/npm info check (or equivalent) and
skip publish when the version is already published so rerunning the workflow
won’t fail.
🧹 Nitpick comments (1)
.github/workflows/release.yml (1)

51-52: Add --provenance for npm package attestation.

The workflow has id-token: write permission, suggesting OIDC publishing intent, but the publish command doesn't use the --provenance flag to generate build provenance attestations.

Suggested fix
      - name: Publish to npm
-        run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
+        run: npm publish --access public --provenance --tag ${{ steps.dist-tag.outputs.tag }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release.yml around lines 51 - 52, Update the "Publish to
npm" step to include the --provenance flag so npm generates build attestations
when OIDC credentials are available; modify the run command that currently
invokes npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }} to
add --provenance, ensuring the workflow's id-token: write permission is used to
produce provenance attestations during publish.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/release.yml:
- Around line 39-49: The current dist-tag step uses a fixed grep for
alpha|beta|rc|next|dev and will default unknown prerelease identifiers to
"latest"; update the logic in the "Determine npm dist-tag" step to detect any
prerelease (check if TAG_VERSION contains a '-'), extract the prerelease
identifier into PRE_TAG (as already done with sed), then if PRE_TAG is one of
the allowed set keep echo "tag=$PRE_TAG", otherwise fail closed by printing an
error referencing TAG_VERSION/PRE_TAG to stderr and exiting non‑zero (so the
workflow stops instead of publishing with --tag latest); reference the variables
TAG_VERSION and PRE_TAG in your change.
- Around line 51-58: The "Publish to npm" step can cause unrecoverable failures
if "Create GitHub Release" later fails; modify the workflow so the Publish to
npm step first checks if the version already exists on npm (using the dist tag
from steps.dist-tag.outputs.tag and the package version) and only runs npm
publish when the package/version is not present, or make publishing idempotent
by moving npm publish after a safe check step; update the steps named "Publish
to npm" and the preceding logic that reads steps.dist-tag.outputs.tag to add an
npm view/npm info check (or equivalent) and skip publish when the version is
already published so rerunning the workflow won’t fail.

---

Nitpick comments:
In @.github/workflows/release.yml:
- Around line 51-52: Update the "Publish to npm" step to include the
--provenance flag so npm generates build attestations when OIDC credentials are
available; modify the run command that currently invokes npm publish --access
public --tag ${{ steps.dist-tag.outputs.tag }} to add --provenance, ensuring the
workflow's id-token: write permission is used to produce provenance attestations
during publish.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6273e2a3-feb9-4aad-af22-8449f240be1a

📥 Commits

Reviewing files that changed from the base of the PR and between 921997e and 5ce15d6.

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

fengmk2 added 2 commits March 29, 2026 19:22
Any version with a hyphenated pre-release suffix (e.g., preview, canary)
is now correctly published with its dist-tag and marked as prerelease.
Copilot AI review requested due to automatic review settings March 29, 2026 11:49
@fengmk2 fengmk2 changed the title feat: trigger release workflow by git tag push chore(ci): trigger release workflow by git tag push Mar 29, 2026
@fengmk2 fengmk2 merged commit b37563f into master Mar 29, 2026
25 of 26 checks passed
@fengmk2 fengmk2 deleted the release-by-tag branch March 29, 2026 11:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fi

- name: Publish to npm
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

npm publish here doesn't provide any auth (e.g., NODE_AUTH_TOKEN) and also doesn't enable npm Trusted Publishing via OIDC. With only id-token: write, npm typically requires --provenance (or NPM_CONFIG_PROVENANCE=true) to perform the OIDC exchange; otherwise this step is likely to fail or fall back to token-based auth. Consider publishing with provenance (and/or explicitly configuring auth) to match the PR's stated OIDC release process.

Suggested change
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }} --provenance

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +46
TAG_VERSION="${GITHUB_REF_NAME#v}"
if echo "$TAG_VERSION" | grep -qE '-([a-zA-Z]+)'; then
# Extract pre-release identifier (e.g., "beta" from "5.0.0-beta.0")
PRE_TAG=$(echo "$TAG_VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/')
echo "tag=$PRE_TAG" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

Pre-release detection only matches tags with alphabetic identifiers (e.g., -beta). SemVer allows numeric-only prerelease identifiers like v1.0.0-0; those would fall into the latest branch and be published to the latest dist-tag and marked as a stable GitHub Release. Consider treating any version containing - as prerelease, and only mapping the identifier to a dist-tag when it is present/valid (otherwise default to a safe prerelease dist-tag like next).

Copilot uses AI. Check for mistakes.
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.

自动根据 tag 发布

2 participants