Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,28 +39,14 @@ jobs:
git config user.name "planetscale-cli[bot]"
git config user.email "272331943+planetscale-cli[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
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: ${{ steps.app-token.outputs.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 }}
Expand Down
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 1 addition & 64 deletions script/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -eu

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

if [ -z "${GORELEASER_CURRENT_TAG:-}" ]; then
Expand All @@ -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" <<EOF
{
Expand All @@ -87,5 +25,4 @@ EOF
trap 'rm -rf -- "$tmpdir"' EXIT

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