Skip to content

Commit 99a4c2b

Browse files
committed
ci: add release workflow
1 parent 2611611 commit 99a4c2b

3 files changed

Lines changed: 68 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- "**"
57
pull_request:
68
workflow_dispatch:
79

@@ -15,7 +17,7 @@ jobs:
1517
with:
1618
fetch-depth: 0
1719
persist-credentials: false
18-
20+
1921
- name: Setup PNPM
2022
uses: pnpm/action-setup@v4
2123
with:
@@ -27,9 +29,9 @@ jobs:
2729
node-version-file: ".nvmrc"
2830
cache: "pnpm"
2931
registry-url: "https://registry.npmjs.org"
30-
32+
3133
- name: Install
3234
run: pnpm install --frozen-lockfile
3335

3436
- name: Build
35-
run: pnpm build:prod_publish
37+
run: pnpm build:prod_publish

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
id-token: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: true
22+
23+
- name: Setup PNPM
24+
uses: pnpm/action-setup@v4
25+
with:
26+
version: latest
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v6
30+
with:
31+
node-version-file: ".nvmrc"
32+
cache: "pnpm"
33+
registry-url: "https://registry.npmjs.org"
34+
35+
- name: Install
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Set build environment variables
39+
run: |
40+
echo "BUILD_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
41+
echo "BUILD_DATE=$(date -u +%Y-%m-%d)" >> $GITHUB_ENV
42+
43+
- name: Build
44+
run: pnpm build:prod_publish
45+
46+
- name: Publish to npm
47+
run: pnpm publish --no-git-checks --provenance
48+
49+
- name: Create GitHub Release
50+
uses: softprops/action-gh-release@v2
51+
with:
52+
generate_release_notes: true
53+
54+
- name: Bump package.json version
55+
run: |
56+
pnpm version $BUILD_VERSION --no-git-tag-version
57+
git config user.name "github-actions[bot]"
58+
git config user.email "github-actions[bot]@users.noreply.github.com"
59+
git add package.json
60+
git commit -m "chore: bump version to $BUILD_VERSION [skip ci]"
61+
git push origin HEAD:refs/heads/${{ github.event.repository.default_branch }}

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enable-pre-post-scripts=true
2+
access=public

0 commit comments

Comments
 (0)