Skip to content
Open
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
4 changes: 4 additions & 0 deletions .github/RELEASE-TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Announcements
* First announcement

# Changes
43 changes: 43 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PyPI Publish

on:
release:
types:
- published

env:
PYTHON_VERSION: "3.12"
UV_SYSTEM_PYTHON: 1

jobs:
publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi-release
url: https://pypi.org/p/django-tos
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Add version to environment vars
run: |
PROJECT_VERSION=$(python3 -c 'import importlib.metadata; print(importlib.metadata.version("django-tos"))')
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Restore distribution files cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
dist/django_tos-${{ env.PROJECT_VERSION }}-py3-none-any.whl
dist/django_tos-${{ env.PROJECT_VERSION }}.tar.gz
key: build-distributions-${{ env.PROJECT_VERSION }}
- name: List distribution files
run: |
ls -l dist/*.whl dist/*.tar.gz
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
verbose: true
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Create release

on:
push:
tags:
- "v*"

env:
PYTHON_VERSION: "3.13"

jobs:
release:
name: Create release
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Add version to environment vars
run: |
PROJECT_VERSION=$(python3 -c 'import importlib.metadata; print(importlib.metadata.version("django-tos"))')
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Check if tag version matches project version
run: |
TAG=$(git describe HEAD --tags --abbrev=0)
echo "TAG: $TAG"
echo "PROJECT_VERSION: $PROJECT_VERSION"
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi
- name: Install packages
run: |
python3 -m pip install --root-user-action=ignore build 'validate-pyproject[all]'
- name: Check pyproject.toml validity
# https://github.com/astral-sh/uv/issues/9653#issuecomment-3591888192
run: validate-pyproject ./pyproject.toml
- name: Build
run: |
python3 -m build
echo "PROJECT_VERSION: $PROJECT_VERSION"
- name: Release Notes
run: |
if (git describe HEAD~ --tags --abbrev=0); then
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s (@%an)' --no-merges >> ".github/RELEASE-TEMPLATE.md"
else
touch .github/RELEASE-TEMPLATE.md
fi
- name: Create Release Draft
uses: softprops/action-gh-release@v1
with:
body_path: ".github/RELEASE-TEMPLATE.md"
draft: true
fail_on_unmatched_files: true
files: |
dist/django_tos-${{ env.PROJECT_VERSION }}-py3-none-any.whl
dist/django_tos-${{ env.PROJECT_VERSION }}.tar.gz
# Save build artifacts so the publish workflow doesn't need to rebuild them
- name: Save distribution files
uses: actions/cache/save@v4
with:
path: |
dist/django_tos-${{ env.PROJECT_VERSION }}-py3-none-any.whl
dist/django_tos-${{ env.PROJECT_VERSION }}.tar.gz
key: build-distributions-${{ env.PROJECT_VERSION }}