Skip to content

Commit 4e9cba3

Browse files
committed
one to create the PR, then manual merge, then auto-tag and trigger release
1 parent fb699ba commit 4e9cba3

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

.github/workflows/release.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ on:
2222
- pypi
2323
- testpypi
2424

25-
push:
25+
pull_request:
26+
types: [closed]
2627
branches: [main]
27-
paths: [osipy/_version.py]
2828

2929
permissions:
3030
contents: write
3131
pull-requests: write
3232
id-token: write
3333

3434
jobs:
35-
# ── Stage 1: triggered by workflow_dispatch ──
35+
# ── Stage 1: workflow_dispatch → run tests and create release PR ──
3636
tests:
3737
if: github.event_name == 'workflow_dispatch'
3838
uses: ./.github/workflows/pytest-actions.yaml
@@ -82,13 +82,16 @@ jobs:
8282
8383
gh pr create \
8484
--title "release: v${version}" \
85-
--body "Automated version bump to v${version}. Approve and merge to publish to **${{ inputs.target }}**." \
85+
--body "Automated version bump to v${version}. Publish target: **${{ inputs.target }}**." \
8686
--base main \
8787
--head "$branch"
8888
89-
# ── Stage 2: triggered by push to main (PR merge) ──
89+
# ── Stage 2: PR merged → tag, build, publish ──
9090
detect-target:
91-
if: github.event_name == 'push'
91+
if: >-
92+
github.event_name == 'pull_request'
93+
&& github.event.pull_request.merged == true
94+
&& startsWith(github.event.pull_request.head.ref, 'release/')
9295
runs-on: ubuntu-latest
9396
outputs:
9497
version: ${{ steps.version.outputs.version }}
@@ -106,14 +109,10 @@ jobs:
106109
")
107110
echo "version=${version}" >> "$GITHUB_OUTPUT"
108111
109-
- name: Detect publish target from PR
112+
- name: Detect publish target from PR body
110113
id: target
111-
env:
112-
GH_TOKEN: ${{ github.token }}
113114
run: |
114-
body=$(gh pr list --state merged --base main --limit 1 \
115-
--search "release: v${{ steps.version.outputs.version }}" \
116-
--json body -q '.[0].body // ""')
115+
body="${{ github.event.pull_request.body }}"
117116
if echo "$body" | grep -q '**pypi**'; then
118117
echo "target=pypi" >> "$GITHUB_OUTPUT"
119118
else

0 commit comments

Comments
 (0)