Skip to content

Commit f90e02f

Browse files
author
Alex Tymchuk
committed
PMM-4817 use pmm-submodules vs distinct repos
1 parent 3ce6898 commit f90e02f

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

build/scripts/create-tags

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22
# 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
34
# 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
56
# - does not need to configure git to push using ssh, this user should set it all up ahead of time
67
# - will use the user's creds and email to tag the repos, therefore sufficient permissions are required
78

@@ -11,10 +12,10 @@ set -o xtrace
1112

1213
# List of repositories whose release branches need to be tagged
1314
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+
"."
1819
)
1920

2021
# These setting are only needed when running in CI (Jenkins or github actions)
@@ -31,37 +32,41 @@ fi
3132
TAG="v${VERSION}"
3233
echo "We will be tagging repos with a tag: $TAG"
3334

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
3849

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
4351

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
5154
echo "SHA: $(git rev-parse HEAD)"
5255

5356
# If the tag already exists, we want to delete it and re-tag this SHA
5457
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
5760
fi
5861

59-
git tag --message="Version $TAG." "$TAG"
62+
git tag --message="Version $VERSION." "$TAG"
6063
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
6266
fi
6367
popd >/dev/null
64-
rm -rf "$DIR_NAME"
6568
done
6669

70+
cd -
71+
rm -rf "$REPO_DIR"
6772
unset repos

0 commit comments

Comments
 (0)