11name : Publish
22
33on :
4- pull_request :
4+ push :
55 branches :
66 - main
7- types : [closed]
87 workflow_dispatch :
98
109jobs :
1110 build :
1211 name : Build source distribution and wheels
1312 uses : ./.github/workflows/build.yml
14- if : github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.repository == 'darvid/python-hyperscan' && startsWith(github.event.pull_request.head.ref, vars.RELEASE_PR_BRANCH || 'create-pull-request/patch'))
13+ if : >
14+ github.event_name == 'workflow_dispatch' ||
15+ (
16+ github.event_name == 'push' &&
17+ github.repository == 'darvid/python-hyperscan' &&
18+ startsWith(github.event.head_commit.message, 'Release ')
19+ )
1520 permissions :
1621 contents : read
1722 actions : write
3843 id : release_check
3944 env :
4045 EVENT_NAME : ${{ github.event_name }}
41- PR_MERGED : ${{ github.event.pull_request.merged }}
42- PR_HEAD_REF : ${{ github.event.pull_request.head.ref }}
43- RELEASE_PR_BRANCH : ${{ vars.RELEASE_PR_BRANCH || 'create-pull-request/patch' }}
4446 REPOSITORY : ${{ github.repository }}
4547 run : |
4648 if [[ "${REPOSITORY}" != "darvid/python-hyperscan" ]]; then
@@ -49,27 +51,17 @@ jobs:
4951 exit 0
5052 fi
5153
52- # For workflow_dispatch, skip PR checks - just verify PyPI status
53- if [[ "${EVENT_NAME}" != "workflow_dispatch" ]]; then
54- if [[ "${PR_MERGED}" != "true" ]]; then
55- echo "Pull request not merged, skipping release"
54+ if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then
55+ echo "workflow_dispatch triggered - skipping commit message check"
56+ else
57+ # For push events, the build job already gates on 'Release ' prefix,
58+ # but double-check here for safety
59+ HEAD_MSG=$(git log -1 --format=%s)
60+ if ! [[ "${HEAD_MSG}" =~ ^Release\ ]]; then
61+ echo "HEAD commit '${HEAD_MSG}' is not a release commit, skipping"
5662 echo "should_release=false" >> "$GITHUB_OUTPUT"
5763 exit 0
5864 fi
59-
60- if [[ -n "${RELEASE_PR_BRANCH}" ]]; then
61- case "${PR_HEAD_REF}" in
62- "${RELEASE_PR_BRANCH}"*)
63- ;;
64- *)
65- echo "Head ref ${PR_HEAD_REF} does not match expected release branch prefix ${RELEASE_PR_BRANCH}"
66- echo "should_release=false" >> "$GITHUB_OUTPUT"
67- exit 0
68- ;;
69- esac
70- fi
71- else
72- echo "workflow_dispatch triggered - skipping PR checks"
7365 fi
7466
7567 # Get the version we're about to release
0 commit comments