Skip to content

Commit 45a5e60

Browse files
authored
Merge pull request #113 from smkent/pypi
Configure PyPI trusted publishing
2 parents b1f4625 + 5a7067d commit 45a5e60

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tests/test_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_rendered_project(
132132
cd_data = yaml.safe_load(f.read())
133133
assert ci_data["env"]["ENABLE_COVERAGE"] == enable_coverage
134134
assert cd_data["env"]["ENABLE_PYPI_PUBLISH"] == enable_pypi_publish
135-
assert cd_data["env"]["ENABLE_TEST_PYPI_PUBLISH"] == enable_pypi_publish
135+
assert cd_data["env"]["ENABLE_TEST_PYPI_PUBLISH"] is False
136136

137137
assert not (
138138
subprocess.check_output(

{{cookiecutter.project_name}}/.github/workflows/cd.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@ name: Release
33

44
env:
55
ENABLE_PYPI_PUBLISH: {{ "true" if cookiecutter.enable_pypi_publish|lower == "yes" else "false" }}
6-
ENABLE_TEST_PYPI_PUBLISH: {{ "true" if cookiecutter.enable_pypi_publish|lower == "yes" else "false" }}
6+
ENABLE_TEST_PYPI_PUBLISH: false
77
RELEASE_PYTHON_VERSION: "3.12"
88
RELEASE_POETRY_VERSION: "2.0"
99

1010
on:
1111
push:
1212
tags:
1313
- '*'
14-
workflow_dispatch:
1514

1615
jobs:
1716
Publish:
1817
name: Publish package for ${{ "{{" }} github.ref_name }}
1918

2019
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
2120
runs-on: ubuntu-latest
21+
environment:
22+
name: pypi
23+
url: https://pypi.org/p/{{ cookiecutter.project_name }}
24+
permissions:
25+
id-token: write
2226

2327
steps:
2428
- name: 💾 Check out repository
@@ -49,15 +53,12 @@ jobs:
4953
uses: pypa/gh-action-pypi-publish@release/v1
5054
if: ${{ "{{" }} env.ENABLE_TEST_PYPI_PUBLISH == 'true' }}
5155
with:
52-
password: ${{ "{{" }} secrets.TEST_PYPI_API_TOKEN }}
5356
repository-url: https://test.pypi.org/legacy/
5457
skip-existing: true
5558

5659
- name: ☢️ Publish to PyPI
5760
if: ${{ "{{" }} env.ENABLE_PYPI_PUBLISH == 'true' }}
5861
uses: pypa/gh-action-pypi-publish@release/v1
59-
with:
60-
password: ${{ "{{" }} secrets.PYPI_API_TOKEN }}
6162

6263
concurrency:
6364
group: ${{ "{{" }} github.workflow }}-${{ "{{" }} github.ref }}

0 commit comments

Comments
 (0)