1.25.13 #515
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload Python Package | |
on: | |
release: | |
types: [published] | |
env: | |
REGISTRY: ghcr.io | |
DOCKER_REGISTRY: docker.io | |
DOCKER_REGISTRY_USER: pinto0309 | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
pypi-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel pipenv | |
- name: Build | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Publish a Python distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
docker-deploy: | |
runs-on: ubuntu-latest | |
needs: pypi-deploy | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false # do not cancel even if any platform fails. | |
matrix: | |
# platform: [linux/amd64,linux/arm64] | |
platform: [linux/amd64] | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v3 | |
- name: Enable buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Repository to lowercase | |
id: lower-repo-1 | |
run: | | |
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT | |
# For Github Container Registory | |
- name: Log in to GCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for GCR | |
id: meta_gh | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ steps.lower-repo-1.outputs.repository }} | |
- name: Build and push by digest to GCR | |
id: build_gh | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: true | |
labels: ${{ steps.meta_gh.outputs.labels }} | |
outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo-1.outputs.repository }},push-by-digest=true,name-canonical=true,push=true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# For Docker Hub | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ env.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DH_ACCESS_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker Hub | |
id: meta_dh | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_REGISTRY }}/${{ steps.lower-repo-1.outputs.repository }} | |
- name: Build and push by digest to Docker Hub | |
id: build_dh | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: true | |
labels: ${{ steps.meta_gh.outputs.labels }} | |
outputs: type=image,name=${{ env.DOCKER_REGISTRY }}/${{ steps.lower-repo-1.outputs.repository }},push-by-digest=true,name-canonical=true,push=true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests/gh | |
digest="${{ steps.build_gh.outputs.digest }}" | |
touch "/tmp/digests/gh/${digest#sha256:}" | |
mkdir -p /tmp/digests/dh | |
digest="${{ steps.build_dh.outputs.digest }}" | |
touch "/tmp/digests/dh/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
runs-on: ubuntu-latest | |
needs: | |
- docker-deploy | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Repository to lowercase | |
id: lower-repo-2 | |
run: | | |
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT | |
# For Github Container Registory | |
- name: Log in to GCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for GCR | |
id: meta_gh | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ steps.lower-repo-2.outputs.repository }} | |
- name: Create manifest list and push to GCR | |
working-directory: /tmp/digests/gh | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY }}/${{ steps.lower-repo-2.outputs.repository }}@sha256:%s ' *) | |
- name: Inspect image on GCR | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ steps.lower-repo-2.outputs.repository }}:${{ steps.meta_gh.outputs.version }} | |
# For Docker Hub | |
- name: Log in to the Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ env.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DH_ACCESS_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker Hub | |
id: meta_dh | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_REGISTRY }}/${{ steps.lower-repo-2.outputs.repository }} | |
- name: Create manifest list and push to Docker Hub | |
working-directory: /tmp/digests/dh | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.DOCKER_REGISTRY }}/${{ steps.lower-repo-2.outputs.repository }}@sha256:%s ' *) | |
- name: Inspect image on Docker Hub | |
run: | | |
docker buildx imagetools inspect ${{ env.DOCKER_REGISTRY }}/${{ steps.lower-repo-2.outputs.repository }}:${{ steps.meta_dh.outputs.version }} |