11name : Create GitHub Release
22
33on :
4+ workflow_run :
5+ workflows : ["Build and Push Docker Image"]
6+ types :
7+ - completed
8+ branches :
9+ - main
10+ - dev
411 push :
512 tags :
6- - ' *' # Trigger on any tag push
13+ - ' *' # Also trigger on manual tag pushes
714
815
916jobs :
1017 release :
1118 runs-on : ubuntu-latest
19+ # Only run if the triggering workflow succeeded
20+ if : ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
1221
1322 permissions :
1423 packages : write
2029 with :
2130 fetch-depth : 0 # Fetch all history for all tags and branches
2231 fetch-tags : true # Fetch all tags
32+ ref : ${{ github.event.workflow_run.head_branch || github.ref }}
2333
2434 - name : Set up Python
2535 uses : actions/setup-python@v6
@@ -34,10 +44,26 @@ jobs:
3444 - name : Get current tag
3545 id : get-tag
3646 run : |
37- # Get the tag that triggered this workflow
38- TAG_NAME=${GITHUB_REF#refs/tags/}
39- echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT
40- echo "Current tag: ${TAG_NAME}"
47+ # If triggered by workflow_run, read version from version.py
48+ if [ "${{ github.event_name }}" = "workflow_run" ]; then
49+ # Read version from version.py (same as CI workflow did)
50+ VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]*' app/core/version.py || echo "")
51+ if [ -z "${VERSION}" ]; then
52+ # Fallback: try Python import
53+ VERSION=$(python -c "import sys; sys.path.insert(0, '.'); from app.core.version import __version__; print(__version__)" 2>/dev/null || echo "")
54+ fi
55+ if [ -z "${VERSION}" ]; then
56+ echo "Error: Could not read version from version.py"
57+ exit 1
58+ fi
59+ echo "TAG_NAME=${VERSION}" >> $GITHUB_OUTPUT
60+ echo "Tag from version.py: ${VERSION}"
61+ else
62+ # If triggered by tag push, get from GITHUB_REF
63+ TAG_NAME=${GITHUB_REF#refs/tags/}
64+ echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT
65+ echo "Current tag from push: ${TAG_NAME}"
66+ fi
4167
4268 - name : Checkout tag commit
4369 run : |
0 commit comments