11name : build
2+
23on :
4+ push :
5+ tags :
6+ - ' v*'
37 schedule :
48 - cron : " 0 16 * * *"
59 workflow_dispatch :
610
711jobs :
812 build :
913 runs-on : ubuntu-latest
14+
1015 steps :
1116 - name : Checkout
1217 uses : actions/checkout@v7
1318 with :
1419 ref : " main"
1520 submodules : recursive
1621
17- - uses : pnpm/action-setup@v6
18- name : Install pnpm
22+ - name : Install pnpm
23+ uses : pnpm/action-setup@v6
1924 with :
2025 version : 10
2126 cache : true
2227
23- - name : Set up Node.js 16-nightly, latest, node
28+ - name : Set up Node.js
2429 uses : actions/setup-node@v6
2530 with :
2631 node-version : ' latest'
4853 rm -f submodules_before.txt submodules_after.txt
4954
5055 - name : Update package version if submodules changed
51- if : steps.check_submodules.outputs.has_updates == 'true'
56+ if : steps.check_submodules.outputs.has_updates == 'true' && github.event_name != 'push'
5257 run : |
5358 pnpm version patch --no-git-tag-version
5459
@@ -61,43 +66,52 @@ jobs:
6166 git push origin main
6267
6368 - name : Install dependencies
64- if : steps.check_submodules.outputs.has_updates == 'true'
69+ if : steps.check_submodules.outputs.has_updates == 'true' || github.event_name == 'push'
6570 run : |
6671 pnpm i --no-frozen-lockfile
6772 cd src/sub/backend
6873 pnpm i --no-frozen-lockfile
6974
7075 - name : Bundle
71- if : steps.check_submodules.outputs.has_updates == 'true'
76+ if : steps.check_submodules.outputs.has_updates == 'true' || github.event_name == 'push'
7277 run : |
7378 pnpm build
7479
75- - id : tag
76- name : Generate release tag
77- if : steps.check_submodules.outputs.has_updates == 'true'
80+ - name : Generate release tag
81+ id : tag
82+ if : steps.check_submodules.outputs.has_updates == 'true' || github.event_name == 'push'
7883 run : |
79- SUBSTORE_RELEASE=`node --eval="process.stdout.write(require('./package.json').version)"`
80- echo "release_tag=$SUBSTORE_RELEASE" >> $GITHUB_OUTPUT
84+ if [ "${{ github.event_name }}" == "push" ]; then
85+ # 从推送的 tag 获取版本号
86+ TAG_NAME="${{ github.ref_name }}"
87+ # 移除 v 前缀(如果存在)
88+ VERSION="${TAG_NAME#v}"
89+ echo "release_tag=$VERSION" >> $GITHUB_OUTPUT
90+ else
91+ # 从 package.json 获取版本号
92+ SUBSTORE_RELEASE=`node --eval="process.stdout.write(require('./package.json').version)"`
93+ echo "release_tag=$SUBSTORE_RELEASE" >> $GITHUB_OUTPUT
94+ fi
8195
8296 - name : Prepare release
83- if : steps.check_submodules.outputs.has_updates == 'true'
97+ if : steps.check_submodules.outputs.has_updates == 'true' || github.event_name == 'push'
8498 run : |
8599 pnpm i -D conventional-changelog-cli
86100 npx conventional-changelog -p cli -i CHANGELOG.md -s
87101
88102 - name : Release
89103 uses : softprops/action-gh-release@v1
90- if : steps.check_submodules.outputs.has_updates == 'true'
104+ if : steps.check_submodules.outputs.has_updates == 'true' || github.event_name == 'push'
91105 env :
92106 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
93107 with :
94108 body_path : ./CHANGELOG.md
95- tag_name : ${{ steps.tag.outputs.release_tag }}
109+ tag_name : ${{ github.event_name == 'push' && github.ref_name || steps.tag.outputs.release_tag }}
96110 files : |
97111 ./dist/_worker.js
98112
99113 - name : Git push assets to "release" branch
100- if : steps.check_submodules.outputs.has_updates == 'true'
114+ if : steps.check_submodules.outputs.has_updates == 'true' || github.event_name == 'push'
101115 run : |
102116 cd dist || exit 1
103117 git init
0 commit comments