Skip to content

Commit dd67a3d

Browse files
committed
chore: add auto-release workflow
1 parent 781c292 commit dd67a3d

File tree

3 files changed

+160
-24
lines changed

3 files changed

+160
-24
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Test & Maybe Release
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
name: Node ${{ matrix.node }} on ${{ matrix.os }}
6+
runs-on: ${{ matrix.os }}
7+
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
node: [12, 14, 16]
12+
# windows support not quite ready: os: [ubuntu-latest, windows-latest]
13+
os: [ubuntu-latest]
14+
15+
steps:
16+
- name: Clone repository
17+
uses: actions/checkout@v2
18+
19+
- run: git fetch --prune --unshallow
20+
21+
- name: Set Node.js version
22+
uses: actions/setup-node@v2
23+
with:
24+
node-version: ${{ matrix.node }}
25+
26+
- run: node --version
27+
- run: npm --version
28+
- run: git --version
29+
30+
- name: Install npm dependencies
31+
run: npm ci
32+
33+
- name: Run tests
34+
run: npm test
35+
36+
release:
37+
name: Release
38+
needs: test
39+
runs-on: ubuntu-latest
40+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/[email protected]
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Setup Node.js
49+
uses: actions/[email protected]
50+
with:
51+
node-version: 14
52+
53+
- name: Install dependencies
54+
run: |
55+
npm install --no-progress --no-package-lock --no-save
56+
57+
- name: Build
58+
run: |
59+
npm run build
60+
61+
- name: Install plugins
62+
run: |
63+
npm install \
64+
@semantic-release/commit-analyzer \
65+
conventional-changelog-conventionalcommits \
66+
@semantic-release/release-notes-generator \
67+
@semantic-release/npm \
68+
@semantic-release/github \
69+
@semantic-release/git \
70+
@semantic-release/changelog \
71+
--no-progress --no-package-lock --no-save
72+
73+
- name: Release
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
77+
run: npx semantic-release

package.json

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"scripts": {
1010
"lint": "standard",
11-
"format": "standard --fix"
11+
"format": "standard --fix",
12+
"test": "npm run lint"
1213
},
1314
"author": "Rod <[email protected]> (http://r.va.gg/)",
1415
"license": "MIT",
@@ -33,5 +34,86 @@
3334
"preferGlobal": true,
3435
"devDependencies": {
3536
"standard": "^16.0.3"
37+
},
38+
"release": {
39+
"branches": [
40+
"main"
41+
],
42+
"plugins": [
43+
[
44+
"@semantic-release/commit-analyzer",
45+
{
46+
"preset": "conventionalcommits",
47+
"releaseRules": [
48+
{
49+
"breaking": true,
50+
"release": "major"
51+
},
52+
{
53+
"revert": true,
54+
"release": "patch"
55+
},
56+
{
57+
"type": "feat",
58+
"release": "minor"
59+
},
60+
{
61+
"type": "fix",
62+
"release": "patch"
63+
},
64+
{
65+
"type": "chore",
66+
"release": "patch"
67+
},
68+
{
69+
"type": "docs",
70+
"release": "patch"
71+
},
72+
{
73+
"type": "test",
74+
"release": "patch"
75+
},
76+
{
77+
"scope": "no-release",
78+
"release": false
79+
}
80+
]
81+
}
82+
],
83+
[
84+
"@semantic-release/release-notes-generator",
85+
{
86+
"preset": "conventionalcommits",
87+
"presetConfig": {
88+
"types": [
89+
{
90+
"type": "feat",
91+
"section": "Features"
92+
},
93+
{
94+
"type": "fix",
95+
"section": "Bug Fixes"
96+
},
97+
{
98+
"type": "chore",
99+
"section": "Trivial Changes"
100+
},
101+
{
102+
"type": "docs",
103+
"section": "Trivial Changes"
104+
},
105+
{
106+
"type": "test",
107+
"section": "Tests"
108+
}
109+
]
110+
}
111+
}
112+
],
113+
"@semantic-release/changelog",
114+
"@semantic-release/npm",
115+
"@semantic-release/github",
116+
"@semantic-release/git"
117+
]
36118
}
37119
}

0 commit comments

Comments
 (0)