Skip to content

Commit cbd7513

Browse files
authored
feat: deduplicate pypi publish workflow (#71)
* feat: deduplicate pypi publish workflow * see what is there * fix: download to path * fix: need test then prod * fix: remove testing items * style: remove extra newline * style: ensure consistent caps * prod: cancel in progress jobs for ci
1 parent 277dfc8 commit cbd7513

File tree

3 files changed

+46
-43
lines changed

3 files changed

+46
-43
lines changed

.github/workflows/build-docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
branches: [main]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
build-docs:
1014
runs-on: ubuntu-latest

.github/workflows/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
branches: [main, devel]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
get-versions:
1014
runs-on: ubuntu-latest

.github/workflows/publish-pypi.yml

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@ concurrency:
1111
cancel-in-progress: false
1212

1313
jobs:
14-
publish-pypi-test:
15-
name: Publish to TestPyPI
16-
environment:
17-
name: test
18-
url: https://test.pypi.org/project/ultraplot/
14+
build-packages:
15+
name: Build packages
1916
runs-on: ubuntu-latest
20-
permissions:
21-
id-token: write
22-
contents: read
2317
steps:
2418
- uses: actions/checkout@v4
2519
with:
@@ -38,7 +32,7 @@ jobs:
3832
python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine
3933
python -m build --sdist --wheel . --outdir dist
4034
41-
- name: CheckFiles
35+
- name: Check files
4236
run: |
4337
ls dist
4438
shell: bash
@@ -59,8 +53,37 @@ jobs:
5953
popd
6054
shell: bash
6155

56+
- name: Upload artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: dist-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }}
60+
path: dist/*
61+
if-no-files-found: error
62+
63+
publish-pypi-test:
64+
name: Publish to TestPyPI
65+
needs: build-packages
66+
if: github.event_name != 'pull_request'
67+
environment:
68+
name: test
69+
url: https://test.pypi.org/project/ultraplot/
70+
runs-on: ubuntu-latest
71+
permissions:
72+
id-token: write
73+
contents: read
74+
steps:
75+
- name: Download artifacts
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: dist-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }}
79+
path: dist
80+
81+
- name: Check files
82+
run: |
83+
ls dist
84+
shell: bash
85+
6286
- name: Publish to TestPyPI
63-
if: github.event_name != 'pull_request'
6487
uses: pypa/gh-action-pypi-publish@release/v1
6588
with:
6689
repository-url: https://test.pypi.org/legacy/
@@ -69,7 +92,7 @@ jobs:
6992
# we get a race condition if we don't skip existing
7093
skip-existing: ${{ github.event_name == 'release' && 'true' || 'false' }}
7194

72-
publish-prod:
95+
publish-pypi:
7396
name: Publish to PyPI
7497
needs: publish-pypi-test
7598
environment:
@@ -81,44 +104,16 @@ jobs:
81104
id-token: write
82105
contents: read
83106
steps:
84-
- uses: actions/checkout@v4
107+
- name: Download artifacts
108+
uses: actions/download-artifact@v4
85109
with:
86-
fetch-depth: 0
110+
name: dist-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }}
87111

88-
- name: Get tags
89-
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
90-
shell: bash
91-
92-
- uses: actions/setup-python@v5
93-
with:
94-
python-version: "3.12"
95-
96-
- name: Build package
97-
run: |
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
112+
- name: Check files
102113
run: |
103114
ls dist
104115
shell: bash
105116

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-
122117
- name: Publish to PyPI
123118
uses: pypa/gh-action-pypi-publish@release/v1
124119
with:

0 commit comments

Comments
 (0)