diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index 386e155..f2794fd 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -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