Skip to content

Harden CI and publish workflow - #220

Open
ejsmith wants to merge 2 commits into
mainfrom
ci/harden-publish-workflow
Open

ejsmith wants to merge 2 commits into
mainfrom
ci/harden-publish-workflow

Conversation

@ejsmith

@ejsmith ejsmith commented Dec 2, 2026

Copy link
Copy Markdown
Member

What changed

  • Permissions: the workflow default is now contents: read. Publishing moved out of the build matrix into two jobs that needs: build. Each rebuilds from a clean checkout with the version computed once in a new Version job and passed through job outputs:
    • Publish Release Packages runs on refs/tags/v* only, with id-token: write and environment: npm-release.
    • Push GitHub CI Packages runs on non-PR branch pushes with a prerelease version (same condition as before), with packages: write.
    • Neither publish job uses a dependency cache.
  • Version stamping: scripts/set-version.mjs (Node built-ins only) replaces the unpinned global replace-in-files-cli install. I ran both in scratch copies and the output was byte-identical, with 58 replacements across 17 files.
  • Pinning: every action is pinned to a commit SHA with a # vX.Y.Z comment. minver-cli stays on 7.0.0.
  • GitHub Packages: || true is gone. Each package is skipped only if npm view shows that exact version already exists; any other publish failure fails the job.
  • Speed and coverage:
    • Switched to setup-node cache: npm and removed the node_modules cache.
    • Added a concurrency group that cancels superseded PR runs.
    • Lint runs once, on ubuntu with Node 24.
    • Node 22 now runs on ubuntu.
  • Dependabot: example-app-only dependencies (next, expo, svelte, vite, vue, …) get their own example-dependencies group, so a broken framework bump can't block SDK updates. Dependencies shared with the SDK packages stay in npm-dependencies. Cooldowns are unchanged. Groups match by dependency name, so a new example-only dependency needs adding to the list.
  • scripts/ is excluded from ESLint (typed linting has no Node types for it). Prettier still checks it.

Triggers, published refs, the workflow file name and the npm publish command are unchanged, so the npm trusted-publisher binding still applies.

Follow-up (repo settings, not changed here)

  • Add protection rules to the npm-release environment, such as a required reviewer and limiting deployments to v* tags. GitHub creates the environment without protection on first use.
  • If npm's trusted publisher entry for these packages names an environment, it must be npm-release. If it names none, nothing needs to change.

- Scope workflow permissions to contents: read; move npm release and
  GitHub Packages publishing into separate jobs that need the build and
  get id-token/packages write only where required.
- Compute the version once and pass it to every job via job outputs.
- Replace the global replace-in-files-cli install with
  scripts/set-version.mjs (Node built-ins only).
- Pin actions to commit SHAs.
- Only tolerate "already published" on GitHub Packages pushes.
- Use setup-node npm caching, add a concurrency group, lint once on
  ubuntu, and test Node 22 on ubuntu.
- Group example-app Dependabot updates separately from SDK updates.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 01:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T19:19:18.212202Z a51aa54 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI 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.

🟡 Changes recommended

The publication glob publishes dependent SDKs before their required dependencies, so a later publish failure can leave the CI tag pointing to an uninstallable package.

1 open issue
What changed in this PR

Hardens CI and package publishing for the SDK monorepo by separating validation from privileged publishing.

Changes:

  • Restricts permissions, pins actions, and isolates publish jobs.
  • Centralizes version stamping, updates caching, and adds Node 22 coverage.
  • Separates example dependency updates from SDK updates.
File Description
scripts/​set-version.mjs Adds dependency-free version stamping.
eslint.config.mjs Excludes scripts from typed linting.
.github/​workflows/​build.yml Separates publishing, tightens permissions, and expands CI coverage.
.github/​dependabot.yml Groups example dependencies separately.

Review effort: Balanced

Comment thread .github/workflows/build.yml Resolved
The packages/* glob published angularjs and browser before core, so a
failed run could leave a CI tag on a package whose exact dependency
version didn't exist.
@ejsmith
ejsmith marked this pull request as draft December 2, 2026 03:20
@niemyjski
niemyjski marked this pull request as ready for review December 2, 2026 19:17
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.

2 participants