4.7.0 #1
Workflow file for this run
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: Publish releases | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-and-publish-pypi: | |
name: Builds and publishes releases to PyPI | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.vars.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get tag | |
id: vars | |
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
- name: Set up Python 3.10 | |
uses: actions/[email protected] | |
with: | |
python-version: "3.10" | |
- name: Install build | |
run: >- | |
pip install build tomli tomli-w | |
- name: Set Python project version from tag | |
shell: python | |
run: |- | |
import tomli | |
import tomli_w | |
with open("pyproject.toml", "rb") as f: | |
pyproject = tomli.load(f) | |
pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}" | |
with open("pyproject.toml", "wb") as f: | |
tomli_w.dump(pyproject, f) | |
- name: Build | |
run: >- | |
python3 -m build | |
- name: Publish release to PyPI | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} |