Skip to content

Commit a9f1779

Browse files
authored
Refactor CI workflow for PyPI and Conda: standardize job names, utilize matrix for Python versions, and improve artifact handling (#126)
1 parent 1085a14 commit a9f1779

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

.github/workflows/cd.yml

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,66 @@ on:
1313

1414
jobs:
1515
pypi:
16-
name: build and deploy to PyPI
16+
name: Build and Deploy to PyPI
1717
runs-on: ubuntu-latest
1818
permissions:
1919
id-token: write
20+
21+
strategy:
22+
matrix:
23+
python-version: ["3.11", "3.12", "3.13"]
24+
2025
steps:
2126
- name: Checkout source
22-
uses: actions/checkout@v5.0.0
23-
- name: Set up Python 3.11
27+
uses: actions/checkout@v5
28+
29+
- name: Set up Python ${{ matrix.python-version }}
2430
uses: actions/setup-python@v6
2531
with:
26-
python-version: 3.11
32+
python-version: ${{ matrix.python-version }}
33+
2734
- name: Install build dependencies
2835
run: python -m pip install build twine
36+
2937
- name: Build distributions
30-
shell: bash -l {0}
3138
run: |
3239
git clean -xdf
33-
pyproject-build
34-
- name: Publish package to PyPI
35-
uses: pypa/gh-action-pypi-publish@release/v1
40+
python -m build --wheel --sdist
41+
42+
- name: Upload artifacts
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: dist-${{ matrix.python-version }}
46+
path: dist/
47+
48+
publish:
49+
# publish only once (not in matrix)
50+
name: Publish package to PyPI
51+
needs: pypi
52+
runs-on: ubuntu-latest
53+
permissions:
54+
id-token: write
55+
steps:
56+
- uses: actions/download-artifact@v4
57+
with:
58+
path: dist/
59+
- uses: pypa/gh-action-pypi-publish@release/v1
3660
with:
3761
skip-existing: true
3862

3963
conda:
40-
name: build and deploy to conda
41-
needs: pypi
64+
name: Build and Deploy to Conda
65+
needs: publish
4266
runs-on: ubuntu-latest
67+
68+
strategy:
69+
matrix:
70+
python-version: ["3.11", "3.12", "3.13"]
71+
4372
steps:
4473
- name: Checkout source
45-
uses: actions/checkout@v5.0.0
74+
uses: actions/checkout@v5
75+
4676
- name: Wait for PyPI propagation
4777
run: |
4878
echo "Waiting for PyPI package to be downloadable..."
@@ -74,11 +104,11 @@ jobs:
74104
uses: conda-incubator/setup-miniconda@v3
75105
with:
76106
miniconda-version: "latest"
77-
python-version: 3.11
107+
python-version: ${{ matrix.python-version }}
78108
environment-file: .conda/environment.yml
79109
auto-update-conda: false
80110
auto-activate-base: false
81-
show-channel-urls: true
111+
82112
- name: Build and upload the conda package
83113
uses: ACCESS-NRI/action-build-and-upload-conda-packages@d97711bc4445ba5c4de55f5a1bccbd4815286289
84114
with:

0 commit comments

Comments
 (0)