Skip to content

Share GitHub workflows - #11

Merged
zemd merged 2 commits into
mainfrom
zemd/share-workflows
Aug 7, 2026
Merged

Share GitHub workflows#11
zemd merged 2 commits into
mainfrom
zemd/share-workflows

Conversation

@zemd

@zemd zemd commented Aug 5, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a major update to the repository's GitHub Actions automation. It publishes the internal CI, CodeQL, Scorecard, and release pipelines as reusable, shared workflows, and moves the release tooling into a typed, tested package whose bundle is committed to .github/scripts. As part of this, the old release scripts (github-releases.mjs, release-pr-body.mjs, and signed-commit.mjs) and their tests are removed, and repository metadata is updated to reflect these changes in ownership, attributes, and dependency update paths.

Shared workflow and release tooling migration:

  • Publishes the CI, CodeQL, Scorecard, and release pipelines as reusable shared-*.yml workflows, allowing other monorepos to consume them by pinned SHA, and moves release tooling into a typed, tested package with its bundle committed to .github/scripts (.changeset/shared-github-workflows.md).

Repository metadata and ownership updates:

  • Updates .github/CODEOWNERS to assign ownership of the new shared workflow files, scripts, and internal GHA tooling to @zemd (/.github/workflows/shared-*.yml, /.github/scripts/, /internal/gha/).
  • Marks all .github/scripts/*.mjs files as generated in .gitattributes to reduce noise in diffs.

Dependency and update configuration:

  • Adds /internal/* to the list of directories Dependabot monitors for dependency updates in .github/dependabot.yml.

Deletions of legacy scripts and tests:

  • Removes the legacy release scripts: github-releases.mjs, release-pr-body.mjs, signed-commit.mjs, and their associated tests (release-pr-body.test.mjs, release-workflow.test.mjs), as these are now replaced by the new shared workflows and package [1] [2] [3] [4] [5].

@zemd zemd self-assigned this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ab321ef0-1719-4b3c-b9e3-f95c3b2ba736

📥 Commits

Reviewing files that changed from the base of the PR and between 899f2d9 and 224d256.

📒 Files selected for processing (19)
  • .github/scripts/gha.mjs
  • .github/workflows-examples/README.md
  • .github/workflows-examples/release.yml
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • .github/workflows/shared-release.yml
  • .prettierignore
  • internal/gha/src/changelog.ts
  • internal/gha/src/commands/context.test.ts
  • internal/gha/src/commands/context.ts
  • internal/gha/src/github.test.ts
  • internal/gha/src/github.ts
  • internal/gha/src/release-pr-body.test.ts
  • internal/gha/src/shared-workflows.test.ts
  • internal/gha/src/shared-workflows.ts
  • internal/gha/src/signed-commit.test.ts
  • internal/gha/src/signed-commit.ts
  • internal/gha/src/testing/fake-github.ts
  • internal/gha/src/workflows.test.ts
🚧 Files skipped from review as they are similar to previous changes (12)
  • internal/gha/src/commands/context.ts
  • .prettierignore
  • .github/workflows-examples/README.md
  • .github/workflows-examples/release.yml
  • internal/gha/src/changelog.ts
  • internal/gha/src/shared-workflows.test.ts
  • internal/gha/src/release-pr-body.test.ts
  • internal/gha/src/shared-workflows.ts
  • internal/gha/src/signed-commit.ts
  • .github/workflows/ci.yml
  • .github/scripts/gha.mjs
  • internal/gha/src/workflows.test.ts

📝 Walkthrough

Walkthrough

The change adds reusable CI, CodeQL, release, and Scorecard workflows. It introduces a typed @zemd/gha package, tests its release operations, bundles the CLI into .github/scripts/gha.mjs, and updates repository workflows to consume the shared contracts.

Changes

GHA workflows and release tooling

Layer / File(s) Summary
Typed tooling foundation
internal/gha/package.json, internal/gha/src/*, internal/gha/tsconfig.json, internal/gha/tsdown.config.js
Adds typed GitHub API, pnpm parsing, semver, changelog, environment, and signed-commit modules with Vitest coverage.
Release operations and CLI
internal/gha/src/commands/*, internal/gha/src/github-releases.ts, internal/gha/src/release-pr-body.ts, internal/gha/src/shared-workflows.ts, .github/scripts/gha.mjs
Adds package release, release-PR, shared-workflow release, signed-commit, and CLI dispatch functionality.
Reusable workflow contracts
.github/workflows/shared-*.yml, .github/workflows/{ci,codeql,release,scorecard}.yml, .github/workflows-examples/*
Adds reusable CI, CodeQL, release, and Scorecard workflows and updates callers and examples to use pinned shared workflows.
Bundling and repository integration
.github/workflows/ci.yml, internal/gha/scripts/sync.ts, internal/gha/src/workflows.test.ts, package.json, pnpm-workspace.yaml, turbo.json, .changeset/*, .github/*, .prettierignore, .gitattributes
Adds generated-bundle synchronization and contract checks, workspace integration, ownership and dependency configuration, build tracking, and release metadata.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CallerWorkflow
  participant SharedReleaseWorkflow
  participant NpmRegistry
  participant GhaCLI
  participant GitHubAPI
  CallerWorkflow->>SharedReleaseWorkflow: invoke shared-release.yml
  SharedReleaseWorkflow->>NpmRegistry: publish public packages
  SharedReleaseWorkflow->>GhaCLI: run shared-workflows-release or github-releases
  GhaCLI->>GitHubAPI: create tags and releases
  GitHubAPI-->>CallerWorkflow: return workflow result
Loading

Possibly related PRs

  • zemd/js#10: Both changes modify .github/workflows/ci.yml; this change adds dependency-review support through the reusable CI workflow.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description directly covers the shared workflows, typed release tooling migration, metadata updates, and legacy script removal.
Title check ✅ Passed The title clearly identifies the main change: publishing GitHub workflows for shared use.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 8

🧹 Nitpick comments (2)
.github/workflows/ci.yml (1)

56-59: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Print untracked output as well as modified output.

git status --porcelain reports untracked files, but git diff does not show them. If the rebuild adds a new file under .github/scripts, the job fails with no visible detail. Print the porcelain status next to the diff.

♻️ Proposed change
           if [ -n "$(git status --porcelain -- .github/scripts)" ]; then
             echo "::error::.github/scripts is stale, rebuild `@zemd/gha` and commit the result"
+            git status --porcelain -- .github/scripts
             git --no-pager diff -- .github/scripts
             exit 1
           fi
🤖 Prompt for 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.

In @.github/workflows/ci.yml around lines 56 - 59, Update the stale
`.github/scripts` check in the CI workflow to print the `git status --porcelain
-- .github/scripts` output alongside the existing `git diff`, ensuring untracked
files are visible when the rebuild check fails.
internal/gha/src/release-pr-body.ts (1)

87-93: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the duplicated release table.

Lines 87-93 and 112-118 render the same table with the same header, separator, and row format. Extract one helper so a future column change updates both sections.

♻️ Proposed helper
+const releaseTable = (out: string[], releases: readonly PreparedRelease[]): void => {
+  out.push("| Package | Bump | Current | Next |");
+  out.push("| :--- | :---: | ---: | ---: |");
+  for (const release of releases) {
+    const current = release.from ? `\`${release.from}\`` : "—";
+    out.push(`| \`${release.name}\` | ${badge[release.kind]} | ${current} | \`${release.to}\` |`);
+  }
+};

Then replace both blocks with releaseTable(out, releases) and releaseTable(out, internal).

Also applies to: 112-118

🤖 Prompt for 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.

In `@internal/gha/src/release-pr-body.ts` around lines 87 - 93, Extract the shared
release-table rendering logic from the duplicated blocks into a helper such as
releaseTable, including the header, separator, and release-row formatting.
Replace both table-rendering sections with calls using releases and internal
respectively, preserving their existing output order and formatting.
🤖 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/ci.yml:
- Around line 62-70: Update the “Require a release intent when the shared
contract changes” step to check whether BASE_SHA or HEAD_SHA is empty before
invoking git diff; skip the shared contract check when either input is
unavailable, while preserving the existing diff and validation behavior when
both SHAs are present.

In @.github/workflows/shared-release.yml:
- Around line 118-119: Update the shared-tooling checkout configuration around
the repository and ref fields to use supported GitHub Actions context values.
Add explicit reusable-workflow inputs for the repository and ref and reference
those inputs, or derive both values from supported workflow context while
preserving the intended shared-tooling checkout target.

In @.prettierignore:
- Line 1: Update the comment in .prettierignore to reference the actual
generator source file, internal/gha/scripts/sync.ts, instead of the incorrect
.mjs path.

In `@internal/gha/src/changelog.ts`:
- Around line 4-17: Update the heading match in changelogEntry to accept an
optional date suffix after the requested version, while continuing to support
Changesets headings such as ## 1.0.0 and bracketed versions. Ensure canonical
headings like ## [1.0.0] - 2026-01-01 resolve to the corresponding entry instead
of returning an empty result.

In `@internal/gha/src/github.ts`:
- Line 94: Update the GitHub client option handling in
internal/gha/src/github.ts at lines 94-94 to add a graphqlUrl option, defaulting
to GitHub.com’s GraphQL endpoint, and build the graphql request from it instead
of apiUrl. In internal/gha/src/commands/context.ts at lines 4-9, pass
GITHUB_GRAPHQL_URL when constructing the client.

In `@internal/gha/src/shared-workflows.test.ts`:
- Around line 58-71: The existing exact-tag check in releaseSharedWorkflows
incorrectly treats vX.Y.Z as proof of completion; gate the no-op path on the
corresponding GitHub release, or resume any missing major-tag and release steps
when the exact tag exists. Update the test to use an existing release for the
no-op case, and add failure-and-retry coverage for both moving the major tag and
creating the GitHub release.

In `@internal/gha/src/shared-workflows.ts`:
- Around line 109-142: Update the early-return logic in the release workflow to
check whether the GitHub release for tag is present, rather than relying on
api.tagExists(tag), so an existing tag with a missing release can be repaired.
Reuse the fetched releases collection for previousTag lookup, and make the retry
path tolerate the already-existing version tag by passing force to putTag or
treating that condition as success.

In `@internal/gha/src/signed-commit.ts`:
- Around line 28-34: Update the rename/copy handling around the status check to
inspect both Git status columns, so entries marked in either index or work-tree
column consume the paired origin pathname and update added/deleted sets
correctly. Preserve existing handling for ordinary records, and add regression
coverage for work-tree renames and copies to ensure no empty pathname reaches
file reading.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 56-59: Update the stale `.github/scripts` check in the CI workflow
to print the `git status --porcelain -- .github/scripts` output alongside the
existing `git diff`, ensuring untracked files are visible when the rebuild check
fails.

In `@internal/gha/src/release-pr-body.ts`:
- Around line 87-93: Extract the shared release-table rendering logic from the
duplicated blocks into a helper such as releaseTable, including the header,
separator, and release-row formatting. Replace both table-rendering sections
with calls using releases and internal respectively, preserving their existing
output order and formatting.
🪄 Autofix

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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8de39507-33ad-45a8-b9f2-b7ba33c6aff7

📥 Commits

Reviewing files that changed from the base of the PR and between ae5d897 and 899f2d9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (59)
  • .changeset/shared-github-workflows.md
  • .gitattributes
  • .github/CODEOWNERS
  • .github/dependabot.yml
  • .github/scripts/gha.mjs
  • .github/scripts/github-releases.mjs
  • .github/scripts/release-pr-body.mjs
  • .github/scripts/release-pr-body.test.mjs
  • .github/scripts/release-workflow.test.mjs
  • .github/scripts/signed-commit.mjs
  • .github/workflows-examples/README.md
  • .github/workflows-examples/ci.yml
  • .github/workflows-examples/codeql.yml
  • .github/workflows-examples/dependabot.yml
  • .github/workflows-examples/release.yml
  • .github/workflows-examples/scorecard.yml
  • .github/workflows/ci.yml
  • .github/workflows/codeql.yml
  • .github/workflows/release.yml
  • .github/workflows/scorecard.yml
  • .github/workflows/shared-ci.yml
  • .github/workflows/shared-codeql.yml
  • .github/workflows/shared-release.yml
  • .github/workflows/shared-scorecard.yml
  • .prettierignore
  • internal/gha/README.md
  • internal/gha/package.json
  • internal/gha/scripts/sync.ts
  • internal/gha/src/changelog.ts
  • internal/gha/src/cli.ts
  • internal/gha/src/commands/command.ts
  • internal/gha/src/commands/context.ts
  • internal/gha/src/commands/github-releases.ts
  • internal/gha/src/commands/index.test.ts
  • internal/gha/src/commands/index.ts
  • internal/gha/src/commands/release-pr-body.ts
  • internal/gha/src/commands/shared-workflows-release.ts
  • internal/gha/src/commands/signed-commit.ts
  • internal/gha/src/env.ts
  • internal/gha/src/github-releases.test.ts
  • internal/gha/src/github-releases.ts
  • internal/gha/src/github.test.ts
  • internal/gha/src/github.ts
  • internal/gha/src/pnpm.test.ts
  • internal/gha/src/pnpm.ts
  • internal/gha/src/release-pr-body.test.ts
  • internal/gha/src/release-pr-body.ts
  • internal/gha/src/semver.ts
  • internal/gha/src/shared-workflows.test.ts
  • internal/gha/src/shared-workflows.ts
  • internal/gha/src/signed-commit.test.ts
  • internal/gha/src/signed-commit.ts
  • internal/gha/src/testing/fake-github.ts
  • internal/gha/src/workflows.test.ts
  • internal/gha/tsconfig.json
  • internal/gha/tsdown.config.js
  • package.json
  • pnpm-workspace.yaml
  • turbo.json
💤 Files with no reviewable changes (5)
  • .github/scripts/release-pr-body.mjs
  • .github/scripts/signed-commit.mjs
  • .github/scripts/github-releases.mjs
  • .github/scripts/release-pr-body.test.mjs
  • .github/scripts/release-workflow.test.mjs

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/shared-release.yml Outdated
Comment thread .prettierignore Outdated
Comment thread internal/gha/src/changelog.ts
Comment thread internal/gha/src/github.ts Outdated
Comment thread internal/gha/src/shared-workflows.test.ts
Comment thread internal/gha/src/shared-workflows.ts Outdated
Comment thread internal/gha/src/signed-commit.ts Outdated
@zemd
zemd merged commit a045937 into main Aug 7, 2026
14 checks passed
@zemd
zemd deleted the zemd/share-workflows branch August 7, 2026 18:36
This was referenced Aug 7, 2026
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