@@ -18,35 +18,35 @@ jobs:
1818 id-token : write
1919
2020 steps :
21- - name : Checkout repository for tag detection
22- uses : actions/checkout@v4
23- with :
24- fetch-depth : 0
25-
26- - name : Detect version tag and extract info
21+ - name : Detect version tag from workflow event
2722 id : version
2823 run : |
29- COMMIT_SHA="${{ github.event.workflow_run.head_sha }}"
24+ HEAD_BRANCH="${{ github.event.workflow_run.head_branch }}"
25+
26+ echo "Workflow triggered by: $HEAD_BRANCH"
3027
31- TAG_NAME=$(git tag --points-at "$COMMIT_SHA" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
28+ if [[ "$HEAD_BRANCH" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
29+ TAG_NAME="$HEAD_BRANCH"
30+ VERSION="${TAG_NAME#v}"
3231
33- if [ -z "$TAG_NAME" ]; then
34- echo "❌ No version tag found at commit $COMMIT_SHA"
35- echo "Available tags at this commit:"
36- git tag --points-at "$COMMIT_SHA" || echo " (none)"
32+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
33+ echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT
34+ echo "artifact_name=${TAG_NAME}-build" >> $GITHUB_OUTPUT
35+
36+ echo "✅ Detected version tag: $TAG_NAME"
37+ echo " Version: $VERSION"
38+ echo " Artifact: ${TAG_NAME}-build"
39+ else
40+ echo "❌ Not triggered by a version tag: $HEAD_BRANCH"
41+ echo "This workflow should only run for version tags (vX.Y.Z)"
3742 exit 1
3843 fi
3944
40- VERSION="${TAG_NAME#v}"
41- echo "version=${VERSION}" >> $GITHUB_OUTPUT
42- echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT
43- echo "artifact_name=${TAG_NAME}-build" >> $GITHUB_OUTPUT
44- echo "✅ Detected version tag: $TAG_NAME"
45-
4645 - name : Checkout repository
4746 uses : actions/checkout@v4
4847 with :
4948 ref : ${{ steps.version.outputs.tag }}
49+ fetch-depth : 0
5050
5151 - name : Validate version matches tag
5252 run : |
0 commit comments