-
Notifications
You must be signed in to change notification settings - Fork 22
61 lines (50 loc) · 1.62 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Publish Package
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
environment: Release
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 安装Pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: 安装依赖
run: pnpm i --no-frozen-lockfile --shamefully-hoist
- name: 设置Node的版本
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org/'
cache: 'pnpm'
- name: 构建代码
run: pnpm build:npm
- name: 发布版本
run: pnpm pub
env:
NODE_AUTH_TOKEN: '${{secrets.NPM_AUTH_TOKEN}}'
- name: 获取当前的版本号
run: |
echo "version=$(grep -o '"version": *"[^"]*"' package.json | awk -F'"' '{print $4}')" >> "$GITHUB_ENV"
- name: 是否是预发布
run: |
echo "prerelease=$([[ ${{ env.version }} == *-* ]] && echo 'true' || echo 'false')" >> "$GITHUB_ENV"
- name: 打印信息
run: |
echo "version: ${{ env.version }}"
echo "prerelease: ${{ env.prerelease }}"
- name: 打个标签
uses: ncipollo/release-action@v1
with:
tag: "v${{ env.version }}"
draft: false
prerelease: ${{ env.prerelease }}
allowUpdates: true
generateReleaseNotes: true
body: "Please refer to [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/v${{ env.version }}/CHANGELOG.md) for details."
token: ${{ secrets.TOKEN }}