# Keeps one pull open that releases HUD's SDK, as knotless's release-pull.yml # does for its client: asked for at main, when main has change files, it # runs `knope release` on main's tip and force-pushes the commit to # `release/next`, opening a pull titled `Release `, or bringing the # open one up to date. Landing that pull bumps every package's version # together (knope.toml); release.yml, asked for at main once it has landed, # publishes them. Nothing is queued here, so when to release stays the # owner's call. # # knotless run rerun knotless://chadtmiller.com/hud --ref refs/heads/main --workflow release-pull # # The version is worked out here and given to knope with # --override-version: 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 alone. The open pull is found by its # title, `Release x.y.z` by the owner. Asked for on any other branch, it # makes the release commit there and prints the pull's body, pushing # nothing. # # RELEASE_PASSWORD is release.yml's app password of the owner's, granted # to main alone. # Its secrets are on ci.knotless.dev alone, the runner that runs only its # owner's repositories. runners: [ci.knotless.dev] on: asked: {refs: [refs/heads/*]} image: node:24.22.1 secrets: [RELEASE_PASSWORD] env: REPO: knotless://chadtmiller.com/hud OWNER: chadtmiller.com BRANCH: release/next KNOTLESS_APPVIEW: https://knotless.dev KNOPE_VERSION: 0.23.2 KNOPE_SHA256: c64f6281e012fc8e046ebd6f30be76c583e88b9ad55b00c7b1809b030db92eee steps: - name: changes run: | set -- .changeset/*.md if [ ! -e "$1" ]; then echo "no change files at $KNOTLESS_RUN_REF: nothing to release" touch ~/.done fi - name: tools run: | [ ! -e ~/.done ] || exit 0 cd /tmp curl -fsSLO "https://github.com/knope-dev/knope/releases/download/knope/v$KNOPE_VERSION/knope-x86_64-unknown-linux-musl.tgz" echo "$KNOPE_SHA256 knope-x86_64-unknown-linux-musl.tgz" | sha256sum -c - tar -xzf knope-x86_64-unknown-linux-musl.tgz install knope-x86_64-unknown-linux-musl/knope /usr/local/bin/ curl -fsSL https://knotless.dev/install.sh | KNOTLESS_INSTALL_DIR=/usr/local/bin sh - name: release commit run: | [ ! -e ~/.done ] || exit 0 git config --global --add safe.directory "$PWD" set -- .changeset/*.md count=$# bumps=$(sed -n 's/^default: *//p' "$@") current=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) IFS=. read -r major minor patch < ~/.version knope release --override-version "$version" git -c user.name=knotless -c user.email=knotless@knotless.invalid commit -aqm "Release $version" at=$(echo "$KNOTLESS_RUN_SHA" | cut -c1-12) notes=$(awk -v v="$version" '/^## / { on = ($2 == v); next } on' CHANGELOG.md) cat > ~/.body < release-pull.yml ## What changes HUD $version, as \`knope release --override-version $version\` makes it from main at $at: every version knope.toml names from $current to $version (the crates, the web packages, hudkit's), the version's CHANGELOG.md section, and the change files removed. $notes ## Why Apps built on HUD get main's changes only from a release. A 0.x minor change bumps the minor here, where knope alone would bump the patch. ## How it was checked The build is left to CI. EOF cat ~/.body - name: pull on: {refs: [refs/heads/main]} run: | [ ! -e ~/.done ] || exit 0 version=$(cat ~/.version) export KNOTLESS_IDENTIFIER="$OWNER" KNOTLESS_PASSWORD="$RELEASE_PASSWORD" 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 "$KNOTLESS_RUN_SHA:.changeset")" ] && git merge-tree --write-tree "$KNOTLESS_RUN_SHA" 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