11name : Publish to PyPI
22on :
3+ pull_request :
34 release :
45 types : [published]
56 push :
67 tags : ["v*"]
78
9+ concurrency :
10+ group : publish-pypi
11+ cancel-in-progress : false
12+
813jobs :
914 publish-pypi-test :
1015 name : Publish to TestPyPI
@@ -19,18 +24,50 @@ jobs:
1924 - uses : actions/checkout@v4
2025 with :
2126 fetch-depth : 0
27+
28+ - name : Get tags
29+ run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
30+ shell : bash
31+
2232 - uses : actions/setup-python@v5
2333 with :
24- python-version : " 3.x"
34+ python-version : " 3.12"
35+
2536 - name : Build package
2637 run : |
27- python -m pip install build
28- python -m build
38+ python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine
39+ python -m build --sdist --wheel . --outdir dist
40+
41+ - name : CheckFiles
42+ run : |
43+ ls dist
44+ shell : bash
45+
46+ - name : Test wheels
47+ run : |
48+ pushd dist
49+ python -m pip install ultraplot*.whl
50+
51+ version=$(python -c "import ultraplot; print(ultraplot.__version__)")
52+ echo "Version: $version"
53+ if [[ "$version" == "0."* ]]; then
54+ echo "Version is not set correctly!"
55+ exit 1
56+ fi
57+
58+ python -m twine check *
59+ popd
60+ shell : bash
61+
2962 - name : Publish to TestPyPI
63+ if : github.event_name != 'pull_request'
3064 uses : pypa/gh-action-pypi-publish@release/v1
3165 with :
3266 repository-url : https://test.pypi.org/legacy/
3367 verbose : true
68+ # releases generate both release and tag events so
69+ # we get a race condition if we don't skip existing
70+ skip-existing : ${{ github.event_name == 'release' && 'true' || 'false' }}
3471
3572 publish-prod :
3673 name : Publish to PyPI
@@ -47,13 +84,41 @@ jobs:
4784 - uses : actions/checkout@v4
4885 with :
4986 fetch-depth : 0
87+
88+ - name : Get tags
89+ run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
90+ shell : bash
91+
5092 - uses : actions/setup-python@v5
5193 with :
52- python-version : " 3.x"
94+ python-version : " 3.12"
95+
5396 - name : Build package
5497 run : |
55- python -m pip install build
56- python -m build
98+ python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine
99+ python -m build --sdist --wheel . --outdir dist
100+
101+ - name : CheckFiles
102+ run : |
103+ ls dist
104+ shell : bash
105+
106+ - name : Test wheels
107+ run : |
108+ pushd dist
109+ python -m pip install ultraplot*.whl
110+
111+ version=$(python -c "import ultraplot; print(ultraplot.__version__)")
112+ echo "Version: $version"
113+ if [[ "$version" == "0."* ]]; then
114+ echo "Version is not set correctly!"
115+ exit 1
116+ fi
117+
118+ python -m twine check *
119+ popd
120+ shell : bash
121+
57122 - name : Publish to PyPI
58123 uses : pypa/gh-action-pypi-publish@release/v1
59124 with :
0 commit comments