Skip to content

Add smoother release workflow with bumpver #70

Add smoother release workflow with bumpver

Add smoother release workflow with bumpver #70

Workflow file for this run

name: PyPI release
# Builds the package on every PR/push to main to catch breakages early, but
# only publishes when a GitHub Release is published (which is created by
# release.yml in response to a v* tag push).
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]
release:
types: [published]
permissions: {}
jobs:
build:
name: Build source distribution
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
- name: Build the sdist and the wheel
run: uv build
- name: Check the sdist installs and imports
run: |
uv venv venv-sdist
uv pip install --python venv-sdist/bin/python dist/tidydraws*.tar.gz
echo "Checking import and version number"
venv-sdist/bin/python -c "import tidydraws; print(tidydraws.__version__)"
- name: Check the bdist installs and imports
run: |
uv venv venv-bdist
uv pip install --python venv-bdist/bin/python dist/tidydraws*.whl
echo "Checking import and version number"
venv-bdist/bin/python -c "import tidydraws; print(tidydraws.__version__)"
- uses: actions/upload-artifact@v4
with:
name: artifact
path: dist/*
test-publish:
name: Upload to Test PyPI
permissions:
id-token: write
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.14.0
with:
skip_existing: true
repository_url: https://test.pypi.org/legacy/
- name: Test pip install from test.pypi
run: |
sleep 5s
python -m venv venv-test-pypi
venv-test-pypi/bin/python -m pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
tidydraws
echo "Checking import and version number"
venv-test-pypi/bin/python -c "import tidydraws; print(tidydraws.__version__)"
publish:
environment: release
permissions:
id-token: write
name: Upload release to PyPI
needs: [build, test-publish]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.14.0