VictoriaMetrics/vendor/github.com/aws/aws-sdk-go-v2/ci-find-smithy-go.sh

59 lines
1.5 KiB
Bash
Raw Normal View History

2023-08-11 14:16:25 +00:00
#!/bin/bash
# looks for (and modreplaces if existing) a smithy-go branch matching the
# current branch name
#
# the loop will unfurl -*s off of the branch, e.g. sdk branch
# 'feat-foo-bar-baz' will match any of the following (in order):
# - feat-foo-bar-baz
# - feat-foo-bar
# - feat-foo
if [ -z "$SMITHY_GO_REPOSITORY" ]; then
2023-09-01 09:11:22 +00:00
SMITHY_GO_REPOSITORY=aws/smithy-go
2023-08-11 14:16:25 +00:00
fi
if [ -z "$RUNNER_TMPDIR" ]; then
echo env RUNNER_TMPDIR is required
exit 1
fi
2023-10-16 21:33:12 +00:00
branch=$(git branch --show-current)
2023-08-11 14:16:25 +00:00
if [ "$branch" == main ]; then
echo aws-sdk-go-v2 is on branch main, stop
exit 0
fi
2023-09-01 09:11:22 +00:00
# For PR workflows, only the triggering ref is checked out, which in isolation
# is not recognized as a branch by git. Use the specific workflow env instead.
if [ -z "$branch" ]; then
branch=$GITHUB_HEAD_REF
fi
2023-08-11 14:16:25 +00:00
if [ -n "$GIT_PAT" ]; then
repository=https://$GIT_PAT@github.com/$SMITHY_GO_REPOSITORY
else
repository=https://github.com/$SMITHY_GO_REPOSITORY
fi
2023-09-01 09:11:22 +00:00
echo on branch \"$branch\"
2023-08-11 14:16:25 +00:00
while [ -n "$branch" ] && [[ "$branch" == *-* ]]; do
2023-10-16 21:33:12 +00:00
echo looking for "$branch"...
git ls-remote --exit-code --heads "$repository" refs/heads/"$branch"
2023-08-11 14:16:25 +00:00
if [ "$?" == 0 ]; then
2023-10-16 21:33:12 +00:00
echo found "$branch"
2023-08-11 14:16:25 +00:00
matched_branch=$branch
break
fi
branch=${branch%-*}
done
if [ -z "$matched_branch" ]; then
echo found no matching smithy-go branch, stop
exit 0
fi
2023-10-16 21:33:12 +00:00
git clone -b "$matched_branch" "$repository" "$RUNNER_TMPDIR"/smithy-go
2023-08-11 14:16:25 +00:00
SMITHY_GO_SRC=$RUNNER_TMPDIR/smithy-go make gen-mod-replace-smithy-.