Skip to content

Commit 063fd52

Browse files
committed
Improve branch matching code (HAProxy-Dataplaneapi)
1 parent bc32257 commit 063fd52

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

update.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,26 @@ if [ -z "${HAPROXY_SHA256}" ]; then
4747
exit 1
4848
fi
4949

50-
DATAPLANE_SRC_URL="https://api.github.com/repos/haproxytech/dataplaneapi/releases/latest"
51-
DATAPLANE_MINOR=$(curl -sfSL "${DATAPLANE_SRC_URL}" | \
52-
grep '"tag_name":' | \
53-
sed -E 's/.*"v?([^"]+)".*/\1/')
50+
DATAPLANE_SRC_URL="https://api.github.com/repos/haproxytech/dataplaneapi/releases"
51+
DATAPLANE_SRC_URL_CONTENT=$(curl -sfSL "${DATAPLANE_SRC_URL}")
52+
DATAPLANE_BRANCH="${HAPROXY_BRANCH}"
53+
54+
DATAPLANE_MINOR=$(echo "${DATAPLANE_SRC_URL_CONTENT}" | \
55+
grep "\"tag_name\":.*\"v${DATAPLANE_BRANCH}\." | \
56+
sed -E 's/.*"v?([^"]+)".*/\1/' | \
57+
sort -V | \
58+
tail -1
59+
)
5460

5561
if [ -z "${DATAPLANE_MINOR}" ]; then
56-
echo "Could not identify latest HAProxy Dataplane release"
57-
exit 1
62+
DATAPLANE_SRC_URL="https://api.github.com/repos/haproxytech/dataplaneapi/releases/latest"
63+
DATAPLANE_MINOR=$(curl -sfSL "${DATAPLANE_SRC_URL}" | \
64+
grep '"tag_name":' | \
65+
sed -E 's/.*"v?([^"]+)".*/\1/')
5866
fi
5967

60-
DATAPLANE_SRC_URL="https://api.github.com/repos/haproxytech/dataplaneapi/releases"
61-
DATAPLANE_V2_MINOR=$(curl -sfSL "${DATAPLANE_SRC_URL}" | \
62-
grep '"tag_name":.*"v2' | \
68+
DATAPLANE_V2_MINOR=$(echo "${DATAPLANE_SRC_URL_CONTENT}" | \
69+
grep '"tag_name":.*"v2\.' | \
6370
sed -E 's/.*"v?([^"]+)".*/\1/' | \
6471
sort -V | \
6572
tail -1

0 commit comments

Comments
 (0)