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
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish to PyPI

on:
pull_request:
paths:
- .github/workflows/publish.yml
release:
types:
- released

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true

jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Comment thread
assignUser marked this conversation as resolved.
with:
persist-credentials: false
fetch-depth: 0

- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0

- name: Build package
env:
SETUPTOOLS_SCM_OVERRIDES_FOR_DOTTXT: '{local_scheme=["fail-on-uncommitted-changes", "no-local-version"]}'
Comment thread
kpwtxt marked this conversation as resolved.
run: |
uv build

- name: Upload distributions
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-package-distributions
path: dist/
if-no-files-found: error

publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write # For trusted publishing
environment:
name: ${{ case(github.event_name == 'release', 'pypi', 'test-pypi') }}
Comment thread
aschwa marked this conversation as resolved.
url: ${{ case(github.event_name == 'release', 'https://pypi.org/p/dottxt',
'https://test.pypi.org/p/dottxt') }}
steps:
- name: Download distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-package-distributions
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
# Same version/content can't be reuploaded, so skip the files if this happens in testing
skip-existing: ${{ github.event_name != 'release' }}
attestations: true
repository-url: ${{ case(github.event_name == 'release', 'https://upload.pypi.org/legacy/',
'https://test.pypi.org/legacy/') }}
Loading