From c4ecb7cede90cc8cffd56978fecec27d06fac12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=85=8E=E9=A5=BC=E6=9E=9C=E5=AD=90=E5=8D=B7=E9=B2=A8?= =?UTF-8?q?=E9=B1=BC=E8=BE=A3=E6=A4=92?= Date: Mon, 30 Dec 2024 18:42:18 +0800 Subject: [PATCH] chore: refine auto-tag workflow with version output and enhanced debugging - Changed output variable from 'new_tag' to 'version' for clarity in the auto-tag job. - Introduced a new version variable to store the generated version, improving readability. - Added debug steps to output version information and job outputs, aiding in troubleshooting. - Updated validation step to provide clearer error messages and confirmation of version validation success. --- .github/workflows/auto-tag.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index f2794fd..ab5df6d 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -16,7 +16,7 @@ jobs: auto-tag: runs-on: ubuntu-22.04 outputs: - new_tag: ${{ steps.get_latest_tag.outputs.version }} + version: ${{ steps.get_latest_tag.outputs.version }} steps: - uses: actions/checkout@v4 with: @@ -29,22 +29,26 @@ jobs: 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 + new_version="v0.1.0" else major=$(echo $latest_tag | cut -d. -f1) minor=$(echo $latest_tag | cut -d. -f2) patch=$(echo $latest_tag | cut -d. -f3) new_patch=$((patch + 1)) - echo "version=$major.$minor.$new_patch" >> $GITHUB_OUTPUT + new_version="$major.$minor.$new_patch" fi + echo "version=$new_version" >> $GITHUB_OUTPUT + echo "Generated version: $new_version" - name: Validate version run: | - new_tag=${{ steps.get_latest_tag.outputs.version }} + new_tag="${{ steps.get_latest_tag.outputs.version }}" + echo "Validating version: $new_tag" if [[ ! $new_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Invalid version format: $new_tag" + echo "::error::Invalid version format: $new_tag" exit 1 fi + echo "Version validation passed" - name: Create new tag env: @@ -56,12 +60,16 @@ jobs: git tag -a $new_tag -m "Release $new_tag" git push origin $new_tag + - name: Debug output + run: | + echo "Version output: ${{ steps.get_latest_tag.outputs.version }}" + echo "Job outputs: ${{ toJSON(needs.auto-tag.outputs) }}" + echo "::debug::Version value: ${{ steps.get_latest_tag.outputs.version }}" + release: needs: auto-tag - if: | - success() && - needs.auto-tag.outputs.new_tag != '' + if: success() && needs.auto-tag.outputs.version != '' uses: ./.github/workflows/release.yml with: - version: ${{ needs.auto-tag.outputs.new_tag }} + version: ${{ needs.auto-tag.outputs.version }} secrets: inherit