Skip to content

Commit ac6d6de

Browse files
authored
BLD: check that we're building a tag before PyPI upload (#3)
1 parent 51cd16e commit ac6d6de

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

.github/workflows/wheels.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,40 @@ jobs:
239239
print-hash: true
240240
attestations: true
241241

242+
check_version:
243+
name: Ensure commit is tag before upload to PyPi
244+
245+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi'
246+
needs: [build_wheels, build_sdist]
247+
runs-on: ubuntu-latest
248+
steps:
249+
- name: Checkout numpy
250+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
251+
with:
252+
repository: numpy/numpy
253+
ref: ${{ env.SOURCE_REF_TO_BUILD }}
254+
path: numpy-src
255+
fetch-depth: 0
256+
fetch-tags: true
257+
submodules: false
258+
persist-credentials: false
259+
260+
- name: Examine git commit
261+
run: |
262+
cd numpy-src
263+
hash=$(git describe HEAD)
264+
echo $hash
265+
if [[ $hash == *"-"*"-"* ]]; then
266+
echo "SOURCE_REF_TO_BUILD is not a tag"
267+
exit 1
268+
else
269+
echo "SOURCE_REF_TO_BUILD is a tag"
270+
fi;
271+
242272
pypi-publish:
243273
name: Publish release to PyPI
244274
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi'
245-
needs: [build_wheels, build_sdist]
275+
needs: [check_version]
246276
runs-on: ubuntu-latest
247277
environment:
248278
name: pypi

0 commit comments

Comments
 (0)