Skip to content

Commit 58c0124

Browse files
Fix release
1 parent 4e5b464 commit 58c0124

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,31 @@ jobs:
7070
VERSION: ${{ steps.version.outputs.VERSION }}
7171
run: |
7272
set -euo pipefail
73+
# Tag-triggered runs check out a detached HEAD. Find the unique remote
74+
# branch that contains the tagged commit so we know where to push the
75+
# version-bump back to. If 0 or >1 branches contain it, fail loudly —
76+
# we will not guess.
77+
git fetch --no-tags --prune origin '+refs/heads/*:refs/remotes/origin/*'
78+
mapfile -t BRANCHES < <(git branch -r --contains HEAD --format='%(refname:short)' \
79+
| sed 's|^origin/||' \
80+
| grep -vx 'HEAD' \
81+
| sort -u)
82+
if [ ${#BRANCHES[@]} -eq 0 ]; then
83+
echo "No remote branch contains the tagged commit. Refusing to push." >&2
84+
exit 1
85+
fi
86+
if [ ${#BRANCHES[@]} -gt 1 ]; then
87+
echo "Tagged commit belongs to multiple branches: ${BRANCHES[*]}. Refusing to guess." >&2
88+
exit 1
89+
fi
90+
TARGET_BRANCH="${BRANCHES[0]}"
91+
echo "Pushing version bump to origin/$TARGET_BRANCH"
7392
sed -i 's|<Version>.*</Version>|<Version>'"$VERSION"'</Version>|' Directory.Build.props
7493
git config user.name "github-actions[bot]"
7594
git config user.email "github-actions[bot]@users.noreply.github.com"
7695
git add Directory.Build.props
7796
git diff --cached --quiet || git commit -m "chore: bump version to $VERSION [skip ci]"
78-
git push
97+
git push origin "HEAD:refs/heads/$TARGET_BRANCH"
7998
8099
- name: Create GitHub Release
81100
env:
@@ -94,7 +113,7 @@ jobs:
94113

95114
deploy-website:
96115
needs: [publish, deploy-lql-website]
97-
uses: ./.github/workflows/deploy-website.yml
116+
uses: ./.github/workflows/deploy-pages.yml
98117
with:
99118
version: ${{ needs.publish.outputs.version }}
100119
secrets: inherit

0 commit comments

Comments
 (0)