Skip to content

Commit

Permalink
Add release workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
zjowowen committed Oct 31, 2024
1 parent 1169fc5 commit 3cc02df
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish to PyPI

on:
# Trigger this workflow when a new tag is pushed
push:
tags:
- '*'

jobs:
build-and-publish:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
# Step 1: Check out the repository
- name: Check out code
uses: actions/checkout@v3

# Step 2: Set up Python environment with matrix
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# Step 3: Install build dependencies
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
# Step 4: Build the package (wheel and source distribution)
- name: Build the package
run: |
python setup.py sdist bdist_wheel
# Step 5: Publish the package to PyPI (only run once for one version)
- name: Publish to PyPI
if: matrix.python-version == '3.9' # Publish only once, on Python 3.9
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} # Use the PyPI token stored in GitHub Secrets
run: |
python -m twine upload dist/*
# Step 6: Clean up the build artifacts
- name: Remove build artifacts
if: matrix.python-version == '3.9' # Clean up once after publishing
run: rm -rf dist build *.egg-info

0 comments on commit 3cc02df

Please sign in to comment.