Skip to content

Commit

Permalink
build: Add release-it flow
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Jul 26, 2023
1 parent 80035a9 commit d19aeb8
Show file tree
Hide file tree
Showing 10 changed files with 20,679 additions and 1,020 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,49 @@ jobs:
- name: Test
run: npm run test

- name: Upload dist files
uses: actions/upload-artifact@v3
with:
name: dist-files
retention-days: 1
path: |
lib/**/*
publish:
# Run only for version tags
if: contains(github.ref, 'refs/tags/v')
needs:
- build
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3

# Cache packages when the branch is not update-dependencies or dependabot/*
- name: Resolve caching
id: cache
if: ${{ github.ref_name != 'update-dependencies' && !startsWith(github.ref_name, 'dependabot/') }}
run: echo "PACKAGE=npm" >> $GITHUB_OUTPUT

- name: Use Node.js
uses: actions/setup-node@v3.7.0
with:
node-version-file: ".nvmrc"
cache: ${{ steps.cache.outputs.PACKAGE }}
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Download dist files
uses: actions/download-artifact@v3
with:
name: dist-files

- name: Publish
run: npm run release
env:
NPM_CONFIG_PROVENANCE: true
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ jest.config.js
jsconfig.json
src
test
config
scripts
25 changes: 25 additions & 0 deletions config/release-it-common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require('dotenv').config();

module.exports = {
git: {
commit: true,
// eslint-disable-next-line no-template-curly-in-string
commitMessage: ':package: release ${version}\n[ci skip]',
push: true,
requireUpstream: false,
tag: true,
// eslint-disable-next-line no-template-curly-in-string
tagName: 'v${version}',
},
npm: {
publish: false,
ignoreVersion: true,
allowSameVersion: true,
},
github: {
draft: false,
release: false,
preRelease: false,
tokenRef: 'GITHUB_TOKEN',
},
};
17 changes: 17 additions & 0 deletions config/release-it-publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const config = require('./release-it-common');

module.exports = {
...config,
git: {
...config.git,
commit: false,
push: false,
tag: false,
requireCleanWorkingDir: false,
requireUpstream: false,
},
npm: {
...config.npm,
publish: true,
},
};
10 changes: 10 additions & 0 deletions config/release-it-version-beta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const config = require('./release-it-common');

module.exports = {
...config,
git: {
...config.git,
// eslint-disable-next-line no-template-curly-in-string
commitMessage: 'DROP - release ${version}',
},
};
20 changes: 20 additions & 0 deletions config/release-it-version-stable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const config = require('./release-it-common');

module.exports = {
...config,
git: {
...config.git,
// eslint-disable-next-line no-template-curly-in-string
commitMessage: ':package: release ${version}',
},
github: {
...config.github,
release: true,
},
plugins: {
...config.plugins,
'@release-it/conventional-changelog': {
preset: 'angular',
},
},
};
Loading

0 comments on commit d19aeb8

Please sign in to comment.