Skip to content

ci: semantic releases#335

Open
dhensby wants to merge 2 commits into
node-oauth:masterfrom
dhensby:pulls/semantic-release
Open

ci: semantic releases#335
dhensby wants to merge 2 commits into
node-oauth:masterfrom
dhensby:pulls/semantic-release

Conversation

@dhensby

@dhensby dhensby commented Mar 13, 2025

Copy link
Copy Markdown
Contributor

Summary

This change adds semantic releases to the release pipeline. Commits are automatically analysed when they are merged into master and depending on the commit message (fix, feat), a new release will be authored (tagged in git, pushed to GH releases and NPM); this includes updating the release version in package.json and updating the CHANGELOG.MD.

Other added benefits are NPM attestation of releases, no human dependencies on releases, fixes are released as soon as they are merged.

Contributors will now have to ensure their commits conform to the conventional commits standard

Outstanding actions:

  1. Someone with publish permissions to the NPM repository will need to create a fine-grained access token to allow publishing of the package - this must then be added to the github repo secrets with the name NPM_TOKEN.
  2. Someone with admin rights to the GH repo will need to create a fine-grained access token to allow pushing to the repository - this must then be added to the github repo secrets with the name GITHUB_TOKEN.

There is now no longer a need for an NPM_TOKEN to. be stored as a secret as NPM supports trusted publishing and uses federated credentials for publishing instead.

The GH token needs the following access:

      contents: write # to be able to publish a GitHub release & commit changelog changes
      issues: write # to be able to comment on released issues
      pull-requests: write # to be able to comment on released pull requests
      id-token: write # to enable use of OIDC for npm provenance

Linked issue(s)

See discussion #310

Involved parts of the project

Releases / automation.

Added tests?

N/A

OAuth2 standard

N/A

Reproduction

N/A

@dhensby dhensby force-pushed the pulls/semantic-release branch 2 times, most recently from 2ce5b21 to 69a3c8c Compare March 13, 2025 13:24
@jankapunkt

Copy link
Copy Markdown
Member

Thanks a lot for this @dhensby

I have nom publishing access but I'd like to limit this only to the master branch so new releases are definitely reviewed beforehand by at least two of us. What do you think?

@dhensby

dhensby commented Mar 13, 2025

Copy link
Copy Markdown
Contributor Author

By default the release process won't work unless it's in a list of the default branches (master, next, and then N.x for changes to other versions). We can limit this to just master either in the release config or in the GH workflow (or both).

@jankapunkt

Copy link
Copy Markdown
Member

Ok then we can leverage npm tags so everything on next is also tagged @next (like alpha beta release candidate) and not auto installed by users while releases on master can be tagged @latest so they are installable without explicit version pinning

@dhensby

dhensby commented Mar 14, 2025

Copy link
Copy Markdown
Contributor Author

Yep - that's how it works "out of the box" 👍

@jankapunkt

Copy link
Copy Markdown
Member

@dhensby I just merged some dependabot dev-dependencies. Would these kinds of merges be ignored by your current PR?

@dhensby

dhensby commented May 20, 2025

Copy link
Copy Markdown
Contributor Author

I just merged some dependabot dev-dependencies. Would these kinds of merges be ignored by your current PR?

No; they are flagged as build: or sometimes chore(deps): commits that don't trigger releases. Also, if you use @dependabot merge command, the CI is run in reduced-privilege mode which means that the runs don't have access to the secrets and so they can't be used to perform releases.

In regard to dependencies, our version constraints should be permissive enough that any upstream consumer can be responsible for upgrading any packages that have vulnerabilities or bugs; if we start to depend on new major versions of dependencies that form part of our outward facing APIs (I don't think they do), then we should probably manually update them with at least minor and maybe major change releases.

@dhensby dhensby force-pushed the pulls/semantic-release branch from 69a3c8c to cac8b96 Compare May 20, 2025 08:12
@dhensby dhensby force-pushed the pulls/semantic-release branch 3 times, most recently from c480f52 to 832e5bd Compare June 15, 2026 22:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces automated semantic-versioned releases using semantic-release, along with commit message linting to enforce Conventional Commits as part of the CI pipeline.

Changes:

  • Add semantic-release configuration (including changelog + git commit of release artifacts).
  • Add commitlint configuration and CI steps to validate commit messages for pushes/PRs.
  • Extend the existing CI workflow to include a release job and adjust lint scripts/changelog header to match the release tooling.

Reviewed changes

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

Show a summary per file
File Description
release.config.mjs Defines semantic-release plugins and release/changelog/git behavior.
commitlint.config.mjs Adds Conventional Commits lint rules for CI enforcement.
package.json Adds devDependencies for commitlint/semantic-release tooling and updates lint scripts.
CHANGELOG.md Updates heading to match semantic-release changelog plugin title.
.github/workflows/tests.yml Adds commitlint checks, fetch-depth changes, and a semantic-release publish job.

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

Comment thread release.config.mjs
Comment on lines +1 to +11
export default {
preset: 'conventionalcommits',
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
['@semantic-release/changelog', { changelogTitle: '# Changelog' }],
'@semantic-release/npm',
'@semantic-release/github',
['@semantic-release/git', { message: 'chore(release): ${nextRelease.version}\n\n${nextRelease.notes}'} ],
],
};
Comment on lines +36 to +38
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose
Comment on lines +89 to +97
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
Comment on lines +103 to +106
env:
NPM_CONFIG_PROVENANCE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
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