Skip to content

Commit 121d192

Browse files
Use Trusted Publishing (#806)
1 parent d7e372a commit 121d192

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

.github/workflows/publish.yml

+40-11
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@
33

44
name: Publish Python distributions to PyPI
55

6-
on: push
6+
on:
7+
release:
8+
types: [published]
9+
push:
10+
branches: [master]
11+
pull_request:
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
719

820
jobs:
9-
build-n-publish:
21+
build:
1022
name: Build and publish Python distributions to PyPI
1123
runs-on: ubuntu-latest
1224
steps:
1325
- uses: actions/checkout@v4
14-
- name: Set up Python 3.11
26+
- name: Set up Python
1527
uses: actions/setup-python@v5
1628
with:
17-
python-version: "3.11"
29+
python-version: "3.x"
1830
- name: Install pypa/build
1931
run: >-
20-
python -m
21-
pip install
22-
build
23-
--user
32+
python -m pip install --upgrade build
2433
- name: Build a binary wheel and a source tarball
2534
run: >-
2635
python -m
@@ -29,8 +38,28 @@ jobs:
2938
--wheel
3039
--outdir dist/
3140
.
41+
- name: Store the distribution packages
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
47+
publish:
48+
name: Publish distribution to PyPI
49+
if: github.event_name == 'release'
50+
needs:
51+
- build
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: publish
55+
url: https://pypi.org/p/pyanalyze
56+
permissions:
57+
id-token: write
58+
steps:
59+
- name: Download all the dists
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: python-package-distributions
63+
path: dist/
3264
- name: Publish distribution to PyPI
33-
if: startsWith(github.ref, 'refs/tags')
3465
uses: pypa/gh-action-pypi-publish@release/v1
35-
with:
36-
password: ${{ secrets.PYPI_API_TOKEN }}

docs/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Version 0.13.1 (August 7, 2024)
4+
5+
- Use Trusted Publishing to publish releases (#806)
6+
37
## Version 0.13.0 (August 7, 2024)
48

59
- Flag use of generators that are immediately discarded (#800)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup
44

5-
version = "0.13.0"
5+
version = "0.13.1"
66
package_data = ["test.toml", "stubs/*/*.pyi"]
77

88

0 commit comments

Comments
 (0)