-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wrapper script for sidecar release
- Loading branch information
1 parent
78c0fb7
commit cbff685
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/sh -x | ||
|
||
die () { | ||
echo >&2 "\nERROR: $@\n" | ||
exit 1 | ||
} | ||
|
||
MAX_RETRY=10 | ||
|
||
# Get the options | ||
while getopts ":u:v:" option; do | ||
case $option in | ||
u) # Set username | ||
username=$OPTARG;; | ||
v) # Set version | ||
v=$OPTARG;; | ||
\?) # Invalid option | ||
echo "Error: Invalid option: $OPTARG" | ||
exit;; | ||
esac | ||
done | ||
|
||
while read repo branches; do | ||
if [ "$repo" != "#" ]; then | ||
( | ||
cd $repo || die "$repo: does not exit" | ||
git fetch origin || die "$repo: git fetch" | ||
for i in $branches; do | ||
git checkout -B module-update-$i origin/$i || die "$repo:$i checkout" | ||
rm -rf .git/MERGE* | ||
if ! git subtree pull --squash --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master; then | ||
# Sometimes "--squash" leads to merge conflicts. Because we know that "release-tools" | ||
# is an unmodified copy of csi-release-tools, we can automatically resolve that | ||
# by replacing it completely. | ||
if [ -e .git/MERGE_MSG ] && [ -e .git/FETCH_HEAD ] && grep -q "^# Conflict" .git/MERGE_MSG; then | ||
rm -rf release-tools | ||
mkdir release-tools | ||
git archive FETCH_HEAD | tar -C release-tools -xf - || die "failed to re-create release-tools from FETCH_HEAD" | ||
git add release-tools || die "add release-tools" | ||
git commit --file=.git/MERGE_MSG || die "commit squashed release-tools" | ||
else | ||
die "git subtree pull --squash failed, cannot reover." | ||
fi | ||
fi | ||
RETRY=0 | ||
while ! ./release-tools/go-get-kubernetes.sh -p $v && RETRY < MAX_RETRY | ||
do | ||
RETRY=RETRY+1 | ||
go mod tidy && go mod vendor && go mod tidy | ||
done | ||
go mod tidy && go mod vendor && go mod tidy || die "last go mod vendor && go mod tidy failed" | ||
git add --all || die "git add -all failed" | ||
git commit -m "Update dependency go modules for k8s v$v" || die "commit update modules" | ||
git remote set-url origin https://github.com/$username/$repo.git || die "git remote set-url failed" | ||
make test || die "$repo:$i make test" | ||
git push origin module-update-$i --force || die "origin:module-update-$i push failed - probably there is already an unmerged branch and pending PR" | ||
gh auth login || die "gh auth login failed" | ||
gh pr create --title="Update dependency go modules for k8s v$v" --body "Ran kubernetes-csi/csi-release-tools go-get-kubernetes.sh -p $v" --head "$username:module-update-master" --base "master" --repo="kubernetes-csi/$repo" | ||
done | ||
) || die "failed" | ||
fi | ||
done <<EOF | ||
csi-driver-host-path master | ||
csi-driver-iscsi master | ||
csi-driver-nfs master | ||
csi-lib-utils master | ||
csi-proxy master | ||
csi-test master | ||
external-attacher master | ||
external-health-monitor master | ||
external-provisioner master | ||
external-resizer master | ||
external-snapshotter master | ||
livenessprobe master | ||
node-driver-registrar master | ||
EOF |