Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 100 additions & 100 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,103 +44,103 @@ jobs:
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 }}
# 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 }}
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[project]
name = "python-project-blueprint"
version = "0.0.2"
description = "Production-ready Python project template with modern tooling, CI/CD, security, and configuration built in."
name = "DISTRIBUTION-NAME"
version = "0.1.0"
description = "[[DESCRIPTION]]"
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.12"
license = {"file" = "LICENSE.md"}
authors = [
{ name = "Pymetheus", email = "github.senate902@passfwd.com" }
{ name = "[[USERNAME]]", email = "AUTHOR@EXAMPLE.COM" }
]

classifiers = [
Expand All @@ -28,10 +28,10 @@ dev = [
]

[project.urls]
Homepage = "https://github.com/Pymetheus/python-project-blueprint"
Repository = "https://github.com/Pymetheus/python-project-blueprint"
Documentation = "https://github.com/Pymetheus/python-project-blueprint/blob/main/docs/INSTRUCTIONS.md"
Issues = "https://github.com/Pymetheus/python-project-blueprint/issues"
Homepage = "https://github.com/[[USERNAME]]/[[REPO_NAME]]"
Repository = "https://github.com/[[USERNAME]]/[[REPO_NAME]]"
Documentation = "https://github.com/[[USERNAME]]/[[REPO_NAME]]/blob/main/docs/DOCUMENTATION.md"
Issues = "https://github.com/[[USERNAME]]/[[REPO_NAME]]/issues"

[project.scripts]
DISTRIBUTION-NAME = "package_name.main:main"
Expand Down