Skip to content

Commit 4b2fef3

Browse files
committed
PyPI Trusted publishers
1 parent 18b042f commit 4b2fef3

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

.github/workflows/pypi-package.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: Build & maybe upload PyPI package
3+
4+
on:
5+
push:
6+
branches: [main]
7+
tags: ["*"]
8+
release:
9+
types:
10+
- published
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
id-token: write
16+
17+
jobs:
18+
build-package:
19+
name: Build & verify package
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- uses: hynek/build-and-inspect-python-package@v1
28+
29+
# Upload to Test PyPI on every commit on main.
30+
release-test-pypi:
31+
name: Publish in-dev package to test.pypi.org
32+
environment: release-test-pypi
33+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
34+
runs-on: ubuntu-latest
35+
needs: build-package
36+
37+
steps:
38+
- name: Download packages built by build-and-inspect-python-package
39+
uses: actions/download-artifact@v3
40+
with:
41+
name: Packages
42+
path: dist
43+
44+
- name: Upload package to Test PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
repository-url: https://test.pypi.org/legacy/
48+
49+
# Upload to real PyPI on GitHub Releases.
50+
release-pypi:
51+
name: Publish released package to pypi.org
52+
environment: release-pypi
53+
if: github.event.action == 'published'
54+
runs-on: ubuntu-latest
55+
needs: build-package
56+
57+
steps:
58+
- name: Download packages built by build-and-inspect-python-package
59+
uses: actions/download-artifact@v3
60+
with:
61+
name: Packages
62+
path: dist
63+
64+
- name: Upload package to PyPI
65+
uses: pypa/gh-action-pypi-publish@release/v1

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
([#416](https://github.com/python-attrs/cattrs/pull/416))
5353
- Fix handling classes inheriting from non-generic protocols.
5454
([#374](https://github.com/python-attrs/cattrs/issues/374) [#436](https://github.com/python-attrs/cattrs/pull/436))
55+
- _cattrs_ is now published using PyPI Trusted Publishers, and `main` branch commits are automatically deployed to Test PyPI.
5556

5657
## 23.1.2 (2023-06-02)
5758

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ bench = [
3535
]
3636

3737
[build-system]
38-
requires = ["hatchling"]
38+
requires = ["hatchling", "hatch-vcs"]
3939
build-backend = "hatchling.build"
4040

4141
[tool.mypy]
4242
strict = true
4343

4444
[project]
4545
name = "cattrs"
46-
version = "23.2.0.dev0"
4746
description = "Composable complex class support for attrs and dataclasses."
4847
authors = [
4948
{name = "Tin Tvrtkovic", email = "[email protected]"},
@@ -70,6 +69,7 @@ classifiers = [
7069
"Programming Language :: Python :: Implementation :: PyPy",
7170
"Typing :: Typed",
7271
]
72+
dynamic = ["version"]
7373

7474
[project.urls]
7575
Homepage = "https://catt.rs"
@@ -150,3 +150,7 @@ ignore = [
150150
"DTZ001", # datetimes in tests
151151
"DTZ006", # datetimes in tests
152152
]
153+
154+
[tool.hatch.version]
155+
source = "vcs"
156+
raw-options = { local_scheme = "no-local-version" }

0 commit comments

Comments
 (0)