|
| 1 | +# Publish instanexus to PyPI when a GitHub release is created. |
| 2 | +# |
| 3 | +# HOW IT WORKS |
| 4 | +# 1. A maintainer creates a new GitHub Release (via the web UI or gh CLI). |
| 5 | +# 2. This workflow triggers on the "release published" event. |
| 6 | +# 3. It checks out the code, builds an sdist + wheel with `python -m build`, |
| 7 | +# and uploads both to PyPI using the PYPI_API_TOKEN secret. |
| 8 | +# |
| 9 | +# HOW TO TRIGGER |
| 10 | +# Option A — GitHub web UI: |
| 11 | +# 1. Go to https://github.com/Multiomics-Analytics-Group/InstaNexus/releases/new |
| 12 | +# 2. Create a new tag matching the version in pyproject.toml (e.g. v0.2.1) |
| 13 | +# 3. Fill in release title and notes, then click "Publish release" |
| 14 | +# 4. The workflow starts automatically. |
| 15 | +# |
| 16 | +# Option B — GitHub CLI: |
| 17 | +# gh release create v0.2.1 --title "v0.2.1" --notes "Release notes here" |
| 18 | +# |
| 19 | +# Option C — Manual dispatch (for testing): |
| 20 | +# Go to Actions → "Publish to PyPI" → "Run workflow", or: |
| 21 | +# gh workflow run python-publish.yml |
| 22 | +# |
| 23 | +# PREREQUISITES |
| 24 | +# - A PyPI API token must be stored as a repository secret named PYPI_API_TOKEN. |
| 25 | +# To create one: https://pypi.org/manage/account/token/ |
| 26 | +# Then add it at: Settings → Secrets and variables → Actions → New repository secret |
| 27 | +# |
| 28 | +# - The version in pyproject.toml must match the release tag (without the "v" prefix). |
| 29 | +# For example, tag "v0.2.1" should correspond to version = "0.2.1" in pyproject.toml. |
| 30 | +# PyPI will reject uploads if the version already exists. |
| 31 | + |
| 32 | +name: Publish to PyPI |
| 33 | + |
| 34 | +on: |
| 35 | + release: |
| 36 | + types: [published] |
| 37 | + workflow_dispatch: |
| 38 | + |
| 39 | +permissions: |
| 40 | + contents: read |
| 41 | + |
| 42 | +jobs: |
| 43 | + publish: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set up Python |
| 50 | + uses: actions/setup-python@v5 |
| 51 | + with: |
| 52 | + python-version: "3.x" |
| 53 | + cache: "pip" |
| 54 | + |
| 55 | + - name: Install build dependencies |
| 56 | + run: | |
| 57 | + python -m pip install --upgrade pip |
| 58 | + pip install build |
| 59 | +
|
| 60 | + - name: Build package |
| 61 | + run: python -m build |
| 62 | + |
| 63 | + - name: Publish to PyPI |
| 64 | + uses: pypa/gh-action-pypi-publish@v1.12.4 |
| 65 | + with: |
| 66 | + user: __token__ |
| 67 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments