Skip to content

ci(publish): skip notify/publish when version is already released#1606

Open
nebasuke wants to merge 12 commits intomainfrom
slang/publish-check
Open

ci(publish): skip notify/publish when version is already released#1606
nebasuke wants to merge 12 commits intomainfrom
slang/publish-check

Conversation

@nebasuke
Copy link
Copy Markdown
Member

@nebasuke nebasuke commented Apr 7, 2026

The publish workflow triggered notify-deploy and the publish approval gate on every push to main without pending changesets, even when the workspace version already matched the latest GitHub release. This caused unnecessary Slack notifications and approval prompts on no-op merges.

This PR adds a version check step to the changesets job that compares the local Cargo.toml version against the GitHub release for that tag:

  • Uses actions/github-script with Octokit's getReleaseByTag for explicit 404 handling — real errors (auth, network,
    rate limit) fail the step loudly
  • Only runs when hasChangesets == 'false' to avoid unnecessary API calls and prevent release API failures from
    blocking the changesets job when publishing isn't relevant
  • Gates both notify-deploy and publish on the new publishNeeded output
  • Defaults publishNeeded to 'false' when the check step is skipped, so downstream conditions are explicit rather than
    relying on empty-string semantics

Updated the workflow header table to reflect the new push (no-op) row.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

⚠️ No Changeset found

Latest commit: abde4f2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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

Adds a version check to the publish workflow so that notify/publish steps are skipped when the workspace version is already the latest GitHub release, avoiding unnecessary approval gates and notifications on no-op pushes.

Changes:

  • Added infra publish check subcommand to compare local workspace version vs latest GitHub release and emit a publishNeeded GitHub Actions output.
  • Wired the new publishNeeded output into the workflow to gate notify-deploy and publish jobs.
  • Updated the publish workflow documentation matrix to reflect the new “push (no-op)” path.

Reviewed changes

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

File Description
crates/infra/cli/src/commands/publish/mod.rs Registers the new publish check subcommand in the CLI.
crates/infra/cli/src/commands/publish/check.rs Implements version comparison and writes publishNeeded to GITHUB_OUTPUT.
.github/workflows/publish.yml Adds the check step/output and gates notify/publish jobs on publishNeeded.

nebasuke added 9 commits April 7, 2026 15:16
The publish workflow triggered notify-deploy and the publish approval
gate on every push to main without pending changesets, even when the
workspace version already matched the latest GitHub release. This added
an `infra publish check` subcommand that compares local vs published
versions, and gates notify-deploy/publish on the result.
The check command is self-contained and the downstream jobs already
gate on hasChangesets independently.
The struct has no fields but uses &self to match the execute() signature
pattern used by all other publish controllers.
Instead of printing a parseable line and capturing it in shell, write
directly to the GITHUB_OUTPUT file when running in CI. This simplifies
the workflow step to a plain command invocation.
- Let latest_release_version() errors propagate instead of silently
  treating any failure as "no release found". This avoids masking auth,
  network, or parse errors as false publish-needed signals.
- Pass GH_TOKEN to the workflow step so gh api is authenticated.
The Rust subcommand was CI-only glue with no local utility. A simple
shell comparison of the Cargo.toml version against the latest GitHub
release tag achieves the same result with less code to maintain.
The gh api call to fetch the latest release will 404 if no release
exists yet (or if the latest is a draft/prerelease). Catch this error
gracefully and treat it as "publish needed" with a clear log message,
rather than failing the entire changesets job.
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 1 out of 1 changed files in this pull request and generated 3 comments.

Replace inline shell (grep/sed + gh api) with Octokit's
getReleaseByTag via actions/github-script. This gives explicit 404
handling for the "no release yet" case while letting real errors
(auth, network, rate limit) fail the step loudly instead of being
silently swallowed.
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 1 out of 1 changed files in this pull request and generated 1 comment.

nebasuke added 2 commits April 7, 2026 15:29
Guard the checkVersion step with hasChangesets == 'false' so it only
runs when publishing is actually possible. Avoids unnecessary API
calls and prevents a release API failure from blocking the entire
changesets job when there are pending changesets.
When the checkVersion step is skipped (changesets pending), the output
was implicitly empty. Add an explicit || 'false' fallback so downstream
job conditions don't rely on empty-string-is-not-true semantics.
@nebasuke nebasuke marked this pull request as ready for review April 7, 2026 18:14
@nebasuke nebasuke requested review from a team as code owners April 7, 2026 18:14
uses: "actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea" # v7.0.1
with:
script: |
const fs = require('fs');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we already have the logic to check if a release is needed in infra publish for npm/cargo/github tags. WDYT of exposing that through the CLI instead? that would keep both in sync. Something along the lines of:

      - name: "infra check"
        run: "./scripts/bin/infra publish github-release --check-only" # prints 'true' or 'false'

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.

3 participants