1111
1212 workflow_dispatch :
1313
14- permissions :
15- contents : read
16- id-token : write
17-
1814jobs :
1915 build_sdist :
2016 name : Build source distribution
@@ -38,50 +34,68 @@ jobs:
3834 upload_test_pypi :
3935 needs : [build_sdist]
4036 runs-on : ubuntu-latest
37+ environment : pypi
38+ permissions :
39+ id-token : write
4140 steps :
4241 - name : Install Python (if missing)
43- run : apt-get update && apt-get install -y python3 python3-pip
42+ run : |
43+ sudo apt-get update
44+ sudo apt-get install -y python3 python3-pip
4445
4546 - name : Update python dependencies
46- run : python3 -m pip install -U packaging --break-system-packages
47+ run : |
48+ python3 -m venv venv
49+ source venv/bin/activate
50+ pip install -U packaging
4751
4852 - uses : actions/download-artifact@v4
4953 with :
5054 name : artifact
5155 path : dist
5256
5357 - name : Publish package to TestPyPI
58+ env :
59+ PATH : ${{ github.workspace }}/venv/bin:$PATH
5460 uses : pypa/gh-action-pypi-publish@release/v1
5561 with :
5662 repository-url : https://test.pypi.org/legacy/
5763
5864 upload_pypi :
5965 needs : [build_sdist]
6066 runs-on : ubuntu-latest
67+ environment : pypi
68+ permissions :
69+ id-token : write
6170 if : startsWith(github.ref, 'refs/tags/v') && github.repository == 'linux-nvme/libnvme'
6271 steps :
6372 - name : Install Python (if missing)
64- run : apt-get update && apt-get install -y python3 python3-pip
73+ run : |
74+ sudo apt-get update
75+ sudo apt-get install -y python3 python3-pip
6576
6677 - name : Update python dependencies
67- run : python3 -m pip install -U packaging --break-system-packages
78+ run : |
79+ python3 -m venv venv
80+ source venv/bin/activate
81+ pip install -U packaging
6882
6983 - name : Check if it is a release tag
7084 id : check-tag
7185 run : |
7286 if [[ ${{ github.event.ref }} =~ ^refs/tags/v([0-9]+\.[0-9]+)(\.[0-9]+)?(-rc[0-9]+)?$ ]]; then
7387 echo ::set-output name=match::true
7488 fi
89+
7590 - name : Download artifiact
7691 uses : actions/download-artifact@v4
7792 if : steps.check-tag.outputs.match == 'true'
7893 with :
7994 name : artifact
8095 path : dist
96+
8197 - name : Publish package to PyPI
98+ env :
99+ PATH : ${{ github.workspace }}/venv/bin:$PATH
82100 uses : pypa/gh-action-pypi-publish@release/v1
83101 if : steps.check-tag.outputs.match == 'true'
84- with :
85- user : __token__
86- password : ${{ secrets.PYPI_API_TOKEN }}
87- verify-metadata : false
0 commit comments