-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This script updates the version of tailscale.com in go.mod to match the version used in the specified repository checkout.
- Loading branch information
1 parent
37a714d
commit 0e9e23c
Showing
1 changed file
with
46 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,46 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# 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. | ||
# | ||
# Requires: git, go, jq | ||
# | ||
set -euo pipefail | ||
|
||
# The repository path to compare to. | ||
repo="${1:?missing repository path}" | ||
|
||
cd "$(dirname ${BASH_SOURCE[0]})/.." | ||
if ! git diff --quiet ; then | ||
echo ">> WARNING: The working directory is not clean." 1>&2 | ||
echo " Commit or stash your changes first." 1>&2 | ||
git diff --stat | ||
exit 1 | ||
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 | ||
|
||
digest="$( | ||
cd "$repo" | ||
go list -json "$module" | \ | ||
jq -r .Module.Version | \ | ||
cut -d- -f3 | ||
)" | ||
go get "$module"@"$digest" | ||
go mod tidy | ||
if git diff --quiet ; then | ||
echo "Module $module is up-to-date at commit $digest" 1>&2 | ||
else | ||
git checkout -b "$branch" | ||
git commit -m "go.mod: update $module to commit $digest" go.mod go.sum | ||
git push -u origin "$branch" | ||
echo "Module $module updated to commit $digest" 1>&2 | ||
echo "Branch $branch created" 1>&2 | ||
fi |