From 4f8b2d71f220c0b155b7c17ddc2c4f5548d52088 Mon Sep 17 00:00:00 2001 From: BloggerBust Date: Thu, 4 Jun 2026 16:39:55 -0600 Subject: [PATCH] chore(cli): add Go quickstart dependency update task Add a script and Taskfile target for updating the embedded Go quickstart template dependencies. The script runs the update in a temporary project directory and copies the updated `go.mod` and `go.sum` back into the template. Run the new task once to update the Go quickstart template from v0.87.1 to v0.88.6. --- Taskfile.yaml | 4 ++ cmd/hatchet-cli/cli/templates/go/go.mod.embed | 2 +- cmd/hatchet-cli/cli/templates/go/go.sum | 4 +- hack/update-go-quickstart-deps.sh | 60 +++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100755 hack/update-go-quickstart-deps.sh diff --git a/Taskfile.yaml b/Taskfile.yaml index ae003367dc..c045beff30 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -244,6 +244,10 @@ tasks: generate-sqlc: cmds: - go run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.29.0 generate --file pkg/repository/sqlcv1/sqlc.yaml + update-go-quickstart-deps: + desc: Update Go quickstart template Hatchet SDK to latest (or VERSION=vX.Y.Z) + cmds: + - bash ./hack/update-go-quickstart-deps.sh {{.VERSION | default "latest"}} lint: cmds: - task: lint-go diff --git a/cmd/hatchet-cli/cli/templates/go/go.mod.embed b/cmd/hatchet-cli/cli/templates/go/go.mod.embed index c723398c96..54ecacf6bb 100644 --- a/cmd/hatchet-cli/cli/templates/go/go.mod.embed +++ b/cmd/hatchet-cli/cli/templates/go/go.mod.embed @@ -3,7 +3,7 @@ module github.com/hatchet-dev/hatchet-go-quickstart go 1.25.9 require ( - github.com/hatchet-dev/hatchet v0.87.1 + github.com/hatchet-dev/hatchet v0.88.6 github.com/joho/godotenv v1.5.1 ) diff --git a/cmd/hatchet-cli/cli/templates/go/go.sum b/cmd/hatchet-cli/cli/templates/go/go.sum index 0d6ea92cb7..28858da57b 100644 --- a/cmd/hatchet-cli/cli/templates/go/go.sum +++ b/cmd/hatchet-cli/cli/templates/go/go.sum @@ -78,8 +78,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= -github.com/hatchet-dev/hatchet v0.87.1 h1:3uzn6g+VZKwHqLII2mDwtCapweNfps2KdLMSCWafv0I= -github.com/hatchet-dev/hatchet v0.87.1/go.mod h1:mcOO2ia03lAbTdG/ubLXFNXQJPltXUmhzM0E9TV4jhU= +github.com/hatchet-dev/hatchet v0.88.6 h1:ws7EpdHLnotZN60tgspQct4NkmdDhQeKJQ/VwXaLVfU= +github.com/hatchet-dev/hatchet v0.88.6/go.mod h1:mcOO2ia03lAbTdG/ubLXFNXQJPltXUmhzM0E9TV4jhU= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= diff --git a/hack/update-go-quickstart-deps.sh b/hack/update-go-quickstart-deps.sh new file mode 100755 index 0000000000..c299924160 --- /dev/null +++ b/hack/update-go-quickstart-deps.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Update the Go quickstart template's Hatchet SDK dependency. +# +# The CLI stores Go template files with .embed suffixes: +# - go.mod.embed +# - *.go.embed +# +# The quickstart renderer strips that suffix when generating a user project. +# This avoids two Go toolchain issues in the Hatchet repo: +# - a real go.mod under templates/go would create a nested module boundary that +# //go:embed refuses to embed +# - real *.go files under the template directory could be treated as source +# files in the main repo +# +# Dependabot cannot update go.mod.embed because its Go module file fetcher +# discovers Go modules by looking for go.mod and go.work. +# +# This script copies the template into a temp directory, strips .embed suffixes +# to simulate the generated project, runs go get and go mod tidy there, then +# copies the updated go.mod/go.sum back into the embedded template files. +# +# Usage: +# bash hack/update-go-quickstart-deps.sh +# bash hack/update-go-quickstart-deps.sh v0.88.0 + +set -euo pipefail + +TEMPLATE_DIR="cmd/hatchet-cli/cli/templates/go" +VERSION="${1:-latest}" + +if [ ! -f "${TEMPLATE_DIR}/go.mod.embed" ]; then + echo "Error: ${TEMPLATE_DIR}/go.mod.embed not found. Run from the repo root." >&2 + exit 1 +fi + +TMPDIR="$(mktemp -d)" +trap 'rm -rf "${TMPDIR}"' EXIT + +echo "Copying template to temp directory..." +cp -a "${TEMPLATE_DIR}/." "${TMPDIR}/" + +echo "Stripping .embed suffixes..." +find "${TMPDIR}" -name '*.embed' -print0 | while IFS= read -r -d '' f; do + mv "${f}" "${f%.embed}" +done + +echo "Updating github.com/hatchet-dev/hatchet to ${VERSION}..." +( + cd "${TMPDIR}" + go get "github.com/hatchet-dev/hatchet@${VERSION}" + go mod tidy +) + +echo "Copying updated files back..." +cp "${TMPDIR}/go.mod" "${TEMPLATE_DIR}/go.mod.embed" +cp "${TMPDIR}/go.sum" "${TEMPLATE_DIR}/go.sum" + +echo "Done. Updated files:" +echo " ${TEMPLATE_DIR}/go.mod.embed" +echo " ${TEMPLATE_DIR}/go.sum"