Skip to content

Commit df2e598

Browse files
committed
Add release pipeline
1 parent fa93667 commit df2e598

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Use Node.js
1717
uses: actions/setup-node@v4
1818
with:
19-
node-version: '22'
19+
node-version-file: ".nvmrc"
2020

2121
- name: Install dependencies
2222
run: 'npm ci'

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release on npm
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- package.json
9+
10+
permissions:
11+
contents: write
12+
pull-requests: read
13+
id-token: write
14+
15+
jobs:
16+
build_and_publish:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Node
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version-file: ".nvmrc"
26+
27+
- name: Install dependencies
28+
run: npm install
29+
30+
- name: Build
31+
run: |
32+
npm run clean
33+
npm run build
34+
35+
- id: publish
36+
name: Publish to NPM
37+
uses: JS-DevTools/npm-publish@v3
38+
with:
39+
token: ${{ secrets.NPM_TOKEN }}
40+
dry-run: false
41+
provenance: true
42+
access: public
43+
44+
- name: Post-publish
45+
if: steps.publish.outputs.type != 'none'
46+
run: |
47+
echo "Published ${{ steps.publish.outputs.type }} version: ${{ steps.publish.outputs.version }}"
48+
49+
- name: Publish skipped
50+
if: steps.publish.outputs.type == 'none'
51+
run: |
52+
echo "Version in package.json has not changed. Skipping."
53+
exit 0
54+
55+
- name: Configure changelog
56+
if: steps.publish.outputs.type != 'none'
57+
run: |
58+
echo '{"categories": [], "template": "## Commits:\n\n${{ '${{UNCATEGORIZED}}' }}", "pr_template": ${{ '"- ${{MERGE_SHA}} ${{TITLE}}"' }} }' > changelog_config.json
59+
echo "last_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
60+
echo "curr_commit=$(git rev-parse HEAD)" >> $GITHUB_ENV
61+
62+
- name: Generate changelog
63+
if: steps.publish.outputs.type != 'none'
64+
id: github_release
65+
uses: mikepenz/[email protected]
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
with:
69+
fromTag: "${{ env.last_tag }}"
70+
toTag: ${{ github.ref }}
71+
commitMode: true
72+
configuration: changelog_config.json
73+
74+
- name: Create release
75+
if: steps.publish.outputs.type != 'none'
76+
id: create_release
77+
uses: actions/create-release@v1
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
with:
81+
tag_name: v${{ steps.publish.outputs.version }}
82+
release_name: v${{ steps.publish.outputs.version }}
83+
commitish: ${{ github.ref }}
84+
body: ${{ steps.github_release.outputs.changelog }}
85+
draft: false
86+
prerelease: false

.nvmrc

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

0 commit comments

Comments
 (0)