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
104 changes: 43 additions & 61 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,54 @@
name: Create and Publish Release
name: Publish Python Package

on:
push:
tags:
- 'v*' # Trigger on version tags
branches-ignore:
- '**' # Ignore branch pushes, only trigger on tags
release:
types: [created]

jobs:
publish-pypi:
environment:
name: pypi
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
permissions:
contents: read

steps:
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install --user uv
uv venv
source .venv/bin/activate
uv pip install build
python -m build
uv pip install twine
twine upload dist/*

create-github-release:
environment:
name: pypi
needs: [publish-pypi]
jobs:
test:
runs-on: ubuntu-latest
environment: test
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
fetch-depth: 0

- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-stable-and-deploy-branch:
environment:
name: pypi
needs: [create-github-release]
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install -e '.[dev]'
- name: Run tests
run: |
python -m pytest
deploy:
runs-on: ubuntu-latest
needs: [test]
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
fetch-depth: 0
- name: Update stable branch
python-version: "3.13"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git checkout stable || git checkout -b stable
git reset --hard ${GITHUB_REF}
git push -f origin stable
git checkout deploy || git checkout -b deploy
git reset --hard ${GITHUB_REF}
git push -f origin deploy
pip install setuptools wheel build
- name: Build
run: |
python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on: [push, pull_request]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
environment: test
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install -e '.[dev]'
- name: Run tests
run: |
python -m pytest
Loading