Skip to content

Commit dab59c9

Browse files
chore: add semantic-release automation (#106)
1 parent 99a5333 commit dab59c9

File tree

10 files changed

+231
-30
lines changed

10 files changed

+231
-30
lines changed

.github/workflows/commitlint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint Commits
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
commitlint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
12+
with:
13+
fetch-depth: 0
14+
persist-credentials: false
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
18+
with:
19+
node-version: '24'
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Validate commit messages
25+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Prepare Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
concurrency:
9+
group: prepare-release
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
prepare:
18+
runs-on: ubuntu-latest
19+
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
with:
24+
fetch-depth: 0
25+
persist-credentials: false
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
29+
with:
30+
node-version: '24'
31+
32+
- name: Install dependencies
33+
run: npm install
34+
35+
- name: Detect Next Version
36+
id: version
37+
run: |
38+
# Run semantic-release with only commit analyzer to detect version
39+
NEXT_VERSION=$(npx semantic-release --dry-run --plugins @semantic-release/commit-analyzer | tee /dev/stderr | awk '/The next release version is/{print $NF}')
40+
echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
41+
42+
- name: Update package.json
43+
if: steps.version.outputs.next != ''
44+
run: npm version "$NEXT_VERSION" --no-git-tag-version
45+
env:
46+
NEXT_VERSION: ${{ steps.version.outputs.next }}
47+
48+
- name: Update CHANGELOG.md
49+
if: steps.version.outputs.next != ''
50+
run: npx conventional-changelog-cli -p angular -i CHANGELOG.md -s
51+
52+
- name: Create Pull Request
53+
if: steps.version.outputs.next != ''
54+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
55+
with:
56+
token: ${{ secrets.GITHUB_TOKEN }}
57+
commit-message: "chore(release): ${{ steps.version.outputs.next }}"
58+
branch: "release/v${{ steps.version.outputs.next }}"
59+
delete-branch: true
60+
title: "chore(release): ${{ steps.version.outputs.next }}"
61+
body: |
62+
This PR prepares the release of version ${{ steps.version.outputs.next }}.
63+
64+
**Changes:**
65+
- Updated version in `package.json` to ${{ steps.version.outputs.next }}
66+
- Updated `CHANGELOG.md` with release notes
67+
68+
**Next Steps:**
69+
Review and merge this PR to trigger the publish workflow.
70+
labels: release

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
id-token: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
environment: release
18+
if: startsWith(github.event.head_commit.message, 'chore(release):')
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
with:
24+
fetch-depth: 0
25+
persist-credentials: false
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
29+
with:
30+
node-version: '24'
31+
32+
- name: Install dependencies
33+
run: npm install
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
37+
with:
38+
python-version: "3.10"
39+
40+
- name: Configure AWS credentials
41+
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
42+
with:
43+
role-to-assume: ${{ secrets.PRODSEC_TOOLS_ARN }}
44+
aws-region: us-east-1
45+
mask-aws-account-id: true
46+
47+
- name: Install rl-wrapper
48+
env:
49+
WRAPPER_INDEX_URL: "https://${{ secrets.PRODSEC_TOOLS_USER }}:${{ secrets.PRODSEC_TOOLS_TOKEN }}@a0us.jfrog.io/artifactory/api/pypi/python-local/simple"
50+
run: pip install "rl-wrapper>=1.0.0" --index-url $WRAPPER_INDEX_URL
51+
52+
- name: Release
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
NPM_CONFIG_PROVENANCE: true
56+
RLSECURE_LICENSE: ${{ secrets.RLSECURE_LICENSE }}
57+
RLSECURE_SITE_KEY: ${{ secrets.RLSECURE_SITE_KEY }}
58+
SIGNAL_HANDLER_TOKEN: ${{ secrets.SIGNAL_HANDLER_TOKEN }}
59+
PYTHONUNBUFFERED: 1
60+
run: npx semantic-release

.github/workflows/sca-scan.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Snyk Scan
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
7+
jobs:
8+
snyk-cli:
9+
uses: auth0/devsecops-tooling/.github/workflows/sca-scan.yml@5246a8b59100e3eea284ce4f2e2a51b51e237380
10+
secrets: inherit

.github/workflows/semgrep.yml

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

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
node-version: ['20', '22', '24']
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
with:
23+
persist-credentials: false
24+
25+
- name: Setup Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Test
34+
run: npm test

.husky/commit-msg

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

.releaserc.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"branches": [
3+
"master"
4+
],
5+
"plugins": [
6+
"@semantic-release/commit-analyzer",
7+
"@semantic-release/release-notes-generator",
8+
[
9+
"@semantic-release/npm",
10+
{
11+
"npmPublish": true,
12+
"pkgRoot": "."
13+
}
14+
],
15+
[
16+
"@semantic-release/exec",
17+
{
18+
"verifyReleaseCmd": "ARTIFACT=$(npm pack --ignore-scripts | tail -1) && rl-wrapper --artifact \"$ARTIFACT\" --name node-saml --version ${nextRelease.version} --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --build-env github_actions --suppress_output",
19+
"prepareCmd": "git diff --exit-code"
20+
}
21+
],
22+
"@semantic-release/github"
23+
]
24+
}

.travis.yml

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

package.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
"node": ">=12"
66
},
77
"devDependencies": {
8-
"@commitlint/cli": "^11.0.0",
9-
"@commitlint/config-conventional": "^11.0.0",
8+
"@commitlint/cli": "^20.3.1",
9+
"@commitlint/config-conventional": "^20.3.1",
10+
"@semantic-release/exec": "^7.0.3",
1011
"chai": "^4.2.0",
11-
"husky": "^4.3.0",
12+
"husky": "^9.1.7",
1213
"mocha": "^8.2.0",
13-
"should": "~1.2.1",
14-
"standard-version": "^9.0.0"
14+
"semantic-release": "^25.0.2",
15+
"should": "~1.2.1"
1516
},
1617
"main": "./lib",
1718
"repository": "https://github.com/auth0/node-saml",
@@ -32,12 +33,7 @@
3233
"xpath": "0.0.5"
3334
},
3435
"scripts": {
35-
"release": "standard-version",
36+
"prepare": "husky",
3637
"test": "mocha"
37-
},
38-
"husky": {
39-
"hooks": {
40-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
41-
}
4238
}
4339
}

0 commit comments

Comments
 (0)