Skip to content

Set setuptools_scm.version_scheme to only-version #142

Set setuptools_scm.version_scheme to only-version

Set setuptools_scm.version_scheme to only-version #142

name: Publish Python distributions to PyPI and TestPyPI
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
on: push
jobs:
build:
name: Build and publish to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-tags: true
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Get species list
run: python "download species list.py"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a source tarball and a wheel
run: >-
python -m
build
--outdir dist/
.
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pycatsearch
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Test the package name for a dev sign
id: test-package-name
run: |
echo "devs=$(find dist -iname "*.dev*" -exec echo {} +)" | tee -a "${GITHUB_OUTPUT}"
shell: bash
- name: Publish to PyPI
# don't publish if it's a dev release
if: steps.test-package-name.outputs.devs == ''
uses: pypa/gh-action-pypi-publish@release/v1
publish-to-testpypi:
name: Publish to TestPyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/pycatsearch
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
repository-url: https://test.pypi.org/legacy/