Skip to content

Commit 5f57765

Browse files
Use trusted publishing for publishing whls to pypi (Update build-and-test.yml) (#193)
Signed-off-by: Andreas Fehlner <fehlner@arcor.de> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent a13401a commit 5f57765

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

.github/workflows/build-and-test.yml

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,34 @@ jobs:
7676
path: dist/*.tar.gz
7777

7878
# TODO: Discuss release workflow
79-
# upload_pypi:
80-
# name: Upload to PyPI
81-
# needs: [build_wheels, build_sdist]
82-
# runs-on: ubuntu-latest
83-
# steps:
84-
# - uses: actions/download-artifact@v4
85-
# with:
86-
# name: artifact
87-
# path: dist
88-
89-
# - name: Publish distribution 📦 to Test PyPI
90-
# uses: pypa/gh-action-pypi-publish@release/v1
91-
# with:
92-
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
93-
# repository-url: https://test.pypi.org/legacy/
94-
# skip-existing: true
95-
96-
# - name: Publish distribution 📦 to PyPI
97-
# if: startsWith(github.ref, 'refs/tags/v')
98-
# uses: pypa/gh-action-pypi-publish@release/v1
99-
# with:
100-
# password: ${{ secrets.PYPI_API_TOKEN }}
79+
release:
80+
name: Release
81+
environment:
82+
name: release
83+
url: https://pypi.org/p/onnxoptimizer
84+
runs-on: ubuntu-latest
85+
permissions:
86+
id-token: write
87+
88+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
89+
needs: [build_wheels, build_sdist]
90+
steps:
91+
- uses: actions/download-artifact@v4
92+
with:
93+
name: artifact
94+
path: dist
95+
96+
# TODO: get acccess for test.pypi
97+
# - name: Publish distribution 📦 to Test PyPI
98+
# uses: pypa/gh-action-pypi-publish@release/v1
99+
# with:
100+
# repository-url: https://test.pypi.org/legacy/
101+
# skip-existing: true
102+
# attestations: true
103+
104+
- name: Publish distribution 📦 to PyPI
105+
if: startsWith(github.ref, 'refs/tags/v')
106+
uses: pypa/gh-action-pypi-publish@release/v1
107+
with:
108+
repository-url: https://upload.pypi.org/legacy/
109+
attestations: true

0 commit comments

Comments
 (0)