Skip to content

Commit a793f49

Browse files
committed
Change action to create draft release on tag push
1 parent 3b1e0d0 commit a793f49

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

.github/workflows/cibuildwheel.yml

+34-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
name: Build
22

33
on:
4-
release:
5-
types:
6-
- created
7-
4+
push:
5+
tags:
6+
- '(pre)?release-v[0-9]+.[0-9]+.[0-9]+'
87
jobs:
98
build_wheels:
109
name: Build wheels on ${{ matrix.os }}
@@ -16,7 +15,6 @@ jobs:
1615

1716
steps:
1817
- uses: actions/checkout@v4
19-
2018
- name: Build wheels
2119
uses: pypa/[email protected]
2220
env:
@@ -42,6 +40,36 @@ jobs:
4240
with:
4341
name: cibw-sdist
4442
path: dist/*.tar.gz
43+
create_release:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Get the tag name and determine if it's a prerelease
47+
id: get_tag_info
48+
run: |
49+
FULL_TAG=${GITHUB_REF#refs/tags/}
50+
if [[ $FULL_TAG == release-* ]]; then
51+
TAG_NAME=${FULL_TAG#release-}
52+
IS_PRERELEASE=false
53+
elif [[ $FULL_TAG == prerelease-* ]]; then
54+
TAG_NAME=${FULL_TAG#prerelease-}
55+
IS_PRERELEASE=true
56+
else
57+
echo "Tag does not match expected patterns" >&2
58+
exit 1
59+
fi
60+
echo "FULL_TAG=$TAG_NAME" >> $GITHUB_ENV
61+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
62+
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV
63+
- name: Create Draft Release
64+
id: create_release
65+
uses: actions/create-release@v1
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
with:
69+
tag_name: ${{ env.FULL_TAG }}
70+
release_name: ${{ env.TAG_NAME }}
71+
draft: true
72+
prerelease: ${{ env.IS_PRERELEASE }}
4573
# After the build has finished, download the artifacts from the action
4674
# and upload them to the release. When we publish the release, the
4775
# assets will be downloaded from it and uploaded to PyPi.
@@ -65,6 +93,7 @@ jobs:
6593
path: dist
6694
merge-multiple: true
6795
- uses: alexellis/[email protected]
96+
# The action fetches the release from the tag ref
6897
env:
6998
GITHUB_TOKEN: ${{ github.token }}
7099
with:

0 commit comments

Comments
 (0)