~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Releases are cut from change files, as the Release pull

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:release/flow
.knotless/workflows/check.yml+4−1
@@ -1,5 +1,6 @@
# Formatting, lints and the dependencies, as `just lint` checks the Rust, on
# every pull and push to main; test.yml runs the tests.
# every pull and push to main; test.yml runs the tests. On a pull, that a
# change people see comes with a change file (harness/changes.sh).
#
# The image is the Rust `just lint` runs locally, so a newer release's new
# lints land on purpose. The build, the toolchain's components and
@@ -31,3 +32,5 @@ steps:
/opt/cargo-deny/bin/cargo-deny --version 2>/dev/null | grep -qx "cargo-deny $v" ||
cargo install --locked --force --version "$v" --root /opt/cargo-deny cargo-deny
/opt/cargo-deny/bin/cargo-deny check
- name: changes
run: harness/changes.sh
deploy/release.shnew+139−0
@@ -0,0 +1,139 @@
#!/usr/bin/env bash
# Releases the workspace from main's change files, as the repository's
# owner, signed in with `knotless login`:
#
# deploy/release.sh [--dry-run]
#
# First it tags the release that last landed: when main's version has a
# commit on main titled `Release <version>` and no tag `v<version>`, it
# tags that commit, which mirror.yml then pushes to GitHub. Then, when
# main has change files, it cuts the next release at main's tip, in a
# worktree of its own: `knope release --override-version <version>`,
# committed as `Release <version>`, force-pushed to release/next, and the
# pull of that title opened, or the open one brought up to date. Landing
# that pull is the release; run this again once it has, to tag it.
#
# The version is worked out here, not by knope: a change file's `minor` or
# `major` bumps 0.x's minor, where knope would bump the patch, and a
# `patch` the patch; from 1.0 on, each bumps its own part. A pull already
# holding main's change files, and still merging with main, is left as it
# is, so its checks run again only when what it releases changes.
#
# It runs here rather than in a workflow: the repository is private, and
# reading or writing it takes an OAuth login's space credential, which an
# app password, all a run could sign in with, cannot get.
#
# With --dry-run it tags nothing, and makes the release commit and prints
# the pull's body, pushing nothing.
set -euo pipefail
cd "$(dirname "$0")/.."
REPO=knotless://chadtmiller.com/group-host
OWNER=chadtmiller.com
BRANCH=release/next
dry=
case "${1:-}" in
--dry-run) dry=1 ;;
"") ;;
*) sed -n '5p' "$0" >&2; exit 2 ;;
esac
command -v knope >/dev/null || { echo "needs knope (https://knope.tech): cargo install knope" >&2; exit 1; }
root=$PWD
git fetch -q "$REPO" main
main=$(git rev-parse FETCH_HEAD)
current=$(git show "$main:Cargo.toml" | sed -n 's/^version = "\(.*\)"/\1/p' | head -1)
# The release that landed last, tagged once.
landed=$(git log --format='%H%x09%s' "$main" | awk -F '\t' -v t="Release $current" '$2 == t { print $1; exit }')
if [ -z "$landed" ]; then
echo "main's $current came from no release pull: nothing to tag"
else
# Exit 2 alone says there is no such tag; any other failure says nothing.
asked=0
git ls-remote --exit-code -q "$REPO" "refs/tags/v$current" >/dev/null || asked=$?
case $asked in
0) echo "v$current is tagged already" ;;
2)
if [ -n "$dry" ]; then
echo "would tag $landed v$current"
else
knotless tag create "$REPO" "v$current" "$landed"
echo "tagged $landed v$current"
fi
;;
*) echo "could not ask $REPO whether v$current is tagged" >&2; exit 1 ;;
esac
fi
tree=$(mktemp -d)
trap 'git -C "$root" worktree remove --force "$tree"' EXIT
git worktree add -q --detach "$tree" "$main"
cd "$tree"
set -- .changeset/*.md
if [ ! -e "$1" ]; then
echo "no change files on main: nothing to release"
exit 0
fi
count=$#
bumps=$(sed -n 's/^default: *//p' "$@")
IFS=. read -r major minor patch <<< "$current"
if echo "$bumps" | grep -qx major && [ "$major" != 0 ]; then
version=$((major + 1)).0.0
elif echo "$bumps" | grep -qxE 'major|minor'; then
version=$major.$((minor + 1)).0
else
version=$major.$minor.$((patch + 1))
fi
knope release --override-version "$version"
git commit -aqm "Release $version"
at=$(echo "$main" | cut -c1-12)
notes=$(awk -v v="$version" '/^## / { on = ($2 == v); next } on' CHANGELOG.md)
body=$(mktemp)
cat > "$body" <<EOF
Releases group-host $version, from the $count change files on main: its changelog is below. Merging this pull releases it; \`just release\` then tags it \`v$version\`, and brings this pull up to date as more change files land.
<details>
<summary>deploy/release.sh</summary>
## What changes
group-host $version, as \`knope release --override-version $version\` makes it from main at $at: the workspace version from $current to $version in Cargo.toml and the crates' Cargo.lock entries, which \`/xrpc/_health\` and the MCP server's \`serverInfo\` name once it is deployed, the version's CHANGELOG.md section, and the change files removed.
$notes
## Why
A version names what the host, the console and the command do for those who run and use them. A 0.x minor change bumps the minor here, where knope alone would bump the patch.
## How it was checked
The build and tests are left to CI.
</details>
EOF
if [ -n "$dry" ]; then
cat "$body"
exit 0
fi
pull=$(knotless pull list "$REPO" -q "is:pull state:open author:$OWNER Release" |
awk -F '\t' '$4 ~ /^Release [0-9]+\.[0-9]+\.[0-9]+$/ { print $3; exit }')
if [ -n "$pull" ] && git fetch -q "$REPO" "refs/heads/$BRANCH" &&
[ "$(git rev-parse "FETCH_HEAD^:.changeset")" = "$(git rev-parse "$main:.changeset")" ] &&
git merge-tree --write-tree "$main" FETCH_HEAD > /dev/null; then
echo "$pull releases main's change files already and merges with main: nothing to push"
exit 0
fi
git push -q --force "$REPO" "HEAD:refs/heads/$BRANCH"
if [ -z "$pull" ]; then
knotless pull create "$REPO" main "$REPO" "$BRANCH" "Release $version" -m - < "$body"
else
knotless pull retarget "$REPO" "$pull" --head "$BRANCH"
knotless pull edit "$REPO" "$pull" --title "Release $version" -m - < "$body"
echo "updated $pull"
fi
docs/reference/cli.md+1−0
@@ -185,3 +185,4 @@ An unknown command or flag fails with its usage, and any failure exits 1.
| `docs` | checks the docs' links and anchors, as the `docs` check runs it |
| `docs-site` | serves the docs as their site at http://localhost:4321/, updating as they change |
| `docs-deploy` | builds the docs site and deploys it as the repository's ([development](../development.md#the-docs-site)) |
| `release [--dry-run]` | tags the release that last landed, then cuts the next from main's change files as the `Release <version>` pull ([development](../development.md#releasing)) |
docs/development.md+43−0
@@ -253,3 +253,46 @@ written (`.claude/hooks/format.mjs`).
`just lex` is the `lexicons` check, with goat 0.2.8 in CI. `just docs`
with the site's build is the `docs` check. `AGENTS.md` says what each
workflow runs, and when.
## Releasing
The workspace has one version, in `Cargo.toml`, which `/xrpc/_health`
and the MCP server's `serverInfo` name. It's set with
[knope](https://knope.tech) from change files, not conventional commits.
A pull that changes what someone running a group, calling the host, or
using the command or the console sees adds a change file under
`.changeset/`, as `knope document-change` writes one. Its front matter
names the bump (`default: patch`, `minor` or `major`), and below it a
heading and a line say what changed for them. The `check` check asks
for one on any pull that changes `crates/*/src`, `web/src`,
`web/messages`, `lexicons/fyi` or `packages/sdk/src`
(`harness/changes.sh`). A change no one sees says `Changeset: none` on a
line of one of its commits' messages instead. The pull's body would be
the place, but a run can't read it, since the repository is private.
`just release` (`deploy/release.sh`) cuts a release from main's change
files. It works out the version: a `minor` or `major` file bumps 0.x's
minor, where knope alone would bump the patch, and a `patch` file the
patch; from 1.0 on, each bumps its own part. It runs `knope release
--override-version <version>` at main's tip, in a worktree of its own,
which bumps `Cargo.toml` and the crates' entries in `Cargo.lock`, writes
the version's section of `CHANGELOG.md`, and deletes the change files.
It commits that as `Release <version>`, force-pushes it to
`release/next`, and opens the pull of that title with the changelog in
its body, or brings the open one up to date. A pull that already holds
main's change files and still merges with main is left alone, so its
checks don't run again for nothing.
Merging that pull is the release, and `deploy` puts it up on
next.opensocial.fyi as it does any push to main. The next `just release`
tags its commit `v<version>` before it cuts anything, and `mirror` pushes
the tag to GitHub. `just release --dry-run` tags nothing, makes the
release commit, and prints the pull's body, pushing nothing.
The owner runs it, signed in with `knotless login`, with knope
installed (`cargo install knope`). No workflow can, for the same reason
as the docs site: reading or writing a private repository takes an OAuth
login's space credential, and an app password, all a run could sign in
with, can't get one. For the same reason, nothing is published as a
knotless release: knotless refuses a private repository's releases.
harness/changes.shnew+42−0
@@ -0,0 +1,42 @@
#!/bin/sh
# Whether a pull that changes what the host, its console, its MCP tools,
# the command, the lexicons or the SDK do says so in a change file, as
# AGENTS.md (Versioning) asks: it adds a file under .changeset/, as `knope
# document-change` writes one, or one of its commits says on a line of
# its message
#
# Changeset: none
#
# for a change no one running or using them sees. The pull's body would
# be the place, but a run cannot read it: it is kept in the private
# repository's space. Run by check.yml in a pull's run, at its head merged
# with its base; elsewhere it passes, since a push to main carries pulls
# checked already.
set -eu
[ -n "${KNOTLESS_RUN_PULL:-}" ] || { echo "not a pull: nothing to check"; exit 0; }
base="$KNOTLESS_RUN_BASE"
git config --global --add safe.directory '*'
changed=$(git diff --name-only "$base" HEAD -- \
crates/group-host/src crates/group-host-mcp/src crates/opensocial/src \
web/src web/messages lexicons/fyi packages/sdk/src)
if [ -z "$changed" ]; then
echo "nothing anyone uses is changed: no change file needed"
exit 0
fi
added=$(git diff --name-only --diff-filter=A "$base" HEAD -- '.changeset/*.md')
if [ -n "$added" ]; then
echo "what people use is changed, and said so in: $added"
exit 0
fi
if git log --format=%B "$base..HEAD" | grep -qx 'Changeset: none'; then
echo "what people use is changed, and a commit says no change file is needed"
exit 0
fi
echo "what people use is changed, in:"
printf "%s\n" "$changed" | sed 's/^/ /'
echo "but no change file was added under .changeset/. Add one, as \`knope document-change\` writes one (AGENTS.md, Versioning), or, if no one running or using the host sees the change, push a commit saying \`Changeset: none\` on a line of its message."
exit 1
AGENTS.md+19−1
@@ -194,7 +194,7 @@ that page in the same pull:
`docs/reference/mcp.md`
- a new page: the sidebar in `docs-site/astro.config.mjs`
- a command of `opensocial`, or a `just` recipe: `docs/reference/cli.md`
- building, testing, the checks: `docs/development.md`
- building, testing, the checks, releasing: `docs/development.md`
- a flow in the console a guide shows: that guide, its pictures drawn
again with `just shots` (the `e2e` check fails until they are)
@@ -216,6 +216,8 @@ pulls into it or into a `feature/` branch:
unsound or yanked crate, permissive licences only, and crates from
crates.io and the atproto registry alone. No crate has unsafe code:
`Cargo.toml` forbids it in every target, and the build refuses any.
On a pull, that a change people see comes with a change file
(`harness/changes.sh`, Versioning below).
- `test`: every test, under the 100% gate of lines and functions.
- `web`: oxfmt's format, the component layers, dialogs' titles, words
as messages, svelte-check (failing on any warning), and the build.
@@ -239,6 +241,22 @@ runs only its owner's repositories, and holds its secrets.
On a pull, `web`, `lexicons`, `e2e` and `docs` run only when it changes
what they read; otherwise each passes at once, noted as skipped.
## Versioning
A pull that changes what someone running a group, calling the host or
using the command or the console sees adds a change file under
`.changeset/`, as `knope document-change` writes one
(https://knope.tech): `default: patch`, `minor` or `major` in its front
matter, then a heading and a line for them. `just release`, run by the
owner, turns them into the version and CHANGELOG.md with `knope
release`, in the `Release <version>` pull; merging it releases, and the
next `just release` tags it `v<version>`. Commit titles stay prose: no
conventional commits. The `check` check fails a pull that changes
`crates/*/src`, `web/src`, `web/messages`, `lexicons/fyi` or
`packages/sdk/src` and adds no change file, unless one of its commits
says, on a line of its message, `Changeset: none`: for a change no one
running or using the host sees.
## Landing a change
Open a pull rather than committing to `main`: push the work to a branch
CHANGELOG.mdnew+6−0
@@ -0,0 +1,6 @@
# Changelog
What changed in each version of the group host, its console and the
`opensocial` command for those who run and use them, from the change
files in `.changeset/` (see `knope.toml`).
Justfile+6−0
@@ -52,6 +52,12 @@ docs-deploy:
cd docs-site && npm ci --no-audit --no-fund && npm run build
knotless site knotless://chadtmiller.com/group-host docs-site/dist --not-found 404.html
# Tags the release that last landed, then cuts the next from main's
# change files as the `Release <version>` pull (deploy/release.sh), as
# the owner, signed in with `knotless login`; --dry-run pushes nothing.
release *args:
deploy/release.sh {{args}}
lint:
{{cargo}} fmt --all --check
{{oxfmt}} --check {{js}}
knope.tomlnew+30−0
@@ -0,0 +1,30 @@
# Versioning, from change files: a pull that changes what someone running
# a group, calling the host or using the command sees adds one, with
# `knope document-change`, naming the bump and saying what changed for
# them. `knope release` bumps the workspace's version, writes CHANGELOG.md
# and removes the files it used; `just release` (deploy/release.sh) runs
# it. No conventional commits: commit titles say what changed, for us.
[package]
versioned_files = [
"Cargo.toml",
{ path = "Cargo.lock", dependency = "group-host" },
{ path = "Cargo.lock", dependency = "group-host-mcp" },
{ path = "Cargo.lock", dependency = "opensocial" },
]
changelog = "CHANGELOG.md"
[changes]
ignore_conventional_commits = true
[[workflows]]
name = "document-change"
[[workflows.steps]]
type = "CreateChangeFile"
[[workflows]]
name = "release"
[[workflows.steps]]
type = "PrepareRelease"