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 create-tags script to pmm #2217

Merged
merged 10 commits into from
Aug 9, 2023
60 changes: 6 additions & 54 deletions pmm/pmm2-release.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -524,61 +524,13 @@ ENDSSH
deleteDir()
withCredentials([sshUserPrivateKey(credentialsId: 'GitHub SSH Key', keyFileVariable: 'SSHKEY', passphraseVariable: '', usernameVariable: '')]) {
sh '''
# This step should never cause the pipeline failure so we can create tags outside of the pipeline
# This step must never cause the pipeline to fail, so that we can create tags outside of it
set +e
set -x

# List of repos whose release branches need to be tagged
declare -A repos=(
["percona-grafana"]="percona-platform/grafana"
["percona-dashboards"]="percona/grafana-dashboards"
["pmm"]="percona/pmm"
["pmm-submodules"]="Percona-Lab/pmm-submodules"
)

# 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 UserKnownHostsFile=/dev/null"

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

for PACKAGE in "${!repos[@]}"; do
rm -fr $PACKAGE || true
mkdir -p $PACKAGE

pushd $PACKAGE >/dev/null
REPO=${repos["$PACKAGE"]}
git clone https://github.com/$REPO ./
# The default is https, and we want to set it to ssh
git remote set-url origin [email protected]:$REPO.git

BRANCH="pmm-${VERSION}"
if ! git checkout "$BRANCH"; then
echo "Warning: failed to tag the repository $REPO with $TAG"
continue
fi
echo "SHA: $(git rev-parse HEAD)"
echo "Branch: $(git branch --show-current)"

# If the tag already exists, we want to delete it and re-tag this SHA
if [ $(git tag -l "$TAG") ]; then
git tag --delete "$TAG"
git push --delete origin "$TAG"
fi

git tag --message="Version $TAG." "$TAG"
if [ ! $(git push origin "$TAG") ]; then
echo "Warning: failed to tag the repository $REPO with $TAG"
fi
popd >/dev/null
rm -rf "$PACKAGE"
done
set +x
curl -o create-tags https://raw.githubusercontent.com/percona/pmm/pmm-${VERSION}/build/scripts/create-tags || :
if [ -f create-tags ]; then
chmod +x create-tags
bash -E "$(pwd)/create-tags"
fi
'''
}
}
Expand Down