Skip to content

Workflow file for this run

name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI and to Dockerhub
on:
release:
types:
- published
push:
jobs:
build-n-publish:
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI and to Dockerhub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install pypa
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build dist
run: |
python -m build --sdist --wheel
- name: Publish distribution 📦 to Test PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
# Here comes the Docker stuff, uses the .whl built in previous steps
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
${{ secrets.DOCKERHUB_USER }}/fastflow
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v3
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USER }}/fastflow:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USER }}/fastflow:buildcache,mode=max
- name: Push Docker image
uses: docker/build-push-action@v3
if: github.event_name == 'release'
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USER }}/fastflow:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USER }}/fastflow:buildcache,mode=max