Skip to content

Commit

Permalink
PyPI Trusted publishers
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Nov 4, 2023
1 parent 18b042f commit 4b2fef3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Build & maybe upload PyPI package

on:
push:
branches: [main]
tags: ["*"]
release:
types:
- published
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v1

# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
environment: release-test-pypi
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-package

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
environment: release-pypi
if: github.event.action == 'published'
runs-on: ubuntu-latest
needs: build-package

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
([#416](https://github.com/python-attrs/cattrs/pull/416))
- Fix handling classes inheriting from non-generic protocols.
([#374](https://github.com/python-attrs/cattrs/issues/374) [#436](https://github.com/python-attrs/cattrs/pull/436))
- _cattrs_ is now published using PyPI Trusted Publishers, and `main` branch commits are automatically deployed to Test PyPI.

## 23.1.2 (2023-06-02)

Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ bench = [
]

[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.mypy]
strict = true

[project]
name = "cattrs"
version = "23.2.0.dev0"
description = "Composable complex class support for attrs and dataclasses."
authors = [
{name = "Tin Tvrtkovic", email = "tinchester@gmail.com"},
Expand All @@ -70,6 +69,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: PyPy",
"Typing :: Typed",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://catt.rs"
Expand Down Expand Up @@ -150,3 +150,7 @@ ignore = [
"DTZ001", # datetimes in tests
"DTZ006", # datetimes in tests
]

[tool.hatch.version]
source = "vcs"
raw-options = { local_scheme = "no-local-version" }

0 comments on commit 4b2fef3

Please sign in to comment.