1- name : Release
1+ name : Release Verify
22
33on :
44 push :
5- tags :
6- - ' v*'
75 branches :
86 - ' **'
97 paths :
108 - ' .github/workflows/release.yaml'
119 - ' .github/workflows/check.yaml'
10+ - ' .github/workflows/publish.yaml'
11+ - ' .github/workflows/prepare-release.yaml'
1212 - ' scripts/compile.ts'
1313 - ' scripts/checksum.ts'
1414 - ' scripts/platforms.ts'
1515 - ' scripts/release.ts'
16+ - ' scripts/publish-release.ts'
17+ - ' scripts/prepare-release.ts'
1618 - ' scripts/smoke.ts'
1719 - ' docs/installation.md'
1820 - ' LICENSE*'
1921 - ' tests/compile.test.ts'
2022 - ' tests/release.test.ts'
23+ - ' tests/publish-release.test.ts'
24+ - ' tests/prepare-release.test.ts'
2125 - ' package.json'
2226 - ' bun.lockb'
2327 - ' bump.config.ts'
2428 - ' .bun-version'
2529 workflow_dispatch :
30+ workflow_call :
31+ inputs :
32+ publish :
33+ description : 验收通过后创建标签并发布
34+ type : boolean
35+ default : false
2636
2737permissions :
2838 contents : read
2939
3040concurrency :
31- group : release-${{ github.ref }}
32- cancel-in-progress : ${{ github.ref_type != 'tag' }}
41+ group : release-${{ inputs.publish && 'publish' || github.ref }}
42+ cancel-in-progress : ${{ !inputs.publish }}
3343
3444jobs :
3545 metadata :
3646 name : 校验版本与发布目标
3747 runs-on : ubuntu-24.04
3848 outputs :
39- tag : ${{ steps.metadata.outputs.tag }}
40- prerelease : ${{ steps.metadata.outputs.prerelease }}
4149 matrix : ${{ steps.metadata.outputs.matrix }}
4250 steps :
4351 - uses : actions/checkout@v5
52+ with :
53+ ref : ${{ github.sha }}
54+ fetch-depth : 0
4455 - uses : oven-sh/setup-bun@v2
4556 with :
4657 bun-version-file : .bun-version
47- - name : 校验标签并生成产物清单
58+ - name : 校验版本并生成产物清单
4859 id : metadata
49- run : bun scripts/release.ts metadata
50- - name : 检查发布状态
51- if : github.event_name == 'push' && github.ref_type == 'tag'
60+ run : bun scripts/release.ts metadata ${{ inputs.publish && '--publish' || '' }}
61+ - name : 检查发布请求、主分支与已有版本
62+ if : inputs.publish
5263 env :
5364 GH_TOKEN : ${{ github.token }}
54- RELEASE_TAG : ${{ steps.metadata.outputs.tag }}
55- run : |
56- if state=$(gh release view "$RELEASE_TAG" --json isDraft --jq .isDraft); then
57- if [ "$state" != 'true' ]; then
58- echo '该标签已经公开发布,请使用新版本标签。'
59- exit 1
60- fi
61- fi
65+ run : bun scripts/publish-release.ts check
6266
6367 checks :
6468 needs : metadata
65- if : github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
69+ if : inputs.publish || github.event_name == 'workflow_dispatch'
6670 uses : ./.github/workflows/check.yaml
71+ with :
72+ ref : ${{ github.sha }}
73+ publish : ${{ inputs.publish || false }}
6774
6875 build :
6976 name : 验收 ${{ matrix.name }}
8188 steps :
8289 - name : 检出待验收提交
8390 uses : actions/checkout@v5
91+ with :
92+ ref : ${{ github.sha }}
8493 - name : 安装固定版本 Bun
8594 uses : oven-sh/setup-bun@v2
8695 with :
@@ -138,6 +147,8 @@ jobs:
138147 runs-on : ubuntu-24.04
139148 steps :
140149 - uses : actions/checkout@v5
150+ with :
151+ ref : ${{ github.sha }}
141152 - uses : oven-sh/setup-bun@v2
142153 with :
143154 bun-version-file : .bun-version
@@ -165,19 +176,20 @@ jobs:
165176 overwrite : true
166177
167178 release :
168- name : 发布完整标签产物
179+ name : 创建标签并发布已验收产物
169180 needs : [metadata, checks, artifacts]
170- if : github.event_name == 'push' && github.ref_type == 'tag'
181+ if : inputs.publish
171182 runs-on : ubuntu-24.04
172183 permissions :
173184 contents : write
174185 env :
175186 GH_TOKEN : ${{ github.token }}
176187 GH_REPO : ${{ github.repository }}
177- RELEASE_TAG : ${{ needs.metadata.outputs.tag }}
178- RELEASE_PRERELEASE : ${{ needs.metadata.outputs.prerelease }}
179188 steps :
180189 - uses : actions/checkout@v5
190+ with :
191+ ref : ${{ github.sha }}
192+ fetch-depth : 0
181193 - uses : oven-sh/setup-bun@v2
182194 with :
183195 bun-version-file : .bun-version
@@ -188,34 +200,5 @@ jobs:
188200 - name : 核对待上传文件
189201 working-directory : dist
190202 run : sha256sum --check SHA256SUMS
191- - name : 生成下载与安装说明
192- run : |
193- bun scripts/release.ts notes > release-notes.md
194- gh api --method POST "repos/$GH_REPO/releases/generate-notes" \
195- -f tag_name="$RELEASE_TAG" --jq .body >> release-notes.md
196- - name : 创建或恢复未公开草稿
197- run : |
198- if state=$(gh release view "$RELEASE_TAG" --json isDraft --jq .isDraft); then
199- if [ "$state" != 'true' ]; then
200- echo '该标签已经公开发布,请使用新版本标签。'
201- exit 1
202- fi
203- gh release edit "$RELEASE_TAG" --title "java-run $RELEASE_TAG" \
204- --notes-file release-notes.md --prerelease="$RELEASE_PRERELEASE"
205- else
206- gh release create "$RELEASE_TAG" --verify-tag --draft \
207- --notes-file release-notes.md --title "java-run $RELEASE_TAG" \
208- --prerelease="$RELEASE_PRERELEASE"
209- fi
210- - name : 上传完整资产并核对草稿
211- run : |
212- gh release upload "$RELEASE_TAG" dist/* --clobber
213- gh release view "$RELEASE_TAG" --json assets --jq '[.assets[].name]' \
214- | bun scripts/release.ts verify-assets
215- - name : 公开已验收版本
216- run : |
217- if [ "$RELEASE_PRERELEASE" = 'true' ]; then
218- gh release edit "$RELEASE_TAG" --draft=false --prerelease=true --latest=false
219- else
220- gh release edit "$RELEASE_TAG" --draft=false --prerelease=false
221- fi
203+ - name : 创建标签、上传草稿资产并公开版本
204+ run : bun scripts/publish-release.ts publish
0 commit comments