File tree Expand file tree Collapse file tree 3 files changed +66
-2
lines changed
Expand file tree Collapse file tree 3 files changed +66
-2
lines changed Original file line number Diff line number Diff line change 22setlocal
33
44set PROJECT = libtiff
5- set REPO = https://gitlab.com/libtiff/libtiff.git
6- set TAG = v4.5.0
5+ set GITLAB_REPO = libtiff/libtiff
6+
7+ :: get the latest release tag from GitLab
8+ cd %~dp0
9+ for /f " usebackq delims=" %%i in (`call %BASH% '../scripts/get-latest-gitlab-release-tag.sh %GITLAB_REPO% '`) do (
10+ set TAG = %%i
11+ )
712
813:: load environment and prepare project
914call " %~dp0 \..\scripts\common.bat" prepare_project || exit /b 1
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ exit /b %errorlevel%
1616 if not defined REPO (
1717 if defined GITHUB_REPO (
1818 set REPO = https://github.com/%GITHUB_REPO% .git
19+ ) else if defined GITLAB_REPO (
20+ set REPO = https://gitlab.com/%GITLAB_REPO% .git
1921 ) else (
2022 echo Missing REPO && exit /b 1
2123 )
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ #
3+ # Gets the latest tag of the form "vX.Y[.Z]" from a given GitLab repository.
4+ #
5+
6+ GITLAB_REPO=$1
7+ TAG_PREFIX=$2
8+
9+ if [ -z " $GITLAB_REPO " ]; then
10+ echo " Usage: $0 <GitLab namespace>/<GitLab repository>"
11+ exit 1
12+ fi
13+
14+ # use GitLab token authentication on CI to prevent rate limit errors
15+ if [ -n " $GITLAB_TOKEN " ]; then
16+ GITLAB_AUTHORIZATION_HEADER=" PRIVATE-TOKEN: $GITLAB_TOKEN "
17+ fi
18+
19+ GITLAB_API_URL=${GITLAB_API_URL:- https:// gitlab.com/ api/ v4}
20+ GITLAB_PROJECT=` printf %s " $GITLAB_REPO " | sed ' s|/|%2F|g' `
21+
22+ # try releases first (preferred), then fall back to tags
23+ # per_page=100 is required for some repositories with a lot of tags
24+
25+ gitlab_releases=` curl \
26+ --silent --show-error --fail-with-body \
27+ --header " $GITLAB_AUTHORIZATION_HEADER " \
28+ " $GITLAB_API_URL /projects/$GITLAB_PROJECT /releases?per_page=100" `
29+
30+ if [ $? -eq 0 ]; then
31+ latest_tag=` echo " $gitlab_releases " \
32+ | grep ' "tag_name":' \
33+ | sed -E ' s/.*"([^"]+)".*/\1/' \
34+ | egrep " ^${TAG_PREFIX:- [a-z_-]+} [0-9]+[\._-][0-9]+([\._-][0-9]+)?$" \
35+ | head -n 1`
36+ if [ -n " $latest_tag " ]; then
37+ echo " $latest_tag "
38+ exit 0
39+ fi
40+ else
41+ echo " $gitlab_releases " >&2
42+ fi
43+
44+ gitlab_tags=` curl \
45+ --silent --show-error --fail-with-body \
46+ --header " $GITLAB_AUTHORIZATION_HEADER " \
47+ " $GITLAB_API_URL /projects/$GITLAB_PROJECT /repository/tags?per_page=100" `
48+
49+ if [ $? -eq 0 ]; then
50+ echo " $gitlab_tags " \
51+ | grep ' "name":' \
52+ | sed -E ' s/.*"([^"]+)".*/\1/' \
53+ | egrep " ^${TAG_PREFIX:- [a-z_-]+} [0-9]+[\._-][0-9]+([\._-][0-9]+)?$" \
54+ | head -n 1
55+ else
56+ echo " $gitlab_tags " >&2
57+ fi
You can’t perform that action at this time.
0 commit comments