Skip to content

Commit 55edd54

Browse files
authored
chore: setup semantic-release github action workflow (#15)
1 parent 37f80c8 commit 55edd54

File tree

6 files changed

+1748
-55
lines changed

6 files changed

+1748
-55
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10-
with:
11-
fetch-depth: 1
1210
- uses: actions/setup-node@v2
1311
with:
1412
node-version: 14

.github/workflows/cypress.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
with:
14-
fetch-depth: 1
1513
- uses: actions/setup-node@v2
1614
with:
1715
node-version: 14

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# inspired by
2+
# @see https://github.com/Jungwoo-An/react-editor-js/blob/1375dea6a3704d16bb234eaa58db6e4104807a11/.github/workflows/publish.yml
3+
name: release
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
install:
10+
runs-on: ubuntu-latest
11+
if: "! contains(github.event.head_commit.message, '[skip ci]')"
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v2
15+
with:
16+
node-version: 14
17+
- uses: actions/cache@v2
18+
with:
19+
path: node_modules
20+
key: natterstefan-nextjs-template-${{ hashFiles('**/yarn.lock') }}
21+
- run: yarn install
22+
- run: chmod -R +x ./node_modules/.bin
23+
24+
validate:
25+
needs: install
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Set @natterstefan-bot as committer
30+
run: |
31+
git config user.name "natterstefan Bot"
32+
git config user.email "natterstefan-bot@users.noreply.github.com"
33+
- uses: actions/setup-node@v2
34+
with:
35+
node-version: 14
36+
- uses: actions/cache@v2
37+
with:
38+
path: node_modules
39+
key: natterstefan-nextjs-template-${{ hashFiles('**/yarn.lock') }}
40+
- run: yarn install
41+
- run: yarn lint
42+
- run: yarn test
43+
- run: yarn test:cypress:ci
44+
45+
publish:
46+
needs: validate
47+
runs-on: ubuntu-latest
48+
if: github.ref == 'refs/heads/main'
49+
steps:
50+
- uses: actions/checkout@v2
51+
- uses: actions/setup-node@v2
52+
with:
53+
node-version: 14
54+
- uses: actions/cache@v2
55+
with:
56+
path: node_modules
57+
key: natterstefan-nextjs-template-${{ hashFiles('**/yarn.lock') }}
58+
- run: npx semantic-release
59+
env:
60+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
"@commitlint/cli": "^12.1.1",
4242
"@commitlint/config-conventional": "^12.1.1",
4343
"@natterstefan/scripts": "^1.2.0",
44+
"@semantic-release/changelog": "^5.0.1",
45+
"@semantic-release/commit-analyzer": "^8.0.1",
46+
"@semantic-release/git": "^9.0.0",
47+
"@semantic-release/github": "^7.2.1",
48+
"@semantic-release/release-notes-generator": "^9.0.2",
4449
"@storybook/addon-actions": "^6.2.9",
4550
"@storybook/addon-essentials": "^6.2.9",
4651
"@storybook/addon-links": "^6.2.9",
@@ -81,6 +86,7 @@
8186
"prettier": "^2.2.1",
8287
"sass": "^1.32.11",
8388
"sass-loader": "^11.0.1",
89+
"semantic-release": "^17.4.2",
8490
"start-server-and-test": "^1.12.1",
8591
"storybook-addon-next-router": "^2.0.4",
8692
"style-loader": "^2.0.0",

release.config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* eslint-disable no-template-curly-in-string */
2+
/**
3+
* Docs
4+
* @see https://github.com/semantic-release/semantic-release/blob/1d1b52a7dc02e63c41308f4d196983e0b5081e51/docs/usage/configuration.md
5+
* @see https://github.com/semantic-release/semantic-release/blob/1d1b52a7dc02e63c41308f4d196983e0b5081e51/docs/recipes/github-actions.md
6+
*/
7+
module.exports = {
8+
branches: ['main'],
9+
tagFormat: '${version}',
10+
plugins: [
11+
// verify commits
12+
[
13+
'@semantic-release/commit-analyzer',
14+
{
15+
preset: 'conventionalcommits',
16+
},
17+
],
18+
// generate release notes
19+
[
20+
'@semantic-release/release-notes-generator',
21+
{
22+
preset: 'conventionalcommits',
23+
},
24+
],
25+
// generate CHANGELOG.md
26+
[
27+
'@semantic-release/changelog',
28+
{
29+
changelogTitle: '# nextjs-template Changelog',
30+
},
31+
],
32+
// publish a new release on github
33+
'@semantic-release/github',
34+
// commit release assets to the project's git repository.
35+
'@semantic-release/git',
36+
],
37+
}

0 commit comments

Comments
 (0)