diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8d77d668..d8a50b50 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,4 @@ -name: Upload Python Package to PyPI when a Release is Created - +name: Upload Python Package and Docker Image on Release on: release: types: [created] @@ -25,6 +24,44 @@ jobs: pip install setuptools wheel - name: Build package run: | - python setup.py sdist bdist_wheel # Could also be python -m build + python setup.py sdist bdist_wheel - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + + docker-publish: + name: Publish Docker image + runs-on: ubuntu-latest + needs: pypi-publish + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}