Skip to content

Commit

Permalink
Use the PyPI trusted publishers system
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansick committed Jul 18, 2023
1 parent d062504 commit d60638d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
43 changes: 35 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Python CI

"on":
merge_group: {}
push:
branches-ignore:
# These should always correspond to pull requests, so ignore them for
Expand All @@ -11,9 +12,9 @@ name: Python CI
- "renovate/**"
- "tickets/**"
- "u/**"
tags:
- "*"
pull_request: {}
release:
types: [published]

jobs:
lint:
Expand Down Expand Up @@ -79,22 +80,48 @@ jobs:
username: ${{ secrets.LTD_USERNAME }}
password: ${{ secrets.LTD_PASSWORD }}
if: >
github.event_name != 'pull_request'
|| startsWith(github.head_ref, 'tickets/')
github.event_name != 'merge_group'
&& (github.event_name != 'pull_request'
|| startsWith(github.head_ref, 'tickets/'))
test-packaging:

name: Test packaging
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: "3.11"
upload: false

pypi:

# This job requires set up:
# 1. Set up a trusted publisher for PyPI
# 2. Set up a "pypi" environment in the repository
# See https://github.com/lsst-sqre/build-and-publish-to-pypi
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [lint, test, docs]
needs: [lint, test, docs, test-packaging]
environment:
name: pypi
url: https://pypi.org/p/kafkit
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v1
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
pypi-token: ${{ secrets.PYPI_SQRE_ADMIN }}
python-version: "3.11"
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
6 changes: 3 additions & 3 deletions .github/workflows/periodic-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ jobs:
tox-envs: "docs,docs-linkcheck"
use-cache: false

pypi:
test-packaging:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v1
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
pypi-token: ""
python-version: "3.11"
upload: false
4 changes: 4 additions & 0 deletions changelog.d/20230717_125707_jsick_DM_39646.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
- `AioKafkaProducerDependency` provides a Kafka producer based on aiokafka's `AIOKafkaProducer` (requires the `aiokafka` extra).
- `PydanticSchemaManager` provides a Pydantic-based schema manager for Avro schemas, `kafkit.schema.manager.PydanticSchemaManager`.
- `RegistryApiDependency` provides an HTTPX-based Schema Registry client, `kafkit.registry.httpx.RegistryApi`.

### Other changes

- Adopt PyPI's trusted publishers mechanism for releases.

0 comments on commit d60638d

Please sign in to comment.