Skip to content

Commit

Permalink
tools/update-oss.sh: check against GitHub instead of a local clone
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Mar 11, 2024
1 parent 058ad95 commit 1af0de8
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tools/update-oss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
# Usage: update-oss.sh <directory-path>
#
# Update the version of the tailscale.com module to be in sync with the version
# used by the repo checked out in the specified directory.
# used by the specified repository.
#
# Requires: git, go, jq
# Requires: gh, git, go, jq
#
set -euo pipefail

# The repository path to compare to.
repo="${1:?missing repository path}"
repo=tailscale/corp

# The module to update.
module=tailscale.com

cd "$(dirname ${BASH_SOURCE[0]})/.."
if ! git diff --quiet ; then
Expand All @@ -21,23 +24,17 @@ if ! git diff --quiet ; then
fi
git checkout --quiet main && git pull --rebase --quiet

# The module to update.
module=tailscale.com

# The branch name to use when making an update.
branch="$USER"/update-oss-version

have="$(go list -f '{{.Version}}' -m "$module" | cut -d- -f3)"
want="$(cd "$repo"; go list -f '{{.Version}}' -m "$module" | cut -d- -f3)"
want="$(
gh api -q '.content|@base64d' repos/"${repo}"/contents/go.mod |
grep -E "\b${module}\b" | cut -d' ' -f2 | cut -d- -f3
)"
if [[ "$have" = "$want" ]] ; then
echo "Module $module is up-to-date at commit $have" 1>&2
exit 0
fi

go get "$module"@"$want"
go mod tidy
git checkout -b "$branch"
git commit -m "go.mod: update $module to commit $want" go.mod go.sum
git push -u origin "$branch"
echo "Module $module updated to commit $want" 1>&2
echo "Branch $branch created" 1>&2
echo "(you must commit and push this change to persist it)" 1>&2

0 comments on commit 1af0de8

Please sign in to comment.