Skip to content

Commit 8f5ec8b

Browse files
committed
ci: detect remote default branch
1 parent bf1911a commit 8f5ec8b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ jobs:
2626
fetch-depth: 0
2727
ref: ${{ env.RELEASE_REF }}
2828

29-
- name: Ensure tag is published from main
29+
- name: Ensure tag points to default branch
3030
run: |
31-
git fetch origin main
32-
if ! git merge-base --is-ancestor "$(git rev-parse HEAD)" origin/main; then
33-
echo "::error::Release tag must point to a commit reachable from main"
31+
git fetch origin
32+
TARGET_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
33+
if [ -z "$TARGET_BRANCH" ]; then
34+
TARGET_BRANCH=master
35+
fi
36+
if ! git merge-base --is-ancestor "$(git rev-parse HEAD)" "origin/${TARGET_BRANCH}"; then
37+
echo "::error::Release tag must point to a commit reachable from ${TARGET_BRANCH}"
3438
exit 1
3539
fi
3640

0 commit comments

Comments
 (0)