Skip to content

chore: bump version to 1.0.1 (#38) #17

chore: bump version to 1.0.1 (#38)

chore: bump version to 1.0.1 (#38) #17

Workflow file for this run

name: Build and Push Docker Image
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
on:
push:
branches:
- main
paths:
- 'app/core/version.py'
- 'pyproject.toml'
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CR_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Read version from version.py
id: get-version
run: |
# Try Python import first
VERSION=$(python -c "import sys; sys.path.insert(0, '.'); from app.core.version import __version__; print(__version__)" 2>/dev/null || echo "")
# Fallback to regex if import fails
if [ -z "${VERSION}" ]; then
VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]*' app/core/version.py || echo "0.0.0")
fi
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Read version: ${VERSION}"
- name: Set Docker image tag
id: set-tag
run: |
VERSION="${{ steps.get-version.outputs.VERSION }}"
echo "IMAGE_TAG=${VERSION}" >> $GITHUB_OUTPUT
echo "Building Docker image with version: ${VERSION}"
- name: Build and Push Docker image
working-directory: "./"
run: |
REPO_NAME="${GITHUB_REPOSITORY,,}"
IMAGE_TAG="${{ steps.set-tag.outputs.IMAGE_TAG }}"
# Build and tag with version
docker build -t ghcr.io/${REPO_NAME}:${IMAGE_TAG} .
docker push ghcr.io/${REPO_NAME}:${IMAGE_TAG}
# Also tag as latest
docker tag ghcr.io/${REPO_NAME}:${IMAGE_TAG} ghcr.io/${REPO_NAME}:latest
docker push ghcr.io/${REPO_NAME}:latest
- name: Create and Push Git Tag
run: |
VERSION="${{ steps.get-version.outputs.VERSION }}"
# Check if tag already exists
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists, skipping"
else
echo "Creating tag: $VERSION"
git tag $VERSION
git push origin $VERSION
fi