46 lines
1.0 KiB
Bash
Executable File
46 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
|
|
|
readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
readonly WORKSPACE_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
|
|
|
|
if ! command -v go >/dev/null 2>&1; then
|
|
echo "error: Go is not installed or is not available in PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd "${WORKSPACE_ROOT}"
|
|
|
|
if [[ ! -f go.work ]]; then
|
|
echo "error: go.work was not found in ${WORKSPACE_ROOT}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mapfile -t modules < <(go list -m -f '{{.Dir}}')
|
|
if (( ${#modules[@]} == 0 )); then
|
|
echo "error: no workspace modules were found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Updating dependencies for ${#modules[@]} workspace modules..."
|
|
|
|
for module_dir in "${modules[@]}"; do
|
|
module_name="$(cd -- "${module_dir}" && go list -m -f '{{.Path}}')"
|
|
echo
|
|
echo "==> ${module_name} (${module_dir})"
|
|
|
|
(
|
|
cd -- "${module_dir}"
|
|
go get -u ./...
|
|
go mod tidy
|
|
)
|
|
done
|
|
|
|
echo
|
|
echo "==> Synchronizing go.work"
|
|
go work sync
|
|
|
|
echo
|
|
echo "Dependency update completed successfully. Review and test the changes before committing."
|