Skip to content
Merged
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
40 changes: 40 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish to PyPI

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-*

jobs:
publish:
name: Build and publish to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write # Required for trusted publishing
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # setuptools_scm needs full history for version

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install build tools
run: pip install build

- name: Build package
run: python -m build

- name: Verify version matches tag
run: |
TAG=${GITHUB_REF#refs/tags/v}
PKG_VERSION=$(python -c "from importlib.metadata import version; print(version('cryptoadvance.spectrum'))" 2>/dev/null || \
python -c "import re; print(re.search(r'Version: (.+)', open('src/cryptoadvance_spectrum.egg-info/PKG-INFO').read()).group(1))" 2>/dev/null || \
ls dist/*.tar.gz | grep -oP '\d+\.\d+\.\d+')
echo "Tag version: $TAG"
echo "Package version: $PKG_VERSION"

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