Skip to content

Commit 6c35a1e

Browse files
committed
Update action
1 parent 7d84b8a commit 6c35a1e

File tree

2 files changed

+83
-9
lines changed

2 files changed

+83
-9
lines changed

.github/workflows/create-release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
on:
2+
push:
3+
tags:
4+
- "v*"
5+
6+
name: Create Release
7+
8+
jobs:
9+
create-release:
10+
name: Publish Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Pull all submodule
17+
run: git submodule update --init --recursive
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: "16"
23+
24+
- name: Setup Git
25+
run: |
26+
git config user.name '${{secrets.MAINTAINER_NAME}}'
27+
git config user.email '${{secrets.MAINTAINER_EMAIL}}'
28+
29+
- name: Update package.json
30+
run: |
31+
# Extract the version from the git tag (e.g., "v1.0.0")
32+
version=$(echo "${{ github.ref }}" | sed -e 's/^refs\/tags\/v//')
33+
34+
# Update the package.json version using Node.js script
35+
node - <<EOF
36+
const fs = require('fs');
37+
const packageJson = JSON.parse(fs.readFileSync('package.json'));
38+
packageJson.version = "$version";
39+
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
40+
EOF
41+
42+
- uses: pnpm/action-setup@v2
43+
name: Install pnpm
44+
id: pnpm-install
45+
with:
46+
version: 7
47+
run_install: false
48+
49+
- name: Get pnpm store directory
50+
id: pnpm-cache
51+
shell: bash
52+
run: |
53+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
54+
55+
- uses: actions/cache@v3
56+
name: Setup pnpm cache
57+
with:
58+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
59+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
60+
restore-keys: |
61+
${{ runner.os }}-pnpm-store-
62+
63+
- name: Install dependencies
64+
run: pnpm install
65+
66+
- name: Build nextjs pages
67+
run: pnpm run build
68+
69+
- uses: actions/create-release@v1
70+
id: create_release
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
tag_name: ${{ github.ref }}
75+
release_name: ${{ github.ref }}
76+
draft: true

.github/workflows/publish.yml renamed to .github/workflows/publish-release.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
name: Publish Release
12
on:
2-
push:
3-
tags:
4-
- 'v*'
5-
6-
name: Create Release
3+
release:
4+
types:
5+
- published
76

87
jobs:
9-
publish:
8+
publish-release:
109
name: Publish Release
1110
runs-on: ubuntu-latest
1211
steps:
@@ -29,7 +28,7 @@ jobs:
2928
- name: Update package.json
3029
run: |
3130
# Extract the version from the git tag (e.g., "v1.0.0")
32-
version=$(echo "${{ github.ref }}" | sed -e 's/^refs\/tags\/v//')
31+
version=$(echo "${{ github.event.release.tag_name }}" | sed -e 's/^refs\/tags\/v//')
3332
3433
# Update the package.json version using Node.js script
3534
node - <<EOF
@@ -69,11 +68,10 @@ jobs:
6968
- name: Publish
7069
run: |
7170
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
72-
if [[ "${{ github.ref }}" == *"beta"* ]]; then
71+
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
7372
npm publish --tag beta
7473
else
7574
npm publish
7675
fi
7776
env:
7877
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
79-

0 commit comments

Comments
 (0)