Skip to content

docs: update README and pyproject.toml for package dependencies and p… #1

docs: update README and pyproject.toml for package dependencies and p…

docs: update README and pyproject.toml for package dependencies and p… #1

Workflow file for this run

# This workflow publishes the package to TestPyPI when a version tag is pushed.
# Tag format must be: version-X.Y.Z
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Publish Python package (TestPyPI)
on:
push:
tags:
- 'version-*'
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Validate tag matches project version
run: |
tag="${GITHUB_REF_NAME}"
if [[ ! "$tag" =~ ^version-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Tag '$tag' does not match required pattern version-X.Y.Z"
exit 1
fi
project_version=$(python - <<'PY'
import pathlib, re
content = pathlib.Path('pyproject.toml').read_text(encoding='utf-8')
m = re.search(r'^version\s*=\s*"([^"]+)"', content, flags=re.MULTILINE)
if not m:
raise SystemExit('Could not find project.version in pyproject.toml')
print(m.group(1))
PY
)
tag_version="${tag#version-}"
if [[ "$tag_version" != "$project_version" ]]; then
echo "Tag version '$tag_version' does not match pyproject version '$project_version'"
exit 1
fi
echo "Tag and project version are consistent: $project_version"
- name: Build release distributions
run: |
# NOTE: put your own distribution build steps here.
python -m pip install build
python -m build
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
testpypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# Dedicated environments with protections for publishing are strongly recommended.
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
environment:
name: testpypi
url: https://test.pypi.org/project/fastmolwidget/
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish release distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
repository-url: https://test.pypi.org/legacy/