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 73e188b
Show file tree
Hide file tree
Showing 11 changed files with 20,681 additions and 1,020 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,35 @@ 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:
needs:
- build
if: contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
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 }}

- name: Download dist files
uses: actions/download-artifact@v3
with:
name: dist-files
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',
},
},
};
18 changes: 18 additions & 0 deletions config/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

BRANCH=$(git rev-parse --abbrev-ref HEAD)
PRERELEASE_ARG=""

# IF diff than master, release beta
if [ "$BRANCH" != "master" ]
then
PRERELEASE_ARG="--config ./config/version-beta.js --preRelease=beta"
else
PRERELEASE_ARG="--config ./config/version-stable.js"
fi

RELEASE_ARGS="${PRERELEASE_ARG} ${@}"

echo "Running release-it with '${RELEASE_ARGS}'."

npx release-it $RELEASE_ARGS
Loading

0 comments on commit 73e188b

Please sign in to comment.