Skip to content

Commit 36ca9e5

Browse files
committed
chore: add auto-release workflow
1 parent ed6ff3b commit 36ca9e5

File tree

2 files changed

+126
-4
lines changed

2 files changed

+126
-4
lines changed

.github/workflows/test.yml .github/workflows/test-and-release.yml

+45-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
name: Tests
2-
1+
name: Test & Maybe Release
32
on: [push, pull_request]
4-
53
jobs:
6-
run:
4+
test:
75
name: Node ${{ matrix.node }} on ${{ matrix.os }}
86
runs-on: ${{ matrix.os }}
97

@@ -47,3 +45,46 @@ jobs:
4745

4846
- name: Run tests
4947
run: npm test
48+
49+
release:
50+
name: Release
51+
needs: test
52+
runs-on: ubuntu-latest
53+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/[email protected]
58+
with:
59+
fetch-depth: 0
60+
61+
- name: Setup Node.js
62+
uses: actions/[email protected]
63+
with:
64+
node-version: 14
65+
66+
- name: Install dependencies
67+
run: |
68+
npm install --no-progress --no-package-lock --no-save
69+
70+
- name: Build
71+
run: |
72+
npm run build
73+
74+
- name: Install plugins
75+
run: |
76+
npm install \
77+
@semantic-release/commit-analyzer \
78+
conventional-changelog-conventionalcommits \
79+
@semantic-release/release-notes-generator \
80+
@semantic-release/npm \
81+
@semantic-release/github \
82+
@semantic-release/git \
83+
@semantic-release/changelog \
84+
--no-progress --no-package-lock --no-save
85+
86+
- name: Release
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
90+
run: npx semantic-release

package.json

+81
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,86 @@
4444
"lint": "standard",
4545
"unit": "tap --no-check-coverage test.js",
4646
"test": "npm run lint && npm run unit"
47+
},
48+
"release": {
49+
"branches": [
50+
"main"
51+
],
52+
"plugins": [
53+
[
54+
"@semantic-release/commit-analyzer",
55+
{
56+
"preset": "conventionalcommits",
57+
"releaseRules": [
58+
{
59+
"breaking": true,
60+
"release": "major"
61+
},
62+
{
63+
"revert": true,
64+
"release": "patch"
65+
},
66+
{
67+
"type": "feat",
68+
"release": "minor"
69+
},
70+
{
71+
"type": "fix",
72+
"release": "patch"
73+
},
74+
{
75+
"type": "chore",
76+
"release": "patch"
77+
},
78+
{
79+
"type": "docs",
80+
"release": "patch"
81+
},
82+
{
83+
"type": "test",
84+
"release": "patch"
85+
},
86+
{
87+
"scope": "no-release",
88+
"release": false
89+
}
90+
]
91+
}
92+
],
93+
[
94+
"@semantic-release/release-notes-generator",
95+
{
96+
"preset": "conventionalcommits",
97+
"presetConfig": {
98+
"types": [
99+
{
100+
"type": "feat",
101+
"section": "Features"
102+
},
103+
{
104+
"type": "fix",
105+
"section": "Bug Fixes"
106+
},
107+
{
108+
"type": "chore",
109+
"section": "Trivial Changes"
110+
},
111+
{
112+
"type": "docs",
113+
"section": "Trivial Changes"
114+
},
115+
{
116+
"type": "test",
117+
"section": "Tests"
118+
}
119+
]
120+
}
121+
}
122+
],
123+
"@semantic-release/changelog",
124+
"@semantic-release/npm",
125+
"@semantic-release/github",
126+
"@semantic-release/git"
127+
]
47128
}
48129
}

0 commit comments

Comments
 (0)