-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (60 loc) · 1.99 KB
/
build.yml
File metadata and controls
65 lines (60 loc) · 1.99 KB
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
62
63
64
65
name: Build plugin
on:
push:
branches: [main, master]
tags: ['**']
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
build:
name: Build Plugin
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: env use node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: build
run: |
npm install
npm run build
- name: upload build artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: plugin-build
path: |
dist/main.js
create-release:
name: Create Release
if: github.event_name == 'push' # no pr
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write # 允许无需 PAT 创建 Release
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./dist
- name: List downloaded artifacts
run: |
echo "Listing contents of ./dist:"
ls -R ./dist
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
# token: ${{ secrets.Your_token_secrets_name }} # PAT GitHub Token。可选一,换成你的PAT,否则报错: `Error: Error undefined: Parameter token or opts.auth is required`
token: ${{ secrets.GITHUB_TOKEN }} # 内置 Github Token。可选二
name: 'Release ${{ github.ref_name }}'
body: 'Release for tag ${{ github.ref_name }}'
artifacts: |
./dist/plugin-build/main.js
generateReleaseNotes: false # 自动根据 commits 生成 release notes。此外,这里应该导向一个更新日志页
prerelease: ${{ endsWith(github.ref_name, 'beta') }} # 是否预发布
makeLatest: ${{ !endsWith(github.ref_name, 'beta') }} # 是否最后一个版本
allowUpdates: true # 如果 tag 已存在,允许更新