Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Deploy to PyPI and DockerHub

on:
workflow_dispatch:

jobs:
pypi-deploy:
uses: ./.github/workflows/pypi.yml

dockerhub-deploy:
needs: pypi
uses: ./.github/workflows/dockerhub.yml
50 changes: 50 additions & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy To DockerHub

on:
workflow_call:
workflow_dispatch:

jobs:
dockerhub-deploy:
runs-on: ubuntu-latest
environment: dockerhub

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "
try:
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
print(data['project']['version'])
except Exception as e:
print(f'Error reading version: {e}', file=sys.stderr)
exit(1)
")
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${{ steps.get_version.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/photomapai:latest
41 changes: 14 additions & 27 deletions .github/workflows/release.yml → .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Release to PyPi & DockerHub
name: Release to PyPi

on:
workflow_call:
workflow_dispatch:

jobs:
release:
pypi-deploy:
runs-on: ubuntu-latest
environment: pypi

Expand All @@ -24,7 +25,16 @@ jobs:
- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
VERSION=$(python -c "
try:
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
print(data['project']['version'])
except Exception as e:
print(f'Error reading version: {e}', file=sys.stderr)
exit(1)
")
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Tag the release
Expand All @@ -50,27 +60,4 @@ jobs:
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://upload.pypi.org/legacy/
# env:
# TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build Docker image
run: |
VERSION=${{ steps.get_version.outputs.version }}
docker build -f docker/Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${VERSION} .
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${VERSION} ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:latest

- name: Push Docker image (versioned)
run: |
VERSION=${{ steps.get_version.outputs.version }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${VERSION}

- name: Push Docker image (latest)
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:latest
repository-url: https://upload.pypi.org/legacy/
Loading