1
1
#! /bin/bash
2
2
# Important: This script should never cause the pipeline to fail, so that the tags can be created outside of it.
3
+ # To run it locally, you need pass the version, i.e. export VERSION=2.39.x
3
4
# If run locally, it:
4
- # - does not need to run inside pmm-submodules as it clones all the necessary repos
5
+ # - it clones the pmm-submodules repo and checks out the branch corresponding to the version
5
6
# - does not need to configure git to push using ssh, this user should set it all up ahead of time
6
7
# - will use the user's creds and email to tag the repos, therefore sufficient permissions are required
7
8
@@ -11,10 +12,10 @@ set -o xtrace
11
12
12
13
# List of repositories whose release branches need to be tagged
13
14
declare repos=(
14
- " percona-platform/grafana "
15
- " percona /grafana-dashboards "
16
- " percona/pmm "
17
- " Percona-Lab/pmm-submodules "
15
+ " sources/pmm/src/github.com/ percona/pmm "
16
+ " sources /grafana/src/github.com/grafana/grafana "
17
+ " sources/grafana-dashboards "
18
+ " . "
18
19
)
19
20
20
21
# These setting are only needed when running in CI (Jenkins or github actions)
31
32
TAG=" v${VERSION} "
32
33
echo " We will be tagging repos with a tag: $TAG "
33
34
34
- for REPO in " ${repos[@]} " ; do
35
- DIR_NAME=${REPO##*/ } # grab the repo name from <company>/<repo>
36
- rm -fr " $DIR_NAME " || true
37
- mkdir -p " $DIR_NAME "
35
+ REPO_DIR=pmm-submodules
36
+ if [ -d " $REPO_DIR " ]; then
37
+ rm -rf " $REPO_DIR "
38
+ fi
39
+ git clone https://github.com/Percona-Lab/pmm-submodules " $REPO_DIR "
40
+
41
+ cd " $REPO_DIR " > /dev/null
42
+ if ! git checkout " pmm-${VERSION} " ; then
43
+ echo " Fatal: failed to check out to pmm-${VERSION} branch"
44
+ cd -
45
+ rm -rf " $REPO_DIR "
46
+ exit 0 # this is on purpose, we don't want to fail the pipeline
47
+ fi
48
+ git submodule update --init --recursive
38
49
39
- pushd " $DIR_NAME " > /dev/null
40
- git clone https://github.com/${REPO} ./
41
- # The default is https, and we want to set it to ssh
42
- git remote set-url origin
[email protected] :
${REPO} .git
50
+ for REPO in " ${repos[@]} " ; do
43
51
44
- BRANCH=" pmm-${VERSION} "
45
- if ! git checkout " $BRANCH " ; then
46
- echo " Warning: failed to checkout the repository $REPO to $BRANCH "
47
- popd > /dev/null
48
- rm -rf " $DIR_NAME "
49
- continue
50
- fi
52
+ pushd " $REPO " > /dev/null
53
+ # git remote set-url origin [email protected] :${REPO}.git
51
54
echo " SHA: $( git rev-parse HEAD) "
52
55
53
56
# If the tag already exists, we want to delete it and re-tag this SHA
54
57
if git tag -l " $TAG " ; then
55
- git tag --delete " $TAG "
56
- git push --delete origin " $TAG "
58
+ echo " Fatal: tag $TAG already exists in $REPO , we won't continue... "
59
+ break
57
60
fi
58
61
59
- git tag --message=" Version $TAG ." " $TAG "
62
+ git tag --message=" Version $VERSION ." " $TAG "
60
63
if ! git push origin " $TAG " ; then
61
- echo " Warning: failed to tag the repository $REPO with $TAG "
64
+ echo " Fatal: failed to tag the repository $REPO with $TAG "
65
+ break
62
66
fi
63
67
popd > /dev/null
64
- rm -rf " $DIR_NAME "
65
68
done
66
69
70
+ cd -
71
+ rm -rf " $REPO_DIR "
67
72
unset repos
0 commit comments