Skip to content

Commit 67b3b7b

Browse files
author
Mikaël Bouchez
committed
feat(ci): add release
1 parent 732a908 commit 67b3b7b

File tree

5 files changed

+127
-20
lines changed

5 files changed

+127
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,61 @@
1-
name: Node.js CI
1+
name: Continuous integration
22

33
on: [push, pull_request]
44

55
jobs:
6-
build:
6+
tests:
77
runs-on: ubuntu-latest
88

99
strategy:
1010
matrix:
1111
node-version: [14.x, 16.x, 18.x]
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
15+
1516
- name: Use Node.js ${{ matrix.node-version }}
16-
uses: actions/setup-node@v2
17+
uses: actions/setup-node@v3
1718
with:
1819
node-version: ${{ matrix.node-version }}
20+
1921
- name: Get yarn cache directory path
2022
id: yarn-cache-dir-path
2123
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
2224

23-
- uses: actions/cache@v2
25+
- uses: actions/cache@v3
2426
id: yarn-cache
2527
with:
2628
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
2729
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
2830
restore-keys: ${{ runner.os }}-yarn-
31+
2932
- name: Install dependencies
3033
if: steps.yarn-cache-dir-path.outputs.cache-hit != 'true'
3134
run: yarn install
32-
- run: yarn lint
33-
- run: yarn check-fmt
34-
- run: yarn build
35+
36+
- name: Eslint
37+
run: yarn lint
38+
39+
- name: Prettier
40+
run: yarn check-fmt
41+
3542
- run: yarn test-cover
3643
env:
3744
CI: true
45+
3846
- name: Coveralls Parallel
3947
uses: coverallsapp/github-action@v1.1.2
4048
with:
4149
github-token: ${{ secrets.GITHUB_TOKEN }}
4250
flag-name: node-${{ matrix.node-version }}
4351
parallel: true
52+
4453
coverall:
45-
needs: build
54+
needs: tests
4655
runs-on: ubuntu-latest
4756
steps:
4857
- name: Coveralls Finished
4958
uses: coverallsapp/github-action@v1.1.2
5059
with:
51-
github-token: ${{ secrets.GITHUB_TOKEN }}
52-
parallel-finished: true
60+
github-token: ${{ secrets.github_token }}
61+
parallel-finished: true

.github/workflows/release.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
strategy:
6+
description: Valid semver number <x.x.x> or strategy <patch, minor, major>
7+
default: "patch"
8+
required: false
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [18.x]
17+
18+
if: ${{ github.actor == 'pebie' || github.actor == 'Crow-EH' || github.actor == 'fthouraud' || github.actor == 'leguellec' || github.actor == 'rande' }}
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Get yarn cache directory path
27+
id: yarn-cache-dir-path
28+
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
29+
30+
- uses: actions/cache@v3
31+
id: yarn-cache
32+
with:
33+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34+
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
35+
restore-keys: ${{ runner.os }}-yarn-
36+
37+
- name: Install dependencies
38+
if: steps.yarn-cache-dir-path.outputs.cache-hit != 'true'
39+
run: yarn install
40+
41+
- name: Build
42+
run: yarn build
43+
44+
- name: Bump the version using input strategy
45+
run: |
46+
git config user.name github-actions[bot]
47+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
48+
yarn version --new-version ${{ github.event.inputs.strategy }} --no-git-tag-version
49+
50+
- name: Update changelog
51+
id: changelog
52+
run: |
53+
CHANGELOG=$(yarn conventional-changelog -p conventionalcommits -r -u 0)
54+
echo -e "${CHANGELOG}\n\n\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
55+
BODY=$(echo -e "${CHANGELOG}" | sed -e "1,2d")
56+
BODY="${BODY//'%'/'%25'}"
57+
BODY="${BODY//$'\n'/'%0A'}"
58+
BODY="${BODY//$'\r'/'%0D'}"
59+
echo "::set-output name=body::${BODY}"
60+
61+
- name: Log changes
62+
run: |
63+
echo "The changelog will be : ${{ steps.changelog.outputs.body }}"
64+
65+
- name: Get version
66+
id: package-version
67+
uses: martinbeentjes/npm-get-version-action@v1.2.3
68+
69+
- name: Create tag
70+
run: |
71+
git config user.name github-actions[bot]
72+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
73+
git add .
74+
git commit -m "chore(bump): release v${{ steps.package-version.outputs.current-version }}"
75+
git push
76+
git tag -a v${{ steps.package-version.outputs.current-version }} -m "chore(tag): release v${{ steps.package-version.outputs.current-version }}"
77+
git push origin v${{ steps.package-version.outputs.current-version }}
78+
79+
- name: Create release
80+
uses: softprops/action-gh-release@v1
81+
with:
82+
body: ${{ steps.changelog.outputs.body }}
83+
tag_name: v${{ steps.package-version.outputs.current-version }}
84+
name: v${{ steps.package-version.outputs.current-version }}
85+
86+
- name: Setup npmrc
87+
uses: actions/setup-node@v3
88+
with:
89+
node-version: '16.x'
90+
registry-url: 'https://registry.npmjs.org'
91+
92+
- name: Publish to NPM
93+
run: npm publish --access public
94+
env:
95+
VERSION: ${{ steps.package-version.outputs.current-version }}
96+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ jspm_packages
5151
!.yarn/sdks
5252
!.yarn/versions
5353
.pnp.*
54-
.vscode
54+
.vscode
55+
56+
events.json

.npmignore

Whitespace-only changes.

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
"name": "@ekino/logger",
33
"description": "A Lightweight logger that combines debug namespacing capabilities with winston levels and multioutput",
44
"homepage": "https://github.com/ekino/node-logger",
5+
"license": "MIT",
6+
"version": "1.0.0",
57
"main": "lib/index.js",
68
"types": "lib/index.d.ts",
7-
"files": ["/lib"],
9+
"files": [
10+
"/lib"
11+
],
812
"tags": [
913
"logger",
1014
"lightweight",
@@ -16,14 +20,9 @@
1620
},
1721
"maintainers": [
1822
{
19-
"name": "Raphaël Benitte"
20-
},
21-
{
22-
"name": "Nadim El-Boustani"
23+
"name": "Mikaël Bouchez"
2324
}
2425
],
25-
"license": "MIT",
26-
"version": "1.0.0",
2726
"engines": {
2827
"node": ">=14"
2928
},
@@ -38,6 +37,7 @@
3837
"@types/uuid": "8.x",
3938
"ava": "4.x",
4039
"commitlint": "17.x",
40+
"conventional-changelog": "3.1.24",
4141
"conventional-changelog-cli": "2.x",
4242
"coveralls": "3.x",
4343
"eslint": "8.x",
@@ -56,7 +56,7 @@
5656
"test": "ava",
5757
"test-cover": "nyc ava",
5858
"coverage": "nyc ava | coveralls",
59-
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s -r 0",
59+
"changelog": "yarn conventional-changelog -p conventionalcommits -r -u 0",
6060
"version": "echo ${npm_package_version}",
6161
"lint": "eslint .",
6262
"postinstall": "husky install"

0 commit comments

Comments
 (0)