Skip to content

Update publish.yml

Update publish.yml #2

Workflow file for this run

name: Publish to PyPI
on:
push:
tags:
- 'v*'
jobs:
wait-for-checks:
runs-on: ubuntu-latest
strategy:
matrix:
check: ['formatter', 'test']
steps:
- name: Wait for ${{ matrix.check }}
uses: lewagon/wait-on-check-action@v1.3.1
with:
ref: ${{ github.ref }}
check-name: ${{ matrix.check }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 120
build:
needs: [wait-for-checks]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
- name: Validate version
run: |
# Extract versions
PYPROJECT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])" 2>/dev/null || python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [[ "$TAG_VERSION" != "$PYPROJECT_VERSION" ]]; then
echo "ERROR: Tag version ($TAG_VERSION) != pyproject.toml version ($PYPROJECT_VERSION)"
exit 1
fi
- name: Build package
run: |
python -m pip install --upgrade pip build
python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
needs: [build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/jumper-extension
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
generate_release_notes: true