Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-4817 move git tags script to pmm #2376

Merged
merged 13 commits into from
Aug 9, 2023
75 changes: 75 additions & 0 deletions build/scripts/create-tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
# Important: This script should never cause the pipeline to fail, so that the tags can be created outside of it.
# To run it locally, you need pass the version, i.e. export VERSION=2.39.x
# If run locally, it:
# - clones pmm-submodules repository and checks out the branch corresponding to the version
# - skips git ssh configuration and expects the user to set it up ahead of time
# - uses the current user's creds and email to push tags to the repos, therefore sufficient git permissions are required

set +o errexit
set +o nounset
set -o xtrace

# List of repositories whose release branches need to be tagged
declare repos=(
"sources/pmm/src/github.com/percona/pmm"
"sources/grafana/src/github.com/grafana/grafana"
"sources/grafana-dashboards"
"."
)

# These setting are only needed when running in CI (Jenkins or github actions)
if [ -n "$CI" ]; then
# Configure git settings globally
git config --global advice.detachedHead false
git config --global user.email "[email protected]"
git config --global user.name "PMM Jenkins"

# Configure git to push using ssh
export GIT_SSH_COMMAND="/usr/bin/ssh -i ${SSHKEY} -o StrictHostKeyChecking=no -o LogLevel=error -o UserKnownHostsFile=/dev/null"
fi

TAG="v${VERSION}"
echo "We will be tagging repos with a tag: $TAG"

REPO_DIR=pmm-submodules
if [ -d "$REPO_DIR" ]; then
echo "Error: the directory $REPO_DIR already exists, exiting..."
exit 0 # this is on purpose, we don't want to fail the pipeline
fi

if ! git clone --branch "pmm-${VERSION}" --single-branch https://github.com/Percona-Lab/pmm-submodules "$REPO_DIR"; then
echo "Fatal: failed to clone pmm-submodules, branch pmm-${VERSION}"
exit 0
fi

cd "$REPO_DIR" >/dev/null
git submodule update --init --recursive

for REPO in "${repos[@]}"; do
pushd "$REPO" >/dev/null
# git remote set-url origin [email protected]:${REPO}.git
echo "SHA: $(git rev-parse HEAD)"

# If the tag already exists, we want to delete it and re-tag this SHA
ademidoff marked this conversation as resolved.
Show resolved Hide resolved
if git tag -l "$TAG"; then
echo "Fatal: tag $TAG already exists in $REPO, exiting..."
break
fi

if [ -n "$CI" ]; then
# We can't sign tags in CI, so we create them without signing
git tag --message="Version $VERSION." "$TAG"
else
git tag --message="Version $VERSION." --sign "$TAG"
fi
if ! git push origin "$TAG"; then
echo "Fatal: failed to tag the repository $REPO with $TAG, exiting..."
break
fi
popd >/dev/null
done

cd -
rm -rf "$REPO_DIR"
unset repos
48 changes: 0 additions & 48 deletions build/scripts/create-tags.py

This file was deleted.

Loading