Skip to content

ci: npm trusted publishing#994

Open
bohdan-struk-avalabs wants to merge 3 commits into
masterfrom
ci/npm-trusted-publishing
Open

ci: npm trusted publishing#994
bohdan-struk-avalabs wants to merge 3 commits into
masterfrom
ci/npm-trusted-publishing

Conversation

@bohdan-struk-avalabs

Copy link
Copy Markdown
Contributor

No description provided.

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.

Pull request overview

Updates the release automation to use npm Trusted Publishing (OIDC/provenance) by separating “version/tag” from “npm publish”, consolidating the prior release/prerelease workflows into a single workflow, and disabling semantic-release’s direct npm publishing.

Changes:

  • Disable @semantic-release/npm publishing (npmPublish: false) so semantic-release only versions/tags (and updates repo files where configured).
  • Replace the old release.yml / prerelease.yml workflows with a single publish.yml workflow that runs semantic-release on branch pushes and npm publish --provenance on tag pushes.
  • Adjust workflow permissions to allow OIDC token minting and repository writes for semantic-release tag/commit pushes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
.releaserc.cjs Disables npm publishing via semantic-release in preparation for OIDC/provenance publishing.
.github/workflows/release.yml Removes legacy release workflow (release-branch semantic-release + npm token publish).
.github/workflows/publish.yml Introduces consolidated “Release” workflow handling branch version/tag and tag-based provenance publishing.
.github/workflows/prerelease.yml Removes legacy prerelease workflow (master semantic-release + npm token publish).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +20 to +23
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't worry about aligning to v4, but we should update to use the latest v6 version SHA instead.

Comment on lines +25 to +31
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false # never use caching in release builds
- run: npm ci
- run: npm run build --if-present
- run: npm test
- run: npm publish # Or: npm stage publish
cache: yarn

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, don't worry about using v4, but please use a full v6 SHA.

Comment on lines +38 to +43
- name: Version & Tag
if: github.ref_type == 'branch'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.ref_name }}
run: yarn run semantic-release
Comment thread .github/workflows/publish.yml Outdated
Comment on lines +45 to +47
- name: Publish
if: github.ref_type == 'tag'
run: npm publish --provenance
Comment on lines +49 to +54
- name: Rebase master
if: github.ref_name == 'release' && github.ref_type == 'branch'
run: |
git checkout master &&
git rebase release &&
git push origin master

@erictaylor erictaylor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for moving this toward a single OIDC/provenance publishing workflow. I think this is the right direction, but this version does not yet preserve the existing publishing behavior.

The main blocker is the new tag-push npm publish --provenance path. With @semantic-release/npm set to npmPublish: false, semantic-release no longer publishes to npm. On the release branch this is mostly okay because the config still includes @semantic-release/git, so the version bump is committed before the tag is pushed and the tag workflow can publish the stable package as latest.

The master prerelease path is broken, though. The master branch config does not include @semantic-release/git, so semantic-release can compute/tag an alpha release while the tagged commit still has the old package.json version. The later tag workflow then checks out that tag and runs plain npm publish --provenance, which can publish the wrong package version or fail because that old version already exists.

Plain npm publish --provenance also loses semantic-release's channel handling. Previously, master prereleases like x.y.z-alpha.n were published to the prerelease channel/dist-tag, not to latest. The new workflow needs to preserve that distinction, for example by validating the tag against package.json and publishing prerelease tags with the appropriate non-latest npm tag while keeping stable release tags on latest.

I agree with the existing comments about hardening the action references, but I would keep the v6 actions and pin them to full commit SHAs rather than downgrading to v4. actions/checkout@v6 and actions/setup-node@v6 both exist; the important thing for this release workflow is using immutable full SHAs.

I do not think the github.ref_type comments are blockers. github.ref_type is available in the GitHub context and should be usable here to distinguish branch and tag refs on push events.

Requesting changes until the prerelease version/tag consistency and prerelease dist-tag behavior are preserved in the consolidated OIDC workflow.

@erictaylor erictaylor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation still does not preserve the existing release behavior.

The main blocker is that the workflow relies on semantic-release creating a tag from a branch push, then expects the same workflow to run again on the pushed v* tag and publish to npm. Because semantic-release is using GITHUB_TOKEN, GitHub will not trigger a normal push workflow from that tag push. So automated master and release runs can version/tag successfully but never reach the Publish step.

GitHub documents this behavior here: https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow

Please also correct these behavior changes so the consolidated workflow preserves the previous publishing expectations:

  • Prerelease dist-tag behavior changed. The new publish script derives alpha from versions like x.y.z-alpha.n, but semantic-release's previous channel behavior for the configured master prerelease branch would publish to the branch channel unless explicitly configured otherwise. If consumers expect @avalabs/avalanchejs@master, publishing as @alpha changes the install path.
  • @semantic-release/git now runs on master, so alpha prerelease version bumps will be committed back to master. Previously, the master prerelease flow updated package.json in the release workspace for publishing but did not persist prerelease version commits to the branch.

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