99 types : [labeled]
1010
1111jobs :
12+ setup-version :
13+ name : Setup version and publication status
14+ runs-on : ubuntu-latest
15+ outputs :
16+ version : ${{ steps.get-version.outputs.version }}
17+ should_publish : ${{ steps.get-version.outputs.should_publish }}
18+ steps :
19+ - name : Check out repo
20+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+ - name : Install dependencies
22+ run : pip install requests
23+ - name : Get version
24+ id : get-version
25+ shell : bash
26+ run : |
27+ python scripts/get_version.py \
28+ --event "${{ github.event_name }}" \
29+ --ref "${{ github.ref }}" \
30+ --tag "${{ github.event.release.tag_name }}" \
31+ --package "heir_py" \
32+ --gha
33+
1234 build_sdist :
1335 name : Build source distribution
36+ needs : [setup-version]
1437 if : github.ref == 'refs/heads/main' || github.event.label.name == 'ci:wheels'
1538 runs-on : ubuntu-latest
1639 steps :
1740 - name : Check out repo
18- uses : actions/checkout@v6
41+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1942 with :
2043 fetch-depth : 0
2144 - name : Install Python 3.12
22- uses : actions/setup-python@v6
45+ uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2346 with :
2447 python-version : " 3.12"
2548 - run : python -m pip install build
2649 - name : Build sdist
27- run : python -m build --sdist
28- - uses : actions/upload-artifact@v6
50+ run : |
51+ if [[ -n "${{ needs.setup-version.outputs.version }}" ]]; then
52+ export SETUPTOOLS_SCM_PRETEND_VERSION="${{ needs.setup-version.outputs.version }}"
53+ fi
54+ python -m build --sdist
55+ - uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
2956 with :
3057 name : dist-sdist
3158 path : dist/*.tar.gz
3259
3360 build_wheels :
3461 name : Build HEIR wheels on ${{ matrix.name }}
62+ needs : [setup-version]
3563 # On PRs, only run when the ci:wheels label is added.
3664 if : github.ref == 'refs/heads/main' || github.event.label.name == 'ci:wheels'
3765 runs-on : ${{ matrix.runner }}
@@ -50,36 +78,40 @@ jobs:
5078
5179 steps :
5280 - name : Check out HEIR
53- uses : actions/checkout@v6
81+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
82+ with :
83+ fetch-depth : 0
5484
55- - uses : actions/setup-python@v6
85+ - uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
5686 name : Install Python 3.12
5787 with :
5888 python-version : " 3.12"
5989 - run : pip install --upgrade pip uv
6090
6191 - name : Build wheels on ${{ matrix.name }} using cibuildwheel
62- uses : pypa/cibuildwheel@v3.0.0
92+ uses : pypa/cibuildwheel@5f22145df44122af0f5a201f93cf0207171beca7 # v3.0.0
93+ env :
94+ SETUPTOOLS_SCM_PRETEND_VERSION : ${{ needs.setup-version.outputs.version }}
6395
6496 - name : Upload HEIR ${{ matrix.name }} wheels
6597 if : always()
66- uses : actions/upload-artifact@v6
98+ uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
6799 with :
68100 name : dist-${{ matrix.name }}
69101 path : wheelhouse/*.whl
70102
71103 pypi_upload :
72104 name : Publish heir wheels to PyPI
73- needs : [build_sdist, build_wheels]
74- # Only publish from main, not PRs
75- if : github.ref == 'refs/heads/main '
105+ needs : [setup-version, build_sdist, build_wheels]
106+ # Only publish from main or releases based on setup-version logic
107+ if : needs.setup-version.outputs.should_publish == 'true '
76108 runs-on : ubuntu-latest
77109 # Cf. trusted publishers on PyPI
78110 environment : pypi
79111 permissions :
80112 id-token : write
81113 steps :
82- - uses : actions/download-artifact@v7
114+ - uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
83115 with :
84116 path : dist
85117 pattern : dist-*
0 commit comments