Skip to content
Draft
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
108 changes: 90 additions & 18 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,104 @@
name: Upload release to pypi
name: Publish release

on:
workflow_dispatch:
push:
tags: "v*"
inputs:
branch:
description: The branch to release from
type: string
required: true
version:
description: The version number to release
type: string
required: true
prev_version:
description: The previously most up-to-date version number
type: string
required: true

jobs:
pypi-publish:
name: Upload release to PyPI
check:
name: Pre-release checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.branch }}

- name: Check no 'TODO RELEASE' comments remain
run: |
if [ -z "$( grep -r --exclude-dir='.*' 'TODO RELEASE' )" ]; then
exit 0
else
exit 1
fi

- name: Check version number matches
run: |
if [ -z "$( grep 'version = \"${{ inputs.version }}\"' pyproject.toml )" ]; then
exit 1
else
exit 0
fi

build:
name: Build dist files
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.branch }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Build pyadjoint
run: |
pip install build
python -m build .

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

pypi:
name: Push dist to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyadjoint-ad
permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
python-version: "3.10"
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Install dependencies
run: python3 -m pip install build twine
github_release:
name: Create GitHub release
needs: pypi
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5

- name: Build a binary wheel and a source tarball
run: python3 -m build --sdist --wheel --outdir dist/ .
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create --title ${{ inputs.version }} --target ${{ inputs.branch }} --generate-notes ${{ inputs.version }} --notes-start-tag ${{ inputs.prev_version }} dist/*
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyadjoint-ad"
# TODO RELEASE
version = "2026.11.0.dev0"
dependencies = [
"checkpoint_schedules",
Expand Down
Loading