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
59 changes: 38 additions & 21 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ format:

# test + produce all shippable artifacts (optimized WASM, release binaries, .vsix). Nothing is pushed.
[group('build')]
release: (_require-plugin "obsidian-vithanco") (_require-plugin "vscode-vithanco")
release: _release-preflight
#!/usr/bin/env bash
set -euo pipefail
# Run the full build+test gate in RELEASE config (optimized WASM flows into the
Expand Down Expand Up @@ -528,7 +528,7 @@ parity: (_require-plugin "obsidian-vithanco") (_require-plugin "vscode-vithanco"

# Commit + push + tag + GitHub release for BOTH plugins (parity-guarded). Stops before the marketplace.
[group('publish')]
publish-plugins: _require-maintainer (_require-plugin "obsidian-vithanco") (_require-plugin "vscode-vithanco")
publish-plugins: _require-maintainer _release-preflight
#!/usr/bin/env bash
set -euo pipefail
OBS_V=$(node -p "require('./obsidian-vithanco/manifest.json').version")
Expand All @@ -542,19 +542,9 @@ publish-plugins: _require-maintainer (_require-plugin "obsidian-vithanco") (_req
# this the recipe discovers problems halfway through — and since Obsidian is
# published first, a late failure leaves one plugin released and the other not.
FAIL=0
# Both plugins ship the engine, so a release must come from a VGraph commit
# that main holds, and say which one: the one build-wasm.sh recorded.
if [ -n "$(git status --porcelain)" ]; then
echo "Preflight: VGraph has uncommitted changes — the engine would ship from code no commit holds." >&2
FAIL=1
fi
if ! git fetch -q origin main 2>/dev/null; then
echo "Preflight: could not fetch VGraph's origin/main to check against." >&2
FAIL=1
elif ! git merge-base --is-ancestor HEAD origin/main 2>/dev/null; then
echo "Preflight: VGraph $(git rev-parse --short HEAD) is not on origin/main — push and merge it first." >&2
FAIL=1
fi
# Both plugins ship the engine, so a release must name the VGraph commit it was
# built from: the one build-wasm.sh recorded. (_release-preflight has checked
# VGraph and the plugin branches, and fetched origin/main.)
# What build-wasm.sh reads. A version-bump commit after the build is expected.
ENGINE_PATHS=(Sources Package.swift Package.resolved .swift-version build-wasm.sh
scripts/wasm-sdk.sh scripts/embedded-unicode.sh VGraphWasm/Package.swift
Expand All @@ -569,7 +559,7 @@ publish-plugins: _require-maintainer (_require-plugin "obsidian-vithanco") (_req
echo "Preflight: the engine was built from an unknown commit — git could not read the checkout. Rebuild it here." >&2
FAIL=1
elif [ "${BUILT%-dirty}" != "$BUILT" ]; then
echo "Preflight: the engine was built from uncommitted changes on ${BUILT:0:12} — commit, then run 'just plugins-release' again." >&2
echo "Preflight: the engine was built from uncommitted changes on ${BUILT:0:12} — commit and merge them, then rebuild with 'just release'." >&2
FAIL=1
elif ! git merge-base --is-ancestor "$BUILT" origin/main 2>/dev/null; then
echo "Preflight: the engine was built from ${BUILT:0:12}, which is not on origin/main." >&2
Expand All @@ -588,11 +578,6 @@ publish-plugins: _require-maintainer (_require-plugin "obsidian-vithanco") (_req
ENGINE="VGraph ${BUILT:0:12}"
for spec in "obsidian-vithanco:main.js" "vscode-vithanco:vithanco-${OBS_V}.vsix"; do
DIR=${spec%%:*}; ASSET=${spec#*:}
BRANCH=$(git -C "$DIR" branch --show-current)
if [ "$BRANCH" != main ]; then
echo "Preflight: $DIR is on '$BRANCH', not main — the release would tag and push that branch." >&2
FAIL=1
fi
if git -C "$DIR" rev-parse -q --verify "refs/tags/$OBS_V" >/dev/null; then
echo "Preflight: $DIR already has tag $OBS_V — bump before publishing." >&2
FAIL=1
Expand Down Expand Up @@ -787,6 +772,38 @@ _require-gcloud:
fi

# First dependency of every recipe that publishes under the maintainer's accounts.
# What must already hold before a release is built or published, checked in
# seconds: `just release` runs this first, so a version bump that is not yet
# merged stops it here, not after its tests and builds.
_release-preflight: (_require-plugin "obsidian-vithanco") (_require-plugin "vscode-vithanco")
#!/usr/bin/env bash
set -uo pipefail
FAIL=0
# A failed `git status` prints nothing, which would read as clean.
if ! STATUS=$(git status --porcelain 2>&1); then
echo "Preflight: could not read VGraph's git status: $STATUS" >&2
FAIL=1
elif [ -n "$STATUS" ]; then
echo "Preflight: VGraph has uncommitted changes — the engine would ship from code no commit holds." >&2
echo " A version bump goes in through a PR: commit it, merge it, then 'git switch main && git pull'." >&2
FAIL=1
fi
if ! git fetch -q origin main 2>/dev/null; then
echo "Preflight: could not fetch VGraph's origin/main to check against." >&2
FAIL=1
elif ! git merge-base --is-ancestor HEAD origin/main 2>/dev/null; then
echo "Preflight: VGraph $(git rev-parse --short HEAD) is not on origin/main — push and merge it first." >&2
FAIL=1
fi
for DIR in obsidian-vithanco vscode-vithanco; do
BRANCH=$(git -C "$DIR" branch --show-current)
if [ "$BRANCH" != main ]; then
echo "Preflight: $DIR is on '$BRANCH', not main — the release would tag and push that branch." >&2
FAIL=1
fi
done
exit "$FAIL"

_require-maintainer:
#!/usr/bin/env bash
if [ "${VITHANCO_MAINTAINER:-}" != "1" ]; then
Expand Down
8 changes: 5 additions & 3 deletions release-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ printf '%s' "$SUMMARY" | while IFS= read -r s; do echo " $s"; done
echo ""
echo "plugins.json updated. Nothing committed, tagged or pushed."
echo ""
echo "Next: just release # builds what publish-plugins ships"
echo " just publish-plugins # commits, tags and creates both GitHub releases"
echo " then commit plugins.json and vgraph-mcp-node here in a PR; main takes no direct pushes"
echo "Next, in this order (just release refuses an uncommitted VGraph):"
echo " 1. commit plugins.json and vgraph-mcp-node here in a PR and merge it; main takes no direct pushes"
echo " 2. git switch main && git pull"
echo " 3. just release # builds what publish-plugins ships"
echo " 4. just publish-plugins # commits the plugins' bumps, tags and creates both GitHub releases"
23 changes: 23 additions & 0 deletions scripts/publish-plugins.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ given_plugins_at 1.2.3
sed -i.bak 's/^\([0-9a-f]*\) /\1-dirty /' "$WORK/website/Package/VGRAPH_BUILD"
publish && fail "published an engine built from uncommitted changes"
grep -q 'uncommitted' "$WORK/out" || fail "does not say the build was uncommitted: $(cat "$WORK/out")"
# The fix is to commit and rebuild; plugins-release would bump the version again.
grep -q "just release" "$WORK/out" || fail "does not point at 'just release': $(cat "$WORK/out")"
grep -q "plugins-release" "$WORK/out" && fail "advises plugins-release, which bumps again: $(cat "$WORK/out")"
nothing_released "dirty build"

# Given a plugin whose wasm is not the recorded build, when publishing, then nothing is released.
Expand Down Expand Up @@ -177,5 +180,25 @@ publish || fail "publishing refreshed glue failed: $(cat "$WORK/out")"
[ "$(git -C "$WORK/obsidian-vithanco" show 1.2.3:vendor/Package/index.js)" = "new glue" ] \
|| fail "the refreshed glue was not committed under the tag"

# Given VGraph with uncommitted changes (a version bump not yet merged), when
# `just release` starts, then it refuses before its long test and build run,
# not only publish-plugins after it.
given_plugins_at 1.2.3
echo '{"bumped":true}' > "$WORK/plugins.json"
just --justfile "$REPO_ROOT/justfile" --working-directory "$WORK" _release-preflight >"$WORK/out" 2>&1 \
&& fail "the release preflight accepted an uncommitted VGraph"
grep -q 'uncommitted' "$WORK/out" || fail "release preflight does not say VGraph is uncommitted: $(cat "$WORK/out")"
just --justfile "$REPO_ROOT/justfile" --show release | grep -q '^release: _release-preflight' \
|| fail "just release does not run _release-preflight first: $(just --justfile "$REPO_ROOT/justfile" --show release | grep '^release:')"

# Given a VGraph whose status git cannot read (a corrupt index), when the release
# preflight runs, then it refuses: empty output from a failed `git status` is
# not a clean checkout.
given_plugins_at 1.2.3
echo 'not an index' > "$WORK/.git/index"
just --justfile "$REPO_ROOT/justfile" --working-directory "$WORK" _release-preflight >"$WORK/out" 2>&1 \
&& fail "the release preflight accepted a VGraph whose status could not be read"
grep -q 'status' "$WORK/out" || fail "does not say the status could not be read: $(cat "$WORK/out")"

[ "$FAILED" -eq 0 ] && echo "✓ publish-plugins"
exit "$FAILED"
Loading