88 push :
99 branches :
1010 - main
11+ - dev
12+ paths :
13+ - ' app/core/version.py'
14+ - ' pyproject.toml'
1115
1216concurrency :
1317 group : ${{ github.head_ref || github.run_id }}
@@ -30,14 +34,38 @@ jobs:
3034 username : ${{ github.actor }}
3135 password : ${{ secrets.CR_TOKEN }}
3236
37+ - name : Set up Python
38+ uses : actions/setup-python@v6
39+ with :
40+ python-version : ' 3.11'
41+
42+ - name : Read version from version.py
43+ id : get-version
44+ run : |
45+ # Try Python import first
46+ VERSION=$(python -c "import sys; sys.path.insert(0, '.'); from app.core.version import __version__; print(__version__)" 2>/dev/null || echo "")
47+ # Fallback to regex if import fails
48+ if [ -z "${VERSION}" ]; then
49+ VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]*' app/core/version.py || echo "0.0.0")
50+ fi
51+ echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
52+ echo "Read version: ${VERSION}"
53+
3354 - name : Set Docker image tag
3455 id : set-tag
3556 run : |
36- echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
57+ VERSION="${{ steps.get-version.outputs.VERSION }}"
58+ echo "IMAGE_TAG=${VERSION}" >> $GITHUB_OUTPUT
59+ echo "Building Docker image with version: ${VERSION}"
3760
3861 - name : Build and Push Docker image
3962 working-directory : " ./"
4063 run : |
4164 REPO_NAME="${GITHUB_REPOSITORY,,}"
42- docker build -t ghcr.io/${REPO_NAME}:${{ steps.set-tag.outputs.IMAGE_TAG }} .
43- docker push ghcr.io/${REPO_NAME}:${{ steps.set-tag.outputs.IMAGE_TAG }}
65+ IMAGE_TAG="${{ steps.set-tag.outputs.IMAGE_TAG }}"
66+ # Build and tag with version
67+ docker build -t ghcr.io/${REPO_NAME}:${IMAGE_TAG} .
68+ docker push ghcr.io/${REPO_NAME}:${IMAGE_TAG}
69+ # Also tag as latest
70+ docker tag ghcr.io/${REPO_NAME}:${IMAGE_TAG} ghcr.io/${REPO_NAME}:latest
71+ docker push ghcr.io/${REPO_NAME}:latest
0 commit comments