Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
85 lines
3.3 KiB
Bash
Executable File
85 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Update (or create) the draft GitHub release for the next release using the
|
|
# current next.mdx content. publish-new.ts finds this draft by name (vX.Y.0) and
|
|
# publishes its body verbatim at release time, so keeping it in sync with next.mdx
|
|
# means the GitHub release and the docs release page always match.
|
|
#
|
|
# Usage: ./update-draft-release.sh <tldraw-repo-dir> [next-version]
|
|
#
|
|
# next-version overrides the target tag (with or without a leading `v`). Pass it
|
|
# for a major release or any override, so the draft name matches the version
|
|
# publish-new.ts will resolve. When omitted, the target defaults to the next
|
|
# minor of last_version — the common case.
|
|
#
|
|
# Requires a local clone of tldraw/tldraw and an authenticated gh CLI.
|
|
|
|
set -e
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: $0 <tldraw-repo-dir> [next-version]" >&2
|
|
echo "Example: $0 /tmp/tldraw # minor bump of last_version" >&2
|
|
echo "Example: $0 /tmp/tldraw v6.0.0 # explicit target (major/override)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TLDRAW_REPO="$1"
|
|
NEXT_FILE="$TLDRAW_REPO/apps/docs/content/releases/next.mdx"
|
|
|
|
if [ ! -f "$NEXT_FILE" ]; then
|
|
echo "next.mdx not found at $NEXT_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "$2" ]; then
|
|
# Explicit target — normalize to a leading `v`. Use this for major releases or
|
|
# overrides, where publish-new.ts resolves the next version from NPM rather than
|
|
# a minor bump (e.g. --bump major -> v6.0.0).
|
|
next_tag="v$(echo "$2" | sed 's/^v//')"
|
|
else
|
|
# The draft tracks the next minor release. Derive it from last_version (the most
|
|
# recent published release recorded in next.mdx frontmatter): bump minor, patch 0.
|
|
# e.g. last_version v5.2.0 -> draft v5.3.0.
|
|
last_version=$(grep -E "^last_version:" "$NEXT_FILE" | head -1 | sed "s/last_version: *//" | tr -d "'\"[:space:]")
|
|
if [ -z "$last_version" ]; then
|
|
echo "Could not read last_version from $NEXT_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
major=$(echo "$last_version" | sed 's/^v//' | cut -d. -f1)
|
|
minor=$(echo "$last_version" | sed 's/^v//' | cut -d. -f2)
|
|
next_tag="v${major}.$((minor + 1)).0"
|
|
fi
|
|
|
|
# Body = next.mdx with the frontmatter block stripped (everything after the second ---).
|
|
body_file=$(mktemp)
|
|
awk 'f{print} /^---$/{c++; if(c==2){f=1}}' "$NEXT_FILE" > "$body_file"
|
|
|
|
# Fail loudly if there is nothing to publish rather than pushing an empty draft.
|
|
if ! grep -qE '[^[:space:]]' "$body_file"; then
|
|
echo "next.mdx has no content below the frontmatter; refusing to write an empty draft." >&2
|
|
rm -f "$body_file"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Draft release target: $next_tag" >&2
|
|
|
|
# Look up an existing release for this tag (finds drafts too).
|
|
existing=$(gh release view "$next_tag" -R tldraw/tldraw --json isDraft 2>/dev/null || echo "")
|
|
|
|
if [ -n "$existing" ]; then
|
|
is_draft=$(echo "$existing" | jq -r '.isDraft')
|
|
if [ "$is_draft" != "true" ]; then
|
|
echo "Release $next_tag already exists and is published; refusing to edit." >&2
|
|
rm -f "$body_file"
|
|
exit 1
|
|
fi
|
|
echo "Updating existing draft release $next_tag" >&2
|
|
gh release edit "$next_tag" -R tldraw/tldraw --title "$next_tag" --notes-file "$body_file"
|
|
else
|
|
echo "Creating new draft release $next_tag" >&2
|
|
gh release create "$next_tag" -R tldraw/tldraw --draft --title "$next_tag" --notes-file "$body_file"
|
|
fi
|
|
|
|
rm -f "$body_file"
|
|
echo "Done. Draft release $next_tag is in sync with next.mdx." >&2
|