1- name : Release to PyPi & DockerHub
1+ name : Release to PyPi
22
33on :
4+ workflow_call :
45 workflow_dispatch :
56
67jobs :
7- release :
8+ pypi-deploy :
89 runs-on : ubuntu-latest
910 environment : pypi
1011
2425 - name : Extract version from pyproject.toml
2526 id : get_version
2627 run : |
27- VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
28+ VERSION=$(python -c "
29+ try:
30+ import tomllib
31+ with open('pyproject.toml', 'rb') as f:
32+ data = tomllib.load(f)
33+ print(data['project']['version'])
34+ except Exception as e:
35+ print(f'Error reading version: {e}', file=sys.stderr)
36+ exit(1)
37+ ")
2838 echo "version=$VERSION" >> $GITHUB_OUTPUT
2939
3040 - name : Tag the release
5060 - name : Publish to PyPI
5161 uses : pypa/gh-action-pypi-publish@release/v1
5262 with :
53- repository-url : https://upload.pypi.org/legacy/
54- # env:
55- # TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
56-
57- - name : Log in to DockerHub
58- uses : docker/login-action@v3
59- with :
60- username : ${{ secrets.DOCKERHUB_USERNAME }}
61- password : ${{ secrets.DOCKERHUB_TOKEN }}
62-
63- - name : Build Docker image
64- run : |
65- VERSION=${{ steps.get_version.outputs.version }}
66- docker build -f docker/Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${VERSION} .
67- docker tag ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${VERSION} ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:latest
68-
69- - name : Push Docker image (versioned)
70- run : |
71- VERSION=${{ steps.get_version.outputs.version }}
72- docker push ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${VERSION}
73-
74- - name : Push Docker image (latest)
75- run : |
76- docker push ${{ secrets.DOCKERHUB_USERNAME }}/photomapai:latest
63+ repository-url : https://upload.pypi.org/legacy/
0 commit comments