From c275c8077748661e3f78cb3bfdb0cb0dc4cfd59d Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Mon, 30 Mar 2026 17:21:59 -0400 Subject: [PATCH 1/3] Ensure `script/release.sh` is idempotent --- script/release.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/script/release.sh b/script/release.sh index a8cf4ca5..62a4aa15 100755 --- a/script/release.sh +++ b/script/release.sh @@ -2,6 +2,7 @@ set -eu +DRY_RUN="${DRY_RUN:-false}" WORKDIR=$(pwd) if [ -z "${GORELEASER_CURRENT_TAG:-}" ]; then @@ -10,6 +11,73 @@ if [ -z "${GORELEASER_CURRENT_TAG:-}" ]; then fi export GORELEASER_CURRENT_TAG +VERSION="${GORELEASER_CURRENT_TAG#v}" + +all_targets=(publish docker homebrew scoop aur) +skip=() + +asset_count=$(gh release view "$GORELEASER_CURRENT_TAG" --json assets --jq '.assets | length' 2>/dev/null || echo "0") +if [ "$asset_count" -gt 0 ]; then + echo "==> GitHub Release assets already exist, skipping publish" + skip+=(publish) +fi + +if docker manifest inspect "planetscale/pscale:${GORELEASER_CURRENT_TAG}" >/dev/null 2>&1; then + echo "==> Docker image already exists, skipping docker" + skip+=(docker) +fi + +if gh api "repos/planetscale/homebrew-tap/contents/Formula/pscale.rb" --jq '.content' 2>/dev/null \ + | base64 --decode 2>/dev/null | grep -q "version \"${VERSION}\""; then + echo "==> Homebrew formula already up to date, skipping homebrew" + skip+=(homebrew) +fi + +if gh api "repos/planetscale/scoop-bucket/contents/pscale.json" --jq '.content' 2>/dev/null \ + | base64 --decode 2>/dev/null | grep -q "\"version\": \"${VERSION}\""; then + echo "==> Scoop manifest already up to date, skipping scoop" + skip+=(scoop) +fi + +if curl -fsSL --connect-timeout 5 "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=pscale-cli-bin" 2>/dev/null \ + | grep -q "pkgver=${VERSION}"; then + echo "==> AUR package already up to date, skipping aur" + skip+=(aur) +fi + +should_skip() { + local target=$1 + for s in "${skip[@]+"${skip[@]}"}"; do + [ "$target" = "$s" ] && return 0 + done + return 1 +} + +run=() +echo "" +echo "==> Release plan for ${GORELEASER_CURRENT_TAG}:" +for target in "${all_targets[@]}"; do + if should_skip "$target"; then + echo " skip ${target}" + else + echo " run ${target}" + run+=("$target") + fi +done +echo "" + +if [ ${#run[@]} -eq 0 ]; then + echo "==> All targets already published, nothing to do." + exit 0 +fi + +if [ "$DRY_RUN" = "true" ]; then + echo "==> Dry run, exiting." + exit 0 +fi + +GORELEASER_SKIP=$(IFS=,; echo "${skip[*]}") + tmpdir=$(mktemp -d) cat >"$tmpdir/docker.json" < Date: Mon, 30 Mar 2026 17:47:04 -0400 Subject: [PATCH 2/3] Replace existing GitHub release assets during republish GoReleaser doesn't allow skipping just the GitHub publish step, so this allows the rest of the release to be idempotent. --- .goreleaser.yml | 1 + script/release.sh | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 9e5a66ed..23f7ca28 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,6 +2,7 @@ project_name: pscale version: 2 release: prerelease: auto # don't publish release with -rc1,-pre, etc suffixes + replace_existing_artifacts: true before: hooks: - go mod tidy diff --git a/script/release.sh b/script/release.sh index 62a4aa15..40a15a3f 100755 --- a/script/release.sh +++ b/script/release.sh @@ -13,15 +13,9 @@ export GORELEASER_CURRENT_TAG VERSION="${GORELEASER_CURRENT_TAG#v}" -all_targets=(publish docker homebrew scoop aur) +all_targets=(docker homebrew scoop aur) skip=() -asset_count=$(gh release view "$GORELEASER_CURRENT_TAG" --json assets --jq '.assets | length' 2>/dev/null || echo "0") -if [ "$asset_count" -gt 0 ]; then - echo "==> GitHub Release assets already exist, skipping publish" - skip+=(publish) -fi - if docker manifest inspect "planetscale/pscale:${GORELEASER_CURRENT_TAG}" >/dev/null 2>&1; then echo "==> Docker image already exists, skipping docker" skip+=(docker) From ad43183d0206d57d43e830b063a43306b78412be Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Mon, 30 Mar 2026 18:07:41 -0400 Subject: [PATCH 3/3] Ensure safe variable expansion of `skip` --- script/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release.sh b/script/release.sh index 40a15a3f..f66a6f75 100755 --- a/script/release.sh +++ b/script/release.sh @@ -70,7 +70,7 @@ if [ "$DRY_RUN" = "true" ]; then exit 0 fi -GORELEASER_SKIP=$(IFS=,; echo "${skip[*]}") +GORELEASER_SKIP=$(IFS=,; echo ${skip[*]+"${skip[*]}"}) tmpdir=$(mktemp -d) cat >"$tmpdir/docker.json" <