Skip to content

Commit a372814

Browse files
committed
Configure "trusted publishing" in Github workflow
The TestPyPI isn't configured because it's kind of unusable in the CI (since we can only upload package files once per version, and the "skip-existing" parameter isn't recommended).
1 parent 633016d commit a372814

3 files changed

Lines changed: 26 additions & 40 deletions

File tree

.github/workflows/packaging.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Packaging
33
on: [push, pull_request]
44

55
jobs:
6-
packaging:
6+
build:
77
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
88
runs-on: ubuntu-22.04
99
steps:
@@ -19,4 +19,26 @@ jobs:
1919
python -m pip install tox
2020
- name: Build package
2121
run: |
22-
tox -e packaging
22+
tox -e build
23+
- name: Upload package
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: python-package-distributions
27+
path: dist/
28+
publish:
29+
if: startsWith(github.ref, 'refs/tags/')
30+
runs-on: ubuntu-22.04
31+
needs: build
32+
environment:
33+
name: pypi
34+
url: https://pypi.org/project/loguru/
35+
permissions:
36+
id-token: write
37+
steps:
38+
- name: Download package
39+
uses: actions/download-artifact@v4
40+
with:
41+
name: python-package-distributions
42+
path: dist/
43+
- name: Publish package
44+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/release.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

tox.ini

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = lint, tests, docs, packaging
2+
envlist = lint, tests, docs, build
33
isolated_build = True
44

55
[testenv]
@@ -24,17 +24,8 @@ description = Build the HTML documentation.
2424
commands =
2525
sphinx-build -a -b html -W --keep-going docs/ docs/build
2626

27-
[testenv:packaging]
27+
[testenv:build]
2828
description = Build the Python package.
2929
commands =
3030
pyproject-build .
3131
twine check --strict dist/*
32-
33-
[testenv:release]
34-
description = Publish a new release on PyPI.
35-
passenv =
36-
TWINE_USERNAME
37-
TWINE_PASSWORD
38-
commands =
39-
{[testenv:packaging]commands}
40-
twine upload dist/* --disable-progress-bar --verbose

0 commit comments

Comments
 (0)