Skip to content

Add GitHub Actions workflow to publish npm package on GitHub release#291

Merged
albe merged 4 commits intomainfrom
copilot/add-npm-release-workflow
Mar 31, 2026
Merged

Add GitHub Actions workflow to publish npm package on GitHub release#291
albe merged 4 commits intomainfrom
copilot/add-npm-release-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Automates npm publishing when a GitHub Release is published, eliminating manual npm publish steps.

Changes

  • .github/workflows/npm-publish.yml — new workflow triggered on release: published with two jobs:
    • verify (runs first):
      • Runs npm pack to build the tarball
      • Checks that all required source files are present in the package (index.js, EventStore.js, Storage.js, Partition.js, Index.js, metadataUtil.js)
      • Checks that sensitive/unwanted files are absent (.env, node_modules/, /data/)
      • Installs the tarball into the bench/ subproject and runs npm run bench as a smoke test — any runtime failure blocks publishing
    • publish (only runs if verify succeeds):
      • Sets up Node.js 22.x with registry-url: https://registry.npmjs.org
      • Runs npm publish --provenance --access public authenticated via NPM_TOKEN secret
      • Uses id-token: write permission for provenance attestation; all other permissions are minimally scoped
  • package.json — added missing src/metadataUtil.js to the files array (it was excluded from the tarball but is required at runtime by ReadableStorage.js)
  • .gitignore — added *.tgz to prevent locally-created pack tarballs from being accidentally committed

Required setup

Add an npm access token as a repository secret named NPM_TOKEN (Settings → Secrets and variables → Actions → New repository secret).

Copilot AI changed the title [WIP] Add GitHub workflow for npm release from GitHub release Add GitHub Actions workflow to publish npm package on GitHub release Mar 31, 2026
Copilot finished work on behalf of albe March 31, 2026 12:49
Copilot AI requested a review from albe March 31, 2026 12:49
@albe
Copy link
Copy Markdown
Owner

albe commented Mar 31, 2026

@copilot add a pre release step that creates a npm pack bundle and verifies it contains all necessary files, but no files that shouldn't be there like a .env, data files or node_modules/* .
Then install the package to a small test project, which could be the benchmark subprojects and try running it. If the package is missing crutial files, includes sensitive files or the test project run fails, then don't publish to npm.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot add a pre release step that creates a npm pack bundle and verifies it contains all necessary files, but no files that shouldn't be there like a .env, data files or node_modules/* .
Then inst...

Done in commit 73c54f4. Here's what was added:

verify job (runs before publish, which now has needs: verify):

  1. Packnpm pack builds the tarball.
  2. Verify pack contents — checks that key required files are present (index.js, EventStore.js, Storage.js, Partition.js, Index.js, metadataUtil.js) and that forbidden patterns are absent (.env, node_modules/, /data/). Any violation exits with an error, blocking the publish.
  3. Smoke test — installs the tarball into the bench/ subproject via npm install --no-save <tarball> and runs the full npm run bench suite (all four bench scripts). If any benchmark fails, the publish is blocked.

Running the smoke test locally also uncovered a real bug: src/metadataUtil.js was imported by ReadableStorage.js but missing from the files array in package.json, so it was silently excluded from the tarball and caused a runtime crash. That's fixed in the same commit.

Copilot finished work on behalf of albe March 31, 2026 14:01
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 98.054%. remained the same
when pulling 73c54f4 on copilot/add-npm-release-workflow
into 211af1e on main.

@albe albe marked this pull request as ready for review March 31, 2026 14:35
@albe albe merged commit 07c362f into main Mar 31, 2026
10 checks passed
@albe albe deleted the copilot/add-npm-release-workflow branch March 31, 2026 14:36
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