Skip to content

Commit ffe2417

Browse files
authored
feat: add automated release (#12)
* feat: add semantic-release * feat: add release and package workflows
1 parent 1b08689 commit ffe2417

File tree

12 files changed

+25747
-13437
lines changed

12 files changed

+25747
-13437
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local_tests

.github/workflows/CI.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: [ "main" ]
64
pull_request:
7-
branches: [ "main" ]
5+
branches:
6+
- '*'
7+
88

99
jobs:
1010
build:
@@ -22,7 +22,14 @@ jobs:
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424

25-
- name: Build
26-
run: |
27-
npm ci
28-
npm run build:dev
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Lint
29+
run: npm run lint
30+
31+
- name: Build Dev
32+
run: npm run build:dev
33+
34+
- name: Build Prod
35+
run: npm run build

.github/workflows/package.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Package
2+
3+
on:
4+
# release:
5+
# types: [published]
6+
# support manual release in case something goes wrong and needs to be repeated or tested
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: tag that needs to publish
11+
type: string
12+
required: true
13+
14+
env:
15+
NODE_VERSION: 18
16+
17+
jobs:
18+
pack:
19+
name: Package Extension
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
steps:
24+
- uses: actions/checkout@v3
25+
26+
- uses: actions/setup-node@v3
27+
with:
28+
node-version: ${{env.NODE_VERSION}}
29+
cache: 'npm'
30+
31+
- name: NPM Install
32+
run: npm ci
33+
34+
- run: npm run build
35+
36+
- name: Attach artifacts to release
37+
uses: svenstaro/upload-release-action@v2
38+
with:
39+
repo_token: ${{ secrets.GITHUB_TOKEN }}
40+
file: './zip/*.zip'
41+
file_glob: true
42+
overwrite: true
43+
tag: ${{ github.event.release.tag_name || inputs.tag }}

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: 'Release'
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
env:
9+
NODE_VERSION: 18
10+
11+
jobs:
12+
build-test:
13+
name: Build and Test
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Clone Repo
17+
uses: actions/checkout@v3
18+
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: ${{env.NODE_VERSION}}
22+
cache: 'npm'
23+
24+
- name: NPM Install
25+
run: npm ci
26+
27+
- name: NPM Lint
28+
run: npm run lint
29+
30+
- name: NPM Build
31+
run: npm run build --if-present
32+
33+
- name: NPM Test
34+
run: npm run test --if-present
35+
36+
newRelease:
37+
name: Create New Release
38+
needs: [build-test]
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: write
42+
issues: write
43+
pull-requests: write
44+
steps:
45+
- uses: actions/checkout@v3
46+
47+
- uses: actions/setup-node@v3
48+
with:
49+
node-version: ${{env.NODE_VERSION}}
50+
cache: 'npm'
51+
52+
- name: NPM Install
53+
run: npm ci
54+
55+
- name: NPM Build
56+
run: npm run build --if-present
57+
58+
- name: Release
59+
run: npm run release
60+
env:
61+
GITHUB_TOKEN: ${{secrets.GLOBAL_GITHUB_TOKEN}}
62+
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
63+
CI: true

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.lintstagedrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"src/**/*.{ts,js,json,md,html,css,scss}": [
3+
"npm run lint"
4+
]
5+
}

.releaserc

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"plugins": [
6+
[
7+
"@semantic-release/commit-analyzer",
8+
{
9+
"preset": "conventionalcommits",
10+
"releaseRules": [
11+
{
12+
"type": "docs",
13+
"scope": "README",
14+
"release": "patch"
15+
},
16+
{
17+
"type": "refactor",
18+
"release": "patch"
19+
},
20+
{
21+
"type": "style",
22+
"release": "patch"
23+
}
24+
],
25+
"parserOpts": {
26+
"noteKeywords": [
27+
"BREAKING CHANGE",
28+
"BREAKING CHANGES"
29+
]
30+
}
31+
}
32+
],
33+
[
34+
"@semantic-release/release-notes-generator",
35+
{
36+
"preset": "conventionalcommits"
37+
}
38+
],
39+
"@semantic-release/changelog",
40+
[
41+
"@semantic-release/npm",
42+
{
43+
"npmPublish": false
44+
}
45+
],
46+
[
47+
"@semantic-release/github",
48+
{
49+
"assets": []
50+
}
51+
],
52+
[
53+
"@semantic-release/git",
54+
{
55+
"assets": [
56+
"package.json",
57+
"package-lock.json",
58+
"CHANGELOG.md"
59+
],
60+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
61+
}
62+
]
63+
]
64+
}

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
module.exports = { extends: ['@commitlint/config-conventional'] }

0 commit comments

Comments
 (0)