Test PyPI Release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test PyPI Release | |
# This workflow is for testing package releases on TestPyPI before official releases | |
# It automatically adds a unique suffix to the version to avoid conflicts | |
# since PyPI doesn't allow re-uploading the same version | |
on: | |
workflow_dispatch: | |
jobs: | |
test_release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.CICD_PAT }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
# Modify version to avoid conflicts on TestPyPI | |
# Format: {version}dev{timestamp} e.g. 0.0.3dev202311190145 | |
# This ensures each test upload has a unique version number | |
- name: Set test version | |
run: | | |
# Extract current version from pyproject.toml | |
VERSION=$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2) | |
# Add timestamp to make version unique | |
TEST_VERSION="${VERSION}dev$(date +%Y%m%d%H%M)" | |
# Update version in pyproject.toml | |
sed -i "s/version = \"${VERSION}\"/version = \"${TEST_VERSION}\"/" pyproject.toml | |
echo "Package version set to ${TEST_VERSION}" | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build wheel | |
- name: Build package | |
run: python -m build | |
- name: Publish to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true | |
skip-existing: true |