chore: publish tag alpha support

chore: update alpha and release workflows to include version consistency checks
This commit is contained in:
Tunglies
2025-06-05 20:56:15 +08:00
Unverified
parent 80f550d67e
commit 44b7af0c6e
4 changed files with 60 additions and 6 deletions

View File

@@ -6,6 +6,10 @@ on:
# 应当通过 git tag 来触发构建
# workflow_dispatch:
push:
# 应当限制在 dev 分支上触发发布。
branches:
- dev
# 应当限制 v*.*.*-alpha* 的 tag 来触发发布。
tags:
- "v*.*.*-alpha*"
permissions: write-all
@@ -18,8 +22,37 @@ concurrency:
group: "${{ github.workflow }} - ${{ github.head_ref || github.ref }}"
jobs:
check_alpha_tag:
name: Check Alpha Tag package.json Version Consistency
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check tag and package.json version
id: check_tag
run: |
TAG_REF="${GITHUB_REF##*/}"
echo "Current tag: $TAG_REF"
if [[ ! "$TAG_REF" =~ -alpha ]]; then
echo "Current tag is not an alpha tag."
exit 1
fi
PKG_VERSION=$(jq -r .version package.json)
echo "package.json version: $PKG_VERSION"
if [[ "$PKG_VERSION" != *alpha* ]]; then
echo "package.json version is not an alpha version."
exit 1
fi
if [[ "$TAG_REF" != "v$PKG_VERSION" ]]; then
echo "Tag ($TAG_REF) does not match package.json version (v$PKG_VERSION)."
exit 1
fi
echo "Alpha tag and package.json version are consistent."
delete_old_assets:
name: Delete Old Alpha Release Assets and Tags
needs: check_alpha_tag
runs-on: ubuntu-latest
steps:
- name: Delete Old Alpha Tags Except Latest

View File

@@ -5,9 +5,10 @@ on:
# ! 不再使用 workflow_dispatch 触发。
# workflow_dispatch:
push:
# ? 应当限制在 main 分支上触发发布。
# branches:
# - main
# 应当限制在 main 分支上触发发布。
branches:
- main
# 应当限制 v*.*.* 的 tag 触发发布。
tags:
- "v*.*.*"
permissions: write-all
@@ -20,8 +21,28 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
check_tag_version:
name: Check Release Tag and package.json Version Consistency
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check tag and package.json version
run: |
TAG_REF="${GITHUB_REF##*/}"
echo "Current tag: $TAG_REF"
PKG_VERSION=$(jq -r .version package.json)
echo "package.json version: $PKG_VERSION"
if [[ "$TAG_REF" != "v$PKG_VERSION" ]]; then
echo "Tag ($TAG_REF) does not match package.json version (v$PKG_VERSION)."
exit 1
fi
echo "Tag and package.json version are consistent."
release:
name: Release Build
needs: check_tag_version
strategy:
fail-fast: false
matrix:

View File

@@ -1,6 +1,6 @@
{
"name": "clash-verge",
"version": "2.3.0-alpha",
"version": "2.3.0",
"license": "GPL-3.0-only",
"scripts": {
"dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev",
@@ -112,4 +112,4 @@
},
"type": "module",
"packageManager": "pnpm@9.13.2"
}
}

View File

@@ -29,7 +29,7 @@ const runRelease = () =>
// 2. 判断是否需要打 tag
function isSemver(version) {
return /^v?\d+\.\d+\.\d+(-alpha)?$/.test(version);
return /^v?\d+\.\d+\.\d+(-[0-9A-Za-z-.]+)?$/.test(version);
}
async function run() {