Skip to content

Professionalize docs/workflows: PyPI install, dev guide, branch strat… #6

Professionalize docs/workflows: PyPI install, dev guide, branch strat…

Professionalize docs/workflows: PyPI install, dev guide, branch strat… #6

Workflow file for this run

name: Publish Package

Check failure on line 1 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish.yml

Invalid workflow file

(Line: 63, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.PYPI_API_TOKEN != '', (Line: 70, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.PYPI_API_TOKEN == ''
on:
release:
types: [published]
workflow_dispatch:
inputs:
publish:
description: "Publish dist to PyPI after build (true/false)"
required: false
default: "false"
permissions:
contents: read
jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install build tooling
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build package
run: python -m build
- name: Verify package metadata
run: python -m twine check dist/*
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*
publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish == 'true')
permissions:
id-token: write
contents: read
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Publish package to PyPI (token)
if: ${{ secrets.PYPI_API_TOKEN != '' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish package to PyPI (trusted publishing)
if: ${{ secrets.PYPI_API_TOKEN == '' }}
uses: pypa/gh-action-pypi-publish@release/v1