Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 73 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Upload Python Package

# Publishing a GitHub release uploads the package to PyPI. Running this
# workflow by hand on main uploads it to TestPyPI. Both use PyPI trusted
# publishing (OIDC), so no API token is stored in this repository; the
# publish jobs run in the "pypi" / "testpypi" environments.

on:
release:
types: [published]
Expand All @@ -8,10 +13,74 @@
permissions: {}

jobs:
deploy:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # trusted signing of build provenance attestations
# for the build provenance attestation
id-token: write
attestations: write
uses: cpp-linter/.github/.github/workflows/py-publish.yml@main
secrets: inherit
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# setuptools_scm needs the tags
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.x'
- name: Build wheel
run: pipx run build --wheel --outdir dist
- name: Check distribution
Comment thread
shenxianpeng marked this conversation as resolved.
Resolved
Comment thread
shenxianpeng marked this conversation as resolved.
Resolved
run: pipx run twine check dist/*
- name: Attest build provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: dist/*
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist

publish-testpypi:
name: Publish to TestPyPI
needs: build
if: >-
github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/main' &&
github.repository_owner == 'cpp-linter'
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/project/cpp-linter-hooks/
permissions:
id-token: write # trusted publishing
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

publish-pypi:
name: Publish to PyPI
needs: build
if: >-
github.event_name == 'release' &&
startsWith(github.ref, 'refs/tags/') &&
github.repository_owner == 'cpp-linter'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/cpp-linter-hooks/
permissions:
id-token: write # trusted publishing
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
Loading