Skip to content

Commit 523212d

Browse files
committed
chore(release): set up semantic-release on ci and commitlint/husky
1 parent 4a9088d commit 523212d

File tree

8 files changed

+8913
-1690
lines changed

8 files changed

+8913
-1690
lines changed

.github/workflows/ci_cd.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- next
7+
- beta
8+
- alpha
9+
pull_request:
10+
11+
permissions:
12+
contents: read # for checkout
13+
14+
jobs:
15+
commitlint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '22.x'
25+
- name: Install dependencies
26+
run: npm ci
27+
- name: Commitlint check
28+
uses: wagoid/commitlint-github-action@v5
29+
release:
30+
name: Release
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: write # to be able to publish a GitHub release
34+
issues: write # to be able to comment on released issues
35+
pull-requests: write # to be able to comment on released pull requests
36+
id-token: write # to enable use of OIDC for npm provenance
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
# Note: Automatically populated GITHUB_TOKEN cannot be used if branch protection is enabled
43+
# for the target branch. If the risk is acceptable, some extra configuration is needed. The
44+
# actions/checkout persist-credentials option needs to be false, otherwise the generated
45+
# GITHUB_TOKEN will interfere with the custom one.
46+
# ref: https://github.com/semantic-release/semantic-release/blob/master/docs/recipes/ci-configurations/github-actions.md#pushing-packagejson-changes-to-your-repository
47+
persist-credentials: false
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: '22.x'
52+
registry-url: 'https://npm.pkg.github.com'
53+
scope: '@mitre-attack'
54+
- name: Install
55+
run: npm clean-install
56+
- name: Build
57+
run: npm run build
58+
- name: Test
59+
run: npm run test
60+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
61+
run: npm audit signatures
62+
- name: Release
63+
run: npx semantic-release
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no-install commitlint --edit

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run format
1+
npm test

.releaserc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"branches": [
3+
"main",
4+
{
5+
"name": "next",
6+
"prerelease": true
7+
},
8+
{
9+
"name": "beta",
10+
"prerelease": true
11+
},
12+
{
13+
"name": "alpha",
14+
"prerelease": true
15+
}
16+
],
17+
"plugins": [
18+
"@semantic-release/commit-analyzer",
19+
"@semantic-release/release-notes-generator",
20+
"@semantic-release/npm",
21+
"@semantic-release/github",
22+
[
23+
"@semantic-release/git",
24+
{
25+
"assets": [
26+
"dist/**",
27+
"docs",
28+
"README.md",
29+
"package.json"
30+
],
31+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
32+
}
33+
]
34+
]
35+
}

0 commit comments

Comments
 (0)