From 5adb5738c8c3da5fd2c76b08137fde71bb67346f Mon Sep 17 00:00:00 2001 From: Nazim Date: Sun, 1 Feb 2026 19:58:48 +0000 Subject: [PATCH] Add GitHub Actions workflow for PyPI publishing on tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uses PyPI trusted publishing (no API tokens needed). Triggers on version tags (v*.*.*). setuptools_scm derives the version from the git tag automatically. After merging, configure trusted publishing on pypi.org: Project: cryptoadvance.spectrum → Publishing → Add a new publisher → Owner: cryptoadvance, Repo: spectrum → Workflow: pypi-publish.yml, Environment: (blank) --- .github/workflows/pypi-publish.yml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/pypi-publish.yml diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 0000000..a2c737b --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -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