3535 # - main
3636
3737jobs :
38- publish-pypi :
39- name : Publish to PyPI
38+ build :
39+ name : Build distribution 📦
4040 runs-on : ubuntu-latest
41- permissions :
42- # This permission is mandatory for OIDC publishing
43- id-token : write
44- if : github.repository == 'GenericMappingTools/pygmt'
4541
4642 steps :
4743 - name : Checkout
48444945 with :
5046 # fetch all history so that setuptools-scm works
5147 fetch-depth : 0
48+ persist-credentials : false
5249
5350 - name : Set up Python
5451@@ -74,11 +71,54 @@ jobs:
7471 echo "Generated files:"
7572 ls -lh dist/
7673
77- - name : Publish to Test PyPI
74+ - name : Store the distribution packages
75+ 76+ with :
77+ name : python-package-distributions
78+ path : dist/
79+
80+ publish-to-testpypi :
81+ name : Publish Python 🐍 distribution 📦 to TestPyPI
82+ if : github.repository == 'GenericMappingTools/pygmt'
83+ needs :
84+ - build
85+ runs-on : ubuntu-latest
86+ environment :
87+ name : testpypi
88+ url : https://test.pypi.org/project/pygmt
89+ permissions :
90+ id-token : write # IMPORTANT: mandatory for trusted OIDC publishing
91+
92+ steps :
93+ - name : Download all the dists
94+ 95+ with :
96+ name : python-package-distributions
97+ path : dist/
98+
99+ - name : Publish distribution 📦 to TestPyPI
7810079101 with :
80102 repository-url : https://test.pypi.org/legacy/
81103
82- - name : Publish to PyPI
83- if : startsWith(github.ref, 'refs/tags')
104+ publish-pypi :
105+ name : Publish Python 🐍 distribution 📦 to PyPI
106+ if : github.repository == 'GenericMappingTools/pygmt' && startsWith(github.ref, 'refs/tags/')
107+ needs :
108+ - build
109+ runs-on : ubuntu-latest
110+ environment :
111+ name : pypi
112+ url : https://pypi.org/project/pygmt/
113+ permissions :
114+ id-token : write # IMPORTANT: mandatory for trusted OIDC publishing
115+
116+ steps :
117+ - name : Download all the dists
118+ 119+ with :
120+ name : python-package-distributions
121+ path : dist/
122+
123+ - name : Publish distribution 📦 to PyPI
84124
0 commit comments