Skip to content

Commit

Permalink
support mod updates in script
Browse files Browse the repository at this point in the history
  • Loading branch information
gjswalling committed Jan 30, 2025
1 parent 5918f96 commit 95abadb
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PKG_VERSION=""
SRC_TARBALL=""
VENDOR_VERSION="1"
OUT_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
UPDATE_MODS=""

# parameters:
#
Expand All @@ -18,6 +19,7 @@ OUT_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# --outFolder : folder where to copy the new tarball(s)
# --pkgVersion : package version
# --vendorVersion : vendor version
# --updateMods : go modules to update, comma separated list
#
PARAMS=""
while (( "$#" )); do
Expand Down Expand Up @@ -58,6 +60,15 @@ while (( "$#" )); do
exit 1
fi
;;
--updateMods)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
UPDATE_MODS=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
Expand All @@ -73,6 +84,7 @@ echo "--srcTarball -> $SRC_TARBALL"
echo "--outFolder -> $OUT_FOLDER"
echo "--pkgVersion -> $PKG_VERSION"
echo "--vendorVersion -> $VENDOR_VERSION"
echo "--updateMods -> $UPDATE_MODS"

if [ -z "$PKG_VERSION" ]; then
echo "--pkgVersion parameter cannot be empty"
Expand Down Expand Up @@ -104,6 +116,16 @@ cd "$NAME_VER"
echo "Get vendored modules"
go mod vendor

if [ -n "$UPDATE_MODS" ]; then
echo "Update vendored modules"
IFS=',' read -r -a MODS <<< "$UPDATE_MODS"
for MODULE in "${MODS[@]}"
do
go get -u $MODULE
done
go mod vendor
fi

echo "Tar vendored modules"
tar --sort=name \
--mtime="2021-04-26 00:00Z" \
Expand Down

0 comments on commit 95abadb

Please sign in to comment.