Skip to content

Commit 4a39378

Browse files
authored
Merge pull request #1242 from planetscale/release-not-idempotent
Release is not idempotent
2 parents 54dc7ed + bb5b0b8 commit 4a39378

3 files changed

Lines changed: 3 additions & 88 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@ name: Release
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: >-
8-
Existing version tag to re-publish (e.g. v0.200.0).
9-
Leave empty to bump and release a new version.
10-
required: false
115

126
jobs:
137
release:
148
# This workflow should always be run on main - this is enforced by the
159
# `release` environment directly but added here for visibility.
16-
# If the workflow fails during publishing, run a new workflow
17-
# with the `version` that needs to be published.
10+
# If the workflow fails during publishing, a new release must be published
1811
if: github.ref == 'refs/heads/main' && github.run_attempt == '1'
1912

2013
runs-on: ubuntu-latest
@@ -46,28 +39,14 @@ jobs:
4639
git config user.name "planetscale-cli[bot]"
4740
git config user.email "272331943+planetscale-cli[bot]@users.noreply.github.com"
4841
49-
- name: Checkout existing tag
50-
if: inputs.version != ''
51-
run: git checkout "refs/tags/$VERSION"
52-
env:
53-
VERSION: ${{ inputs.version }}
54-
5542
- name: Bump version and push tag
56-
if: inputs.version == ''
5743
id: bump
5844
run: script/bump-version.sh
5945

60-
- name: Resolve version
61-
id: version
62-
env:
63-
INPUT_VERSION: ${{ inputs.version }}
64-
BUMP_VERSION: ${{ steps.bump.outputs.RELEASE_VERSION }}
65-
run: echo "TAG=${INPUT_VERSION:-$BUMP_VERSION}" >> "$GITHUB_OUTPUT"
66-
6746
- name: Publish artifacts
6847
env:
6948
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
70-
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.TAG }}
49+
GORELEASER_CURRENT_TAG: ${{ steps.bump.outputs.RELEASE_VERSION }}
7150
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
7251
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
7352
AUR_KEY: ${{ secrets.AUR_KEY }}

.goreleaser.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ project_name: pscale
22
version: 2
33
release:
44
prerelease: auto # don't publish release with -rc1,-pre, etc suffixes
5-
replace_existing_artifacts: true
65
before:
76
hooks:
87
- go mod tidy

script/release.sh

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -eu
44

5-
DRY_RUN="${DRY_RUN:-false}"
65
WORKDIR=$(pwd)
76

87
if [ -z "${GORELEASER_CURRENT_TAG:-}" ]; then
@@ -11,67 +10,6 @@ if [ -z "${GORELEASER_CURRENT_TAG:-}" ]; then
1110
fi
1211
export GORELEASER_CURRENT_TAG
1312

14-
VERSION="${GORELEASER_CURRENT_TAG#v}"
15-
16-
all_targets=(docker homebrew scoop aur)
17-
skip=()
18-
19-
if docker manifest inspect "planetscale/pscale:${GORELEASER_CURRENT_TAG}" >/dev/null 2>&1; then
20-
echo "==> Docker image already exists, skipping docker"
21-
skip+=(docker)
22-
fi
23-
24-
if gh api "repos/planetscale/homebrew-tap/contents/Formula/pscale.rb" --jq '.content' 2>/dev/null \
25-
| base64 --decode 2>/dev/null | grep -q "version \"${VERSION}\""; then
26-
echo "==> Homebrew formula already up to date, skipping homebrew"
27-
skip+=(homebrew)
28-
fi
29-
30-
if gh api "repos/planetscale/scoop-bucket/contents/pscale.json" --jq '.content' 2>/dev/null \
31-
| base64 --decode 2>/dev/null | grep -q "\"version\": \"${VERSION}\""; then
32-
echo "==> Scoop manifest already up to date, skipping scoop"
33-
skip+=(scoop)
34-
fi
35-
36-
if curl -fsSL --connect-timeout 5 "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=pscale-cli-bin" 2>/dev/null \
37-
| grep -q "pkgver=${VERSION}"; then
38-
echo "==> AUR package already up to date, skipping aur"
39-
skip+=(aur)
40-
fi
41-
42-
should_skip() {
43-
local target=$1
44-
for s in "${skip[@]+"${skip[@]}"}"; do
45-
[ "$target" = "$s" ] && return 0
46-
done
47-
return 1
48-
}
49-
50-
run=()
51-
echo ""
52-
echo "==> Release plan for ${GORELEASER_CURRENT_TAG}:"
53-
for target in "${all_targets[@]}"; do
54-
if should_skip "$target"; then
55-
echo " skip ${target}"
56-
else
57-
echo " run ${target}"
58-
run+=("$target")
59-
fi
60-
done
61-
echo ""
62-
63-
if [ ${#run[@]} -eq 0 ]; then
64-
echo "==> All targets already published, nothing to do."
65-
exit 0
66-
fi
67-
68-
if [ "$DRY_RUN" = "true" ]; then
69-
echo "==> Dry run, exiting."
70-
exit 0
71-
fi
72-
73-
GORELEASER_SKIP=$(IFS=,; echo ${skip[*]+"${skip[*]}"})
74-
7513
tmpdir=$(mktemp -d)
7614
cat >"$tmpdir/docker.json" <<EOF
7715
{
@@ -87,5 +25,4 @@ EOF
8725
trap 'rm -rf -- "$tmpdir"' EXIT
8826

8927
cd "$WORKDIR"
90-
make release DOCKER_CREDS_FILE="$tmpdir/docker.json" \
91-
GORELEASER_EXTRA_ARGS="${GORELEASER_SKIP:+--skip=${GORELEASER_SKIP}}"
28+
make release DOCKER_CREDS_FILE="$tmpdir/docker.json"

0 commit comments

Comments
 (0)