Skip to content

Commit a3e322b

Browse files
committed
Migrate to trusted publishing
1 parent b6ab832 commit a3e322b

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ on:
1818
jobs:
1919
deploy:
2020
runs-on: ubuntu-latest
21+
environment:
22+
name: release
23+
url: https://pypi.org/p/tzdata
24+
permissions:
25+
id-token: write
2126
steps:
2227
- uses: actions/checkout@v2
2328
- name: Set up Python
@@ -30,26 +35,18 @@ jobs:
3035
pip install -U tox
3136
- name: Create tox environments
3237
run: |
33-
tox -p -e py,build,release --notest
38+
tox -p -e py,build --notest
3439
- name: Run tests
3540
run: |
3641
tox -e py
3742
- name: Build package
3843
run: |
3944
tox -e build
45+
- name: Publish package (TestPyPI)
46+
if: github.event_name == 'push'
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
with:
49+
repository-url: https://test.pypi.org/legacy/
4050
- name: Publish package
41-
env:
42-
TWINE_USERNAME: "__token__"
43-
run: |
44-
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
45-
export TWINE_REPOSITORY_URL="https://test.pypi.org/legacy/"
46-
export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}"
47-
elif [[ "$GITHUB_EVENT_NAME" == "release" ]]; then
48-
export TWINE_REPOSITORY="pypi"
49-
export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}"
50-
else
51-
echo "Unknown event name: ${GITHUB_EVENT_NAME}"
52-
exit 1
53-
fi
54-
55-
tox -e release
51+
if: github.event_name == 'release'
52+
uses: pypa/gh-action-pypi-publish@release/v1

tox.ini

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,3 @@ commands =
8080
[x.unlink(missing_ok=True) for x in Path('{toxinidir}/dist').glob('*')]"
8181
python -m build -o {toxinidir}/dist {toxinidir}
8282
twine check {toxinidir}/dist/*
83-
84-
[testenv:release]
85-
description = Make a release; must be called after "build"
86-
skip_install = True
87-
deps =
88-
twine
89-
depends =
90-
build
91-
passenv =
92-
TWINE_*
93-
commands =
94-
twine check {toxinidir}/dist/*
95-
twine upload {toxinidir}/dist/* \
96-
{posargs:-r {env:TWINE_REPOSITORY:testpypi} --non-interactive}

0 commit comments

Comments
 (0)