Skip to content

Commit bb3883c

Browse files
authored
Merge pull request #28 from github/pypi-release-config
Setup pypi, testpypi and github releases
2 parents 18e976c + de58016 commit bb3883c

File tree

6 files changed

+126
-94
lines changed

6 files changed

+126
-94
lines changed

.github/workflows/build-and-upload.yaml

-40
This file was deleted.

.github/workflows/package-quality-control.yaml

-39
This file was deleted.
+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2+
3+
on: push
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
build:
10+
name: Build distribution 📦
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
- name: Install hatch
20+
run: >-
21+
python3 -m
22+
pip install
23+
hatch
24+
--user
25+
- name: Build a binary wheel and a source tarball
26+
run: python3 -m hatch build
27+
- name: Store the distribution packages
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: python-package-distributions
31+
path: dist/
32+
33+
publish-to-pypi:
34+
name: >-
35+
Publish Python 🐍 distribution 📦 to PyPI
36+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
37+
needs:
38+
- build
39+
runs-on: ubuntu-latest
40+
environment:
41+
name: pypi
42+
url: https://pypi.org/p/annotated-logger
43+
permissions:
44+
id-token: write # IMPORTANT: mandatory for trusted publishing
45+
46+
steps:
47+
- name: Download all the dists
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: python-package-distributions
51+
path: dist/
52+
- name: Publish distribution 📦 to PyPI
53+
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
54+
55+
github-release:
56+
name: >-
57+
Sign the Python 🐍 distribution 📦 with Sigstore
58+
and upload them to GitHub Release
59+
needs:
60+
- publish-to-pypi
61+
runs-on: ubuntu-latest
62+
63+
permissions:
64+
contents: write # IMPORTANT: mandatory for making GitHub Releases
65+
id-token: write # IMPORTANT: mandatory for sigstore
66+
67+
steps:
68+
- name: Download all the dists
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: python-package-distributions
72+
path: dist/
73+
- name: Sign the dists with Sigstore
74+
uses: sigstore/gh-action-sigstore-python@f514d46b907ebcd5bedc05145c03b69c1edd8b46 #v3.0.0
75+
with:
76+
inputs: >-
77+
./dist/*.tar.gz
78+
./dist/*.whl
79+
- name: Create GitHub Release
80+
env:
81+
GITHUB_TOKEN: ${{ github.token }}
82+
run: >-
83+
gh release create
84+
'${{ github.ref_name }}'
85+
--repo '${{ github.repository }}'
86+
--notes ""
87+
- name: Upload artifact signatures to GitHub Release
88+
env:
89+
GITHUB_TOKEN: ${{ github.token }}
90+
# Upload to GitHub Release using the `gh` CLI.
91+
# `dist/` contains the built packages, and the
92+
# sigstore-produced signatures and certificates.
93+
run: >-
94+
gh release upload
95+
'${{ github.ref_name }}' dist/**
96+
--repo '${{ github.repository }}'
97+
98+
publish-to-testpypi:
99+
name: Publish Python 🐍 distribution 📦 to TestPyPI
100+
needs:
101+
- build
102+
runs-on: ubuntu-latest
103+
104+
environment:
105+
name: testpypi
106+
url: https://test.pypi.org/p/annotated-logger
107+
108+
permissions:
109+
id-token: write # IMPORTANT: mandatory for trusted publishing
110+
111+
steps:
112+
- name: Download all the dists
113+
uses: actions/download-artifact@v4
114+
with:
115+
name: python-package-distributions
116+
path: dist/
117+
- name: Publish distribution 📦 to TestPyPI
118+
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
119+
with:
120+
repository-url: https://test.pypi.org/legacy/

action.yaml

-6
This file was deleted.

annotated_logger/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
if TYPE_CHECKING: # pragma: no cover
3030
from collections.abc import MutableMapping
3131

32-
VERSION = "1.2.0" # pragma: no mutate
32+
# Use 0.0.0.dev1 and so on when working in a PR
33+
# Each push attempts to upload to testpypi, but it only works with a unique version
34+
# https://test.pypi.org/project/annotated-logger/
35+
# The dev versions in testpypi can then be pulled in to whatever project needed
36+
# the new feature.
37+
VERSION = "1.2.1" # pragma: no mutate
3338

3439
T = TypeVar("T")
3540
P = ParamSpec("P")

script/build_package

-8
This file was deleted.

0 commit comments

Comments
 (0)