mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-06-08 04:22:06 +08:00
chore: enhance auto-tag workflow with version validation and error handling
- Added error handling for git fetch command to ensure workflow fails on tag fetch issues. - Introduced a validation step to check the format of the new version tag, ensuring it adheres to semantic versioning. - Updated the conditional execution for the release job to prevent running if no new tag is generated, improving workflow reliability.
This commit is contained in:
parent
f440f47e57
commit
6fb415bfcb
17
.github/workflows/auto-tag.yml
vendored
17
.github/workflows/auto-tag.yml
vendored
@ -25,7 +25,8 @@ jobs:
|
||||
- name: Get latest tag
|
||||
id: get_latest_tag
|
||||
run: |
|
||||
git fetch --tags
|
||||
set -e
|
||||
git fetch --tags || exit 1
|
||||
latest_tag=$(git tag -l 'v*' --sort=-v:refname | head -n 1)
|
||||
if [ -z "$latest_tag" ]; then
|
||||
echo "version=v0.1.0" >> $GITHUB_OUTPUT
|
||||
@ -37,6 +38,14 @@ jobs:
|
||||
echo "version=$major.$minor.$new_patch" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Validate version
|
||||
run: |
|
||||
new_tag=${{ steps.get_latest_tag.outputs.version }}
|
||||
if [[ ! $new_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Invalid version format: $new_tag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Create new tag
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
@ -49,8 +58,10 @@ jobs:
|
||||
|
||||
release:
|
||||
needs: auto-tag
|
||||
if: success()
|
||||
uses: ./.github/workflows/release.yml@${{ github.sha }}
|
||||
if: |
|
||||
success() &&
|
||||
needs.auto-tag.outputs.new_tag != ''
|
||||
uses: ./.github/workflows/release.yml
|
||||
with:
|
||||
version: ${{ needs.auto-tag.outputs.new_tag }}
|
||||
secrets: inherit
|
||||
|
Loading…
x
Reference in New Issue
Block a user