Skip to content

Commit 86e5e82

Browse files
committed
ci: add github workflow
1 parent 3a4ff53 commit 86e5e82

2 files changed

Lines changed: 67 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build plugin
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
tags: ['**']
7+
pull_request:
8+
branches: [main, master]
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: checkout repo
16+
uses: actions/checkout@v4
17+
- name: Install pnpm
18+
uses: pnpm/action-setup@v4
19+
with:
20+
version: 10.10.0
21+
- name: env use node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '22'
25+
cache: pnpm
26+
- name: build
27+
run: |
28+
pnpm install --frozen-lockfile
29+
pnpm build
30+
- name: upload build artifact
31+
if: always()
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: obsidian-any-block
35+
path: |
36+
dist/main.js
37+
38+
create-release:
39+
name: Create Release
40+
if: github.event_name == 'push' # no pr
41+
needs: [build]
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Download all artifacts
45+
uses: actions/download-artifact@v4
46+
with:
47+
path: ./dist
48+
49+
- name: List downloaded artifacts
50+
run: |
51+
echo "Listing contents of ./dist:"
52+
ls -R ./dist
53+
54+
- name: Create Release
55+
if: startsWith(github.ref, 'refs/tags/')
56+
uses: ncipollo/release-action@v1
57+
with:
58+
token: ${{ secrets.AnyBlockPro_Repo }}
59+
name: 'Release ${{ github.ref_name }}'
60+
body: 'Release for tag ${{ github.ref_name }}'
61+
artifacts: |
62+
./dist/main.js
63+
generateReleaseNotes: false # 自动根据 commits 生成 release notes。此外,这里应该导向一个更新日志页
64+
prerelease: true # 是否预发布 (可以在release上修改该项,我就不判断tag是否beta结尾了)
65+
makeLatest: false # 是否最后一个版本 (可以在release上修改该项,我就不判断tag是否beta结尾了)
66+
allowUpdates: true # 如果 tag 已存在,允许更新

vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default defineConfig({
55
lib: { // Library 模式:输出单个 ES 模块文件
66
entry: 'src/index.ts',
77
formats: ['es'],
8-
fileName: () => 'hello-world.js', // 输出文件名
8+
fileName: () => 'main.js', // 输出文件名
99
},
1010
rollupOptions: {
1111
external: [],

0 commit comments

Comments
 (0)