Skip to content

Commit 8611af2

Browse files
⬆️ CI/CD: Migrate PyPI workflows to OpenID Connect authentication
- Replace API token secrets with OIDC-based authentication - Add id-token: write permission for OIDC token generation - Configure environment-based deployment (pypi and pypi-test) - Update pypa/gh-action-pypi-publish to latest release/v1 version - Update actions/checkout and actions/setup-python to latest versions - Remove dependency on PYPI_API_TOKEN and TEST_PYPI_API_TOKEN secrets - Improve security with short-lived tokens and granular access control
1 parent 2a07073 commit 8611af2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

.github/workflows/python-publish-pypi-test.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ on:
66

77
permissions:
88
contents: write
9+
id-token: write # Necessário para OIDC
910

1011
jobs:
1112
deploy:
1213
runs-on: ubuntu-latest
14+
environment: pypi-test # Opcional, mas recomendado para segurança
1315

1416
steps:
15-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1618
with:
1719
repo-token: ${{ secrets.GITHUB_TOKEN }}
1820

1921
- name: ⚙️ Set up Python 3.11
20-
uses: actions/setup-python@v3
22+
uses: actions/setup-python@v5
2123
with:
2224
python-version: "3.11"
2325

@@ -30,7 +32,6 @@ jobs:
3032
run: python -m build
3133

3234
- name: 📦 Publish Package to Test PyPI
33-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
35+
uses: pypa/gh-action-pypi-publish@release/v1
3436
with:
35-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
36-
repository_url: https://test.pypi.org/legacy/
37+
repository-url: https://test.pypi.org/legacy/

.github/workflows/python-publish-pypi.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ on:
66

77
permissions:
88
contents: read
9+
id-token: write # Necessário para OIDC
910

1011
jobs:
1112
deploy:
1213
runs-on: ubuntu-latest
14+
environment: pypi # Opcional, mas recomendado para segurança
1315

1416
steps:
15-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1618
- name: ⚙️ Set up Python 3.10
17-
uses: actions/setup-python@v3
19+
uses: actions/setup-python@v5
1820
with:
1921
python-version: "3.10"
2022
- name: ⚙️ Install dependencies
@@ -24,7 +26,4 @@ jobs:
2426
- name: 📦 Build Package
2527
run: python -m build
2628
- name: 📦 Publish Package to PyPI
27-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
28-
with:
29-
user: __token__
30-
password: ${{ secrets.PYPI_API_TOKEN }}
29+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)