fix: v0.12.3 —— 修正 Release 发布条件,支持手动勾选 publish 发版
- 「发布到 Release」以前只有在推 v* tag 时才跑,普通推送/PR 会显示 skipped, 容易以为坏了;现在条件写成 always() && (tag || 手动 publish) - workflow_dispatch 增加 publish 布尔输入:不打 tag 也能发版,用 v<版本> 作为 tag(不存在就按当前提交新建),省得同步工具漏推 tag - Release 任务里补上 checkout 和版本号读取,Release 标题用 VoiletMark <版本> - 用 always() 代替 !cancelled(),ARM runner 缺失导致 package 失败时也能收尾; 仍然会先检查 x86_64 的包在不在,缺了就不发 - README 写清楚两种发版方式和「skipped 是正常的」这一条
This commit is contained in:
@@ -8,6 +8,11 @@ on:
|
||||
tags: ["v*"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
publish:
|
||||
description: "发布 Release(用 v<版本> 当 tag,不必先打 tag)"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -101,12 +106,29 @@ jobs:
|
||||
release:
|
||||
name: 发布到 Release
|
||||
needs: package
|
||||
# ARM 那个 job 可能因为拿不到 arm runner 而失败,这里用 !cancelled() 照常收尾;
|
||||
# 下面单独检查 x86_64 的包在不在,缺了就不发 Release。
|
||||
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') }}
|
||||
# 只有两种情况发 Release:
|
||||
# 1. 推了 v* tag
|
||||
# 2. 手动 Run workflow 并勾上 publish
|
||||
# 普通推送(main / PR)只会留下 artifact,这一步显示 skipped 是正常的。
|
||||
# 用 always() 是为了 ARM 那个 job 失败(拿不到 arm runner)时这里照常收尾,
|
||||
# 下面会检查 x86_64 的包在不在,缺了就不发。
|
||||
if: >-
|
||||
always() && (
|
||||
startsWith(github.ref, 'refs/tags/') ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.publish)
|
||||
)
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 读取版本号
|
||||
id: meta
|
||||
run: |
|
||||
version=$(sed -n 's/^VERSION[[:space:]]*=[[:space:]]*//p' VoiletMark.pro | head -n1 | tr -d '[:space:]')
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: 下载所有产物
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
@@ -127,9 +149,13 @@ jobs:
|
||||
sha256sum ./*.deb ./*.rpm > SHA256SUMS
|
||||
cat SHA256SUMS
|
||||
|
||||
- name: 挂到对应 tag 的 Release
|
||||
- name: 挂到 Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
# 打 tag 时用那个 tag;手动发布时用 v<版本>(不存在就按当前提交新建)
|
||||
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('v{0}', steps.meta.outputs.version) }}
|
||||
target_commitish: ${{ github.sha }}
|
||||
name: VoiletMark ${{ steps.meta.outputs.version }}
|
||||
files: dist/*
|
||||
generate_release_notes: true
|
||||
fail_on_unmatched_files: true
|
||||
|
||||
Reference in New Issue
Block a user