Skip to content

Commit dfebb1e

Browse files
authored
Merge pull request #38 from metrics-js/semantic-release
chore: set up semantic release
2 parents d1764ed + 417aa62 commit dfebb1e

File tree

4 files changed

+101
-23
lines changed

4 files changed

+101
-23
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release on main
2+
3+
permissions:
4+
contents: write # to be able to publish a GitHub release
5+
issues: write # to be able to comment on released issues
6+
pull-requests: write # to be able to comment on released pull requests
7+
id-token: write # to enable use of OIDC for npm provenance
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
14+
# Cancel previous workflows which might still be running
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
18+
19+
jobs:
20+
release:
21+
name: Release
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Install Node.js
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: 20
31+
32+
- name: Install dependencies
33+
run: npm install
34+
35+
- name: Run all tests
36+
run: npm test
37+
38+
- name: Release and publish
39+
run: npx semantic-release
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
name: Run Lint and Tests
22

3-
on: push
3+
on:
4+
pull_request:
5+
branches: [main]
46

57
jobs:
6-
build:
7-
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
os: [ubuntu-latest, macOS-latest, windows-latest]
11-
node-version: [10.x, 12.x, 13.x]
12-
steps:
13-
- uses: actions/checkout@v1
14-
- name: Use Node.js ${{ matrix.node-version }}
15-
uses: actions/setup-node@v1
16-
with:
17-
node-version: ${{ matrix.node-version }}
18-
- name: npm install
19-
run: |
20-
npm install
21-
env:
22-
CI: true
23-
- name: Run tests
24-
run: |
25-
npm run lint && npm test
26-
env:
27-
CI: true
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, macOS-latest, windows-latest]
13+
node-version: [10.x, 18.x, 20.x]
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
22+
- name: Install dependencies
23+
run: npm install
24+
25+
- name: Lint
26+
run: npm run lint
27+
28+
- name: Run tests
29+
run: npm test

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@
3333
"monitoring"
3434
],
3535
"devDependencies": {
36+
"@semantic-release/changelog": "6.0.3",
37+
"@semantic-release/commit-analyzer": "11.1.0",
38+
"@semantic-release/git": "10.0.1",
39+
"@semantic-release/github": "9.2.1",
40+
"@semantic-release/npm": "11.0.1",
41+
"@semantic-release/release-notes-generator": "12.1.0",
3642
"benchmark": "2.1.4",
3743
"eslint": "7.32.0",
3844
"eslint-config-airbnb-base": "14.2.1",
3945
"eslint-plugin-import": "2.26.0",
4046
"lolex": "6.0.0",
47+
"semantic-release": "22.0.7",
4148
"tap": "14.11.0"
4249
}
4350
}

release.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
plugins: [
3+
'@semantic-release/commit-analyzer',
4+
'@semantic-release/release-notes-generator',
5+
'@semantic-release/changelog',
6+
[
7+
'@semantic-release/npm',
8+
{
9+
tarballDir: 'release',
10+
},
11+
],
12+
[
13+
'@semantic-release/github',
14+
{
15+
assets: 'release/*.tgz',
16+
},
17+
],
18+
'@semantic-release/git',
19+
],
20+
preset: 'angular',
21+
branches: [
22+
{ name: 'main' },
23+
{ name: 'alpha', prerelease: true },
24+
{ name: 'beta', prerelease: true },
25+
{ name: 'next', prerelease: true },
26+
],
27+
};

0 commit comments

Comments
 (0)