Skip to content

ci: add dry-run gate to npm release workflow - #46061

Merged
onutc merged 7 commits into
openclaw:mainfrom
onutc:ci-npm-release-dry-run
Mar 14, 2026
Merged

onutc merged 7 commits into
openclaw:mainfrom
onutc:ci-npm-release-dry-run

Conversation

@onutc

@onutc onutc commented Mar 14, 2026

Copy link
Copy Markdown

TL;DR

I wanna convert this to a dry run. In the first run, instead of publishing, it should just show the operations it will do, fully with all arguments.

Summary

  • split the npm release workflow into tag-push preview and manual publish paths
  • gate the real publish job behind the npm-release environment
  • add a small helper script so preview and publish use the same computed npm publish command

Review focus

  • whether the manual dispatch path is the right approval point for real publishes
  • whether the preview output is explicit enough for release operators
  • whether checking out refs/tags/<input> is the right publish target

Test plan

  • bash -n scripts/openclaw-npm-publish.sh
  • bash scripts/openclaw-npm-publish.sh --dry-run
  • Push a v* tag and confirm the workflow previews without publishing
  • Run the workflow manually with a release tag and confirm npm-release approval is required before publish

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S maintainer Maintainer-authored PR labels Mar 14, 2026
@greptile-apps

greptile-apps Bot commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors the npm release workflow into two distinct jobs: a lightweight preview_openclaw_npm job triggered on every v* tag push that runs validations and a dry-run of the publish command, and a publish_openclaw_npm job triggered manually via workflow_dispatch that gates the real publish behind the npm-release environment. A new helper script scripts/openclaw-npm-publish.sh centralises the npm publish command construction so both paths stay in sync.

Key changes:

  • preview_openclaw_npm (tag-push) runs all checks and prints the resolved npm publish command via --dry-run without actually publishing.
  • publish_openclaw_npm (manual dispatch) requires explicit environment approval before publishing; re-uses the same helper script with --publish.
  • Concurrency key updated to use inputs.tag for workflow_dispatch runs to avoid collisions.

Issues found:

  • id-token: write is unnecessarily granted to the preview job, violating least privilege — it is only required by the publish job for provenance.
  • inputs.tag is interpolated directly into ref: refs/tags/${{ inputs.tag }} without format validation; a path-traversal value (e.g. ../heads/main) could cause the publish job to check out an unintended ref.
  • scripts/openclaw-npm-publish.sh --dry-run is invoked twice in the preview job ("Print release plan" and "Preview publish command"), producing identical output and cluttering the job log.

Confidence Score: 3/5

  • Safe to merge with minor security and correctness fixes recommended before the publish path is used in production.
  • The overall design (preview-on-tag-push, manual-dispatch-to-publish, environment gate) is solid. Two issues lower the score: the unvalidated inputs.tag in the ref: field could let an authorized dispatcher check out and publish from an unintended ref, and id-token: write on the preview job is an unnecessary permissions escalation. Neither is catastrophic given the environment-approval gate, but both should be fixed before the workflow handles real releases.
  • .github/workflows/openclaw-npm-release.yml — review the id-token: write permission on the preview job and add input validation for inputs.tag before the checkout step.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: .github/workflows/openclaw-npm-release.yml
Line: 27-29

Comment:
**Unnecessary `id-token: write` on preview job**

The `preview_openclaw_npm` job never calls `npm publish --provenance` and never requests an OIDC token, so `id-token: write` is not needed here. Granting it violates the principle of least privilege and unnecessarily exposes an OIDC token to every step in the job (including third-party actions like `setup-node-env`). The `id-token: write` permission should be kept only on the `publish_openclaw_npm` job.

```suggestion
    permissions:
      contents: read
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: .github/workflows/openclaw-npm-release.yml
Line: 105-107

Comment:
**Unvalidated tag input used in `ref:` field**

`inputs.tag` is interpolated directly into `ref: refs/tags/${{ inputs.tag }}` without first validating that it looks like a real version tag. A user with workflow-dispatch access (or who bypasses environment approval) could supply a value like `../heads/main`, which Git would resolve to `refs/heads/main`, causing the publish job to check out and publish from the tip of `main` rather than a reviewed, tagged commit.

Consider validating the tag format before the checkout, for example:

```yaml
      - name: Validate tag input format
        run: |
          if [[ ! "${{ inputs.tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
            echo "Invalid tag format: ${{ inputs.tag }}"
            exit 1
          fi
      - name: Checkout
        uses: actions/checkout@v6
        with:
          ref: refs/tags/${{ inputs.tag }}
          fetch-depth: 0
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: .github/workflows/openclaw-npm-release.yml
Line: 44-55

Comment:
**Duplicate `--dry-run` invocation**

`bash scripts/openclaw-npm-publish.sh --dry-run` is called twice in the preview job — once here in "Print release plan" and again at line 92 in "Preview publish command". The script output is identical both times (it just prints the resolved `npm publish` command), so the second call is redundant and adds noise to the job log.

Consider removing the call from "Print release plan" and keeping only the dedicated "Preview publish command" step, or merging the two steps into one.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: a688900

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Mar 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c67db420a2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@onutc
onutc merged commit c083172 into openclaw:main Mar 14, 2026
51 of 53 checks passed
@onutc
onutc deleted the ci-npm-release-dry-run branch March 14, 2026 12:45
@onutc

onutc commented Mar 14, 2026

Copy link
Copy Markdown
Author

Merged via admin rebase while the rerun of the unrelated extensions shard was still pending.

Thanks @onutc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant