Skip to content

Commit 221acd0

Browse files
committed
ci: auto publish
1 parent 254bed1 commit 221acd0

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

.github/workflows/auto-publish.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
- "v*"
77

88
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 输入您将要发布的版本号(默认使用 packages/fluent-editor/package.json 中的版本号),例如:`0.1.0`。
12+
required: false
13+
type: string
914

1015
jobs:
1116
build:
@@ -39,9 +44,24 @@ jobs:
3944
${{ runner.os }}-pnpm-store-
4045
- name: Install dependencies
4146
run: pnpm i --no-frozen-lockfile
47+
- name: Get version
48+
id: ver
49+
run: |
50+
# 优先用手动输入的版本号
51+
if [ -n "${{ inputs.version }}" ]; then
52+
VERSION="${{ inputs.version }}"
53+
else
54+
VERSION="$(node -p "require('./packages/fluent-editor/package.json').version")"
55+
fi
56+
echo "version: $VERSION"
57+
echo "value=$VERSION" >> $GITHUB_OUTPUT
4258
43-
- name: Run Build search-box
44-
run: pnpm build:lib
59+
- name: Build lib
60+
run: |
61+
pnpm build:lib
62+
cd packages/fluent-editor
63+
echo "version: ${{ steps.ver.outputs.value }}"
64+
pnpm pre-release -v ${{ steps.ver.outputs.value }}
4565
4666
- name: Parse Publish tag
4767
id: parse_tag
@@ -58,7 +78,15 @@ jobs:
5878
fi
5979
6080
- name: Publish @opentiny/fluent-editor
61-
run: pnpm pub
81+
run: |
82+
echo "ls"
83+
ls
84+
cd packages/fluent-editor/dist
85+
if [ "${{ steps.parse_tag.outputs.dist_tag }}" = "latest" ]; then
86+
echo "npm publish"
87+
else
88+
echo "npm publish --tag ${{ steps.parse_tag.outputs.dist_tag }}"
89+
fi
6290
env:
6391
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6492

packages/fluent-editor/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"types": "dist/types/index.d.ts",
2929
"scripts": {
3030
"dev": "vite build --watch",
31-
"build": "vite build && node scripts/pre-release.cjs",
31+
"build": "vite build",
32+
"pre-release": "node scripts/pre-release.cjs",
3233
"test": "jest",
3334
"pub": "cd dist && npm publish"
3435
},

0 commit comments

Comments
 (0)