feat: 更新发布工作流逻辑,添加条件判断以控制作业执行,优化版本解析

This commit is contained in:
ryan
2026-03-10 23:11:17 +08:00
parent e5c01f12be
commit e041240423
+23 -3
View File
@@ -12,6 +12,7 @@ jobs:
prepare: prepare:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
should_run: ${{ steps.version.outputs.should_run }}
version: ${{ steps.version.outputs.version }} version: ${{ steps.version.outputs.version }}
is_prerelease: ${{ steps.version.outputs.is_prerelease }} is_prerelease: ${{ steps.version.outputs.is_prerelease }}
steps: steps:
@@ -23,11 +24,19 @@ jobs:
- name: Resolve version metadata - name: Resolve version metadata
id: version id: version
run: | run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then SHOULD_RUN=true
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
if [[ "${GITHUB_REF}" == refs/heads/main ]] && [[ -n "$POINTED_TAG" ]]; then
SHOULD_RUN=false
VERSION="$POINTED_TAG"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF_NAME}" VERSION="${GITHUB_REF_NAME}"
else else
VERSION="$(git describe --tags)" VERSION="$(git describe --tags)"
fi fi
echo "should_run=$SHOULD_RUN" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
echo "is_prerelease=false" >> "$GITHUB_OUTPUT" echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
@@ -37,6 +46,7 @@ jobs:
build-frontend: build-frontend:
needs: prepare needs: prepare
if: needs.prepare.outputs.should_run == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -69,6 +79,7 @@ jobs:
needs: needs:
- prepare - prepare
- build-frontend - build-frontend
if: needs.prepare.outputs.should_run == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
@@ -129,6 +140,7 @@ jobs:
build-agent-binaries: build-agent-binaries:
needs: prepare needs: prepare
if: needs.prepare.outputs.should_run == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
@@ -186,12 +198,20 @@ jobs:
- prepare - prepare
- build-binaries - build-binaries
- build-agent-binaries - build-agent-binaries
if: needs.prepare.outputs.should_run == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Download Binary Artifacts - name: Download Server Artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
pattern: "*-*" pattern: "server-*"
path: dist
merge-multiple: true
- name: Download Agent Artifacts
uses: actions/download-artifact@v4
with:
pattern: "agent-*"
path: dist path: dist
merge-multiple: true merge-multiple: true