Skip to content

CD

CD #13

Workflow file for this run

name: CD
on:
workflow_run:
workflows: [ "CI" ]
types:
- completed
workflow_dispatch: {}
permissions:
contents: write
packages: write
id-token: write
actions: read
attestations: write
env:
PYTHON_VERSION: "3.12"
jobs:
download-distribution:
name: Download Package Distribution
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download build artifacts
uses: actions/download-artifact@v7
with:
name: python-package-distributions-${{ github.event.workflow_run.head_sha }}
path: dist/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify downloaded files
run: |
echo "Downloaded files:"
ls -R dist/
if [ ! -d "dist" ] || [ -z "$(ls -A dist)" ]; then
echo "Artifact 'python-package-distributions-${{ github.event.workflow_run.head_sha }}' not found or is empty."
exit 1
fi
# publish-docker:
# name: Build and publish Docker Image
# runs-on: ubuntu-latest
# needs: download-distribution
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v6
#
# - name: Normalize repository name
# id: repo
# run: |
# echo "repo=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
#
# - name: Extract version
# id: meta
# run: |
# VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
# echo "version=$VERSION" >> $GITHUB_OUTPUT
#
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Build and push
# uses: docker/build-push-action@v6
# with:
# context: .
# file: docker/Dockerfile
# platforms: |
# linux/amd64
# linux/arm64
# push: true
# tags: |
# ghcr.io/${{ steps.repo.outputs.repo }}:latest
# ghcr.io/${{ steps.repo.outputs.repo }}:${{ steps.meta.outputs.version }}
#
# publish-test-pypi:
# name: Publish to TestPyPI
# runs-on: ubuntu-latest
# needs: download-distribution
#
# environment:
# name: testpypi
# url: https://test.pypi.org/p/python_project_blueprint # Replace with your package name
#
# steps:
# - name: Download build artifacts
# uses: actions/download-artifact@v7
# with:
# name: python-package-distributions-${{ github.event.workflow_run.head_sha }}
# path: dist/
# run-id: ${{ github.event.workflow_run.id }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Publish to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# packages-dir: dist/
# skip-existing: true
# verbose: true
#
# github-release:
# name: Create GitHub Release
# runs-on: ubuntu-latest
# needs: [publish-docker, publish-test-pypi]
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v6
#
# - name: Download build artifacts
# uses: actions/download-artifact@v7
# with:
# name: python-package-distributions-${{ github.event.workflow_run.head_sha }}
# path: dist/
# run-id: ${{ github.event.workflow_run.id }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Extract version
# id: meta
# run: |
# VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
# echo "version=$VERSION" >> $GITHUB_OUTPUT
#
# - name: Create GitHub release
# uses: softprops/action-gh-release@v2
# with:
# files: dist/*
# tag_name: v${{ steps.meta.outputs.version }}
# generate_release_notes: true
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}