From 98656d12e4e1eb14d0b016e7bfadc267478f1edc Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Tue, 31 Mar 2026 10:47:23 -0400 Subject: [PATCH] Release is not idempotent --- .github/workflows/release.yml | 25 ++------------ .goreleaser.yml | 1 - script/release.sh | 65 +---------------------------------- 3 files changed, 3 insertions(+), 88 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08bbc5f4..8135055f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,19 +2,12 @@ name: Release on: workflow_dispatch: - inputs: - version: - description: >- - Existing version tag to re-publish (e.g. v0.200.0). - Leave empty to bump and release a new version. - required: false jobs: release: # This workflow should always be run on main - this is enforced by the # `release` environment directly but added here for visibility. - # If the workflow fails during publishing, run a new workflow - # with the `version` that needs to be published. + # If the workflow fails during publishing, a new release must be published if: github.ref == 'refs/heads/main' && github.run_attempt == '1' runs-on: ubuntu-latest @@ -34,30 +27,16 @@ jobs: git config user.name "planetscale-actions-bot" git config user.email "60239337+planetscale-actions-bot@users.noreply.github.com" - - name: Checkout existing tag - if: inputs.version != '' - run: git checkout "refs/tags/$VERSION" - env: - VERSION: ${{ inputs.version }} - - name: Bump version and push tag - if: inputs.version == '' id: bump env: GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} run: script/bump-version.sh - - name: Resolve version - id: version - env: - INPUT_VERSION: ${{ inputs.version }} - BUMP_VERSION: ${{ steps.bump.outputs.RELEASE_VERSION }} - run: echo "TAG=${INPUT_VERSION:-$BUMP_VERSION}" >> "$GITHUB_OUTPUT" - - name: Publish artifacts env: GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.TAG }} + GORELEASER_CURRENT_TAG: ${{ steps.bump.outputs.RELEASE_VERSION }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} AUR_KEY: ${{ secrets.AUR_KEY }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 23f7ca28..9e5a66ed 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,7 +2,6 @@ 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 f66a6f75..a8cf4ca5 100755 --- a/script/release.sh +++ b/script/release.sh @@ -2,7 +2,6 @@ set -eu -DRY_RUN="${DRY_RUN:-false}" WORKDIR=$(pwd) if [ -z "${GORELEASER_CURRENT_TAG:-}" ]; then @@ -11,67 +10,6 @@ if [ -z "${GORELEASER_CURRENT_TAG:-}" ]; then fi export GORELEASER_CURRENT_TAG -VERSION="${GORELEASER_CURRENT_TAG#v}" - -all_targets=(docker homebrew scoop aur) -skip=() - -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[*]+"${skip[*]}"}) - tmpdir=$(mktemp -d) cat >"$tmpdir/docker.json" <