Skip to content

Commit 1dea331

Browse files
author
Prabhakar Kumar
committed
Updates GitHub Actions to rely on Trusted Publisher instead of using API Tokens for PyPI
1 parent 52960cd commit 1dea331

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

.github/actions/build_and_publish_pypi/action.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
# Copyright 2020-2023 The MathWorks, Inc.
1+
# Copyright 2020-2024 The MathWorks, Inc.
22

33
# Composite Action to Build and Publish in PyPi
44
name: Build and Publish in PyPi
5-
inputs:
6-
pypi_token:
7-
description: 'PyPi API Token'
8-
required: true
95
runs:
106
using: "composite"
117
steps:
@@ -26,8 +22,3 @@ runs:
2622

2723
- name: Publish to PyPI.
2824
uses: pypa/gh-action-pypi-publish@release/v1
29-
with:
30-
user: __token__
31-
verbose: true
32-
password: ${{ inputs.pypi_token }}
33-
repository_url: https://upload.pypi.org/legacy/

.github/workflows/release-to-pypi.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 The MathWorks, Inc
1+
# Copyright 2020-2024 The MathWorks, Inc
22

33
# Workflow to test MATLAB-Proxy while releasing to PyPi
44
name: Release to PyPI
@@ -30,6 +30,12 @@ jobs:
3030
if: success()
3131
# windows container is not required here
3232
runs-on: ubuntu-latest
33+
# Specifying a GitHub environment is optional, but strongly encouraged
34+
environment: release
35+
permissions:
36+
# IMPORTANT: this permission is mandatory for trusted publishing
37+
id-token: write
38+
3339
steps:
3440
- name: Checkout
3541
uses: actions/checkout@v3
@@ -38,5 +44,3 @@ jobs:
3844

3945
- name: Build and Publish in PyPi
4046
uses: ./.github/actions/build_and_publish_pypi
41-
with:
42-
pypi_token: ${{ secrets.PYPI_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ htmlcov/
1010
*.key
1111
*.pem
1212
.python-version
13-
coverage.xml
13+
coverage.xml
14+
.ipynb_checkpoints/
15+
*.ipynb

0 commit comments

Comments
 (0)