Skip to content

Update pypa/gh-action-pypi-publish action to v1.12.4 #947

Update pypa/gh-action-pypi-publish action to v1.12.4

Update pypa/gh-action-pypi-publish action to v1.12.4 #947

Workflow file for this run

name: Test and Tag
# Runs on every push to run the unit tests.
# Additionally, if on main, reads the current version from setup.py and then creates a new tag and release named
# for that version.
# If a tag already exists with that name, the Create Release step is skipped.
on:
workflow_dispatch:
push:
paths-ignore:
- "**/README.md"
jobs:
run-unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# If updating this list of python versions, you also need to update tox config in pyproject.toml
env:
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@b5f58b2abc5763ade55e4e9d0fe52cd1ff7979ca # v5
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.12 tox --with tox-uv --with tox-gh
- name: Install Python
if: matrix.env != '3.12'
run: uv python install --python-preference only-managed ${{ matrix.env }}
- name: Setup test suite
run: tox run -vv --notest --skip-missing-interpreters false
env:
TOX_GH_MAJOR_MINOR: ${{ matrix.env }}
- name: Run test suite
run: tox run --skip-pkg-install
env:
TOX_GH_MAJOR_MINOR: ${{ matrix.env }}
create-release:
runs-on: ubuntu-latest
needs: run-unit-tests
if: github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup python
id: setup_python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: '3.10'
- name: Get package version
id: package_version
run: echo "app_version="$(python setup.py --version) >> $GITHUB_OUTPUT
- name: Check if tag exists
uses: mukunku/tag-exists-action@bdad1eaa119ce71b150b952c97351c75025c06a9 # v1.6.0
id: check_tag
with:
tag: ${{ steps.package_version.outputs.app_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ncipollo/release-action@cdcc88a9acf3ca41c16c37bb7d21b9ad48560d87 # v1.15.0
name: Create Release
id: create_release
if: ${{ steps.check_tag.outputs.exists == 'false' }}
with:
commit: main
tag: ${{ steps.package_version.outputs.app_version }}
token: ${{ secrets.GITHUB_TOKEN }}
publish-release:
runs-on: ubuntu-latest
needs: create-release
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install uv
uses: astral-sh/setup-uv@b5f58b2abc5763ade55e4e9d0fe52cd1ff7979ca # v5
- name: Build for publish
id: build_dist
run: |
uv sync --python 3.10 --frozen
uv tool run --from build python -m build
echo workspace dir $GITHUB_WORKSPACE
- name: Publish to PyPI
id: publish-to-pypi
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
password: ${{ secrets.PYPI_API_TOKEN }}