This document describes how to deploy @astro-api/astroapi-typescript to NPM using GitHub Actions with OIDC Trusted Publishing.
Before deploying, ensure you have:
- Access to the GitHub repository with admin permissions
- An NPM account with publish access to
@astro-apiscope - NPM organization
@astro-apicreated
NPM Trusted Publishing allows GitHub Actions to publish packages without storing any secrets.
- Log in to npmjs.com
- Go to your package page:
@astro-api/astroapi-typescript - Click Settings → Publishing access
- Under Trusted publishing, click Add trusted publisher
- Configure the trusted publisher:
- Provider: GitHub Actions
- Repository owner:
astro-api - Repository name:
astroapi-typescript - Workflow filename:
release.yml - Environment: (leave empty)
- Click Add
Note: For new packages, publish the first version manually, then configure trusted publishing.
npm login
npm publish --access public- Go to Settings → Branches
- Add protection for
masterbranch:- Require a pull request before merging
- Require status checks to pass
This project uses Changesets for version management.
Developer creates changeset → Bump version → Create PR → Merge PR → Auto-publish to npm
-
Create changeset (describe your changes):
npx changeset
Select change type:
patch,minor, ormajor -
Bump version (updates package.json and CHANGELOG):
npx changeset version
-
Commit and create PR:
git add . git commit -m "chore: release vX.Y.Z" git push origin HEAD
Create PR manually on GitHub
-
Merge PR → Workflow auto-publishes to npm with OIDC provenance
Triggers: Push to master, Pull requests
- Runs ESLint
- Runs tests with coverage
- Builds package
Triggers: Push to master
- Checks if pending changesets exist (skips publish if yes)
- Publishes to npm when no pending changesets (version already bumped)
- Creates GitHub Release with auto-generated notes
Problem: PR merged but publish failed
Solutions:
- Verify trusted publishing is configured on npm
- Check repository owner/name matches exactly
- Ensure
id-token: writepermission is set - Verify repository is public (required for provenance)
Problem: "Unable to get OIDC token" error
Solutions:
- Ensure
id-token: writein workflow permissions - Verify
registry-urlin setup-node action - Confirm trusted publisher on npm matches workflow
# Local development
npm install
npm run lint
npm run test
npm run build
# Before releasing - create a changeset
npx changeset
# Commit and push
git add .
git commit -m "feat: add new feature"
git push- patch: Bug fixes, minor updates
- minor: New features, backward compatible
- major: Breaking changes
- Issues: GitHub Issues
- NPM Package: @astro-api/astroapi-typescript