semantic-release shareable config to publish npm packages with GitHub.
- Provides an informative git commit message for the release commit that does not trigger continuous integration and conforms to the conventional commits specification (e.g., "chore(release): 1.2.3 [skip ci]").
- Creates a tarball that gets uploaded with each GitHub release.
- Publishes the same tarball to npm.
- Commits the version change in
package.json
. - Creates or updates a changelog file.
$ yarn add semantic-release @linters/semantic-release -D
Ensure that your CI configuration has the following secret environment variables set:
GH_TOKEN
withpublic_repo
access.NPM_TOKEN
See each plugin documentation for required installation and configuration steps.
The shareable config can be configured in the semantic-release configuration file:
{
"extends": "@linters/semantic-release",
"branch": "master"
}
This configuration uses the following plugins:
@semantic-release/changelog
@semantic-release/commit-analyzer
@semantic-release/release-notes-generator
@semantic-release/npm
@semantic-release/git
If you're configuring GitHub actions the following yaml configuration will help you do just that:
name: release
on:
push:
branches:
- master
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org
- name: Cache node modules
uses: actions/cache@v1
id: cache
with:
path: node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install
- run: npx semantic-release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}