Skip to content

Commit 1367330

Browse files
committed
devops: publish only tags on their release branch
1 parent 27e324a commit 1367330

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎.github/workflows/publish.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,27 @@ jobs:
3030
fetch-depth: 0
3131
- name: Check the tag
3232
run: |
33-
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
33+
if [[ ! "$TAG" =~ ^v([0-9]+\.[0-9]+)\.[0-9]+$ ]]; then
3434
echo "Can only publish a release tag (vX.Y.Z), got: $TAG"
3535
exit 1
3636
fi
37+
MINOR="${BASH_REMATCH[1]}"
38+
BRANCH="release-$MINOR"
39+
if ! git rev-parse --verify --quiet "origin/$BRANCH" > /dev/null; then
40+
echo "Branch $BRANCH does not exist, so $TAG cannot be on it"
41+
exit 1
42+
fi
43+
if ! git merge-base --is-ancestor HEAD "origin/$BRANCH"; then
44+
echo "$TAG is not on $BRANCH"
45+
exit 1
46+
fi
47+
# Release branches are cut from main, so the head of an older release
48+
# branch can also be on $BRANCH. Check the driver version too.
49+
DRIVER="$(cat DRIVER_VERSION)"
50+
if [[ "$DRIVER" != "$MINOR."* ]]; then
51+
echo "$TAG has driver $DRIVER, expected $MINOR.x"
52+
exit 1
53+
fi
3754
- name: Set up Python
3855
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
3956
with:

0 commit comments

Comments
 (0)