| 1 | #!/usr/bin/env bash |
| 2 | # Generate the GitHub Release body for a tag. |
| 3 | # |
| 4 | # Usage: generate-release-body.sh <vX.Y.Z> [path/to/CHANGELOG.md] |
| 5 | # |
| 6 | # The install/verify sections are static; the release notes and contributor |
| 7 | # credits come from the CHANGELOG section for the version, so they can never |
| 8 | # drift the way a hand-edited workflow body does. |
| 9 | set -euo pipefail |
| 10 | |
| 11 | tag="${1:?usage: $0 <vX.Y.Z> [CHANGELOG.md]}" |
| 12 | changelog="${2:-CHANGELOG.md}" |
| 13 | version="${tag#v}" |
| 14 | |
| 15 | section="$(awk -v version="${version}" ' |
| 16 | index($0, "## [" version "]") == 1 { in_section = 1; next } |
| 17 | in_section && /^## \[/ { exit } |
| 18 | in_section { print } |
| 19 | ' "${changelog}")" |
| 20 | |
| 21 | contributors="$(printf '%s\n' "${section}" | awk ' |
| 22 | /^### Contributors[[:space:]]*$/ { in_contributors = 1; next } |
| 23 | in_contributors && /^### / { exit } |
| 24 | in_contributors { print } |
| 25 | ')" |
| 26 | |
| 27 | upgrade_notes="$(printf '%s\n' "${section}" | awk ' |
| 28 | /^### Upgrade notes[[:space:]]*$/ { in_upgrade = 1; next } |
| 29 | in_upgrade && /^### / { exit } |
| 30 | in_upgrade { print } |
| 31 | ' | sed '/./,$!d')" |
| 32 | notes="$(printf '%s\n' "${section}" | awk ' |
| 33 | /^### (Contributors|Upgrade notes)[[:space:]]*$/ { in_contributors = 1; next } |
| 34 | in_contributors && /^### / { in_contributors = 0 } |
| 35 | !in_contributors { print } |
| 36 | ')" |
| 37 | |
| 38 | summary="$(printf '%s\n' "${notes}" | awk '/^### / { in_details = 1 } !in_details { print }')" |
| 39 | details="$(printf '%s\n' "${notes}" | awk '/^### / { in_details = 1 } in_details { print }')" |
| 40 | if [[ "${summary}" != *[![:space:]]* ]]; then |
| 41 | summary="${notes}" |
| 42 | details="" |
| 43 | fi |
| 44 | |
| 45 | render_body() { |
| 46 | printf "## What's in %s\n\n" "${tag}" |
| 47 | if [[ "${upgrade_notes}" == *[![:space:]]* ]]; then |
| 48 | printf '%s\n\n%s\n\n' '### Upgrade notes' "${upgrade_notes}" |
| 49 | fi |
| 50 | if [[ -n "${summary}" ]]; then |
| 51 | printf '%s\n' "${summary}" |
| 52 | else |
| 53 | printf '%s\n' "See the changelog link below for this release's notes." |
| 54 | fi |
| 55 | |
| 56 | cat <<EOF |
| 57 | |
| 58 | ## Install |
| 59 | |
| 60 | ### Recommended — official GitHub release |
| 61 | |
| 62 | New macOS/Linux install (checksummed binaries from this release): |
| 63 | |
| 64 | \`\`\`bash |
| 65 | curl -fsSL https://codewhale.net/install.sh | CODEWHALE_VERSION="${tag}" sh |
| 66 | "\$HOME/.local/bin/codewhale" --version |
| 67 | \`\`\` |
| 68 | |
| 69 | For Windows, use the matching installer or archive below. For an existing |
| 70 | direct install, run \`codewhale update\`; it prints the executable path and |
| 71 | keeps newer builds. If the install directory is occupied by a different build, |
| 72 | use the fresh-directory migration in [the installation guide](https://github.com/codewhale-hq/CodeWhale/blob/main/docs/INSTALL.md). |
| 73 | |
| 74 | ### Secondary packaging — npm and Cargo |
| 75 | |
| 76 | \`\`\`bash |
| 77 | npm install -g codewhale |
| 78 | # or build from source |
| 79 | cargo install codewhale-cli --locked |
| 80 | \`\`\` |
| 81 | |
| 82 | The wrapper downloads the matched \`codewhale\` and \`codew\` command assets |
| 83 | from this Release. Both contain the same compiled runtime. |
| 84 | |
| 85 | ### Docker / GHCR |
| 86 | |
| 87 | \`\`\`bash |
| 88 | docker run --rm -it \\ |
| 89 | -e DEEPSEEK_API_KEY="\$DEEPSEEK_API_KEY" \\ |
| 90 | -v codewhale-home:/home/codewhale/.codewhale \\ |
| 91 | ghcr.io/codewhale-hq/codewhale:${tag} |
| 92 | \`\`\` |
| 93 | |
| 94 | The image exposes the same runtime as both \`codewhale\` and \`codew\`. The |
| 95 | \`latest\` tag is also updated on release. |
| 96 | |
| 97 | ### Cargo (Linux / macOS) |
| 98 | |
| 99 | \`\`\`bash |
| 100 | cargo install codewhale-cli --locked |
| 101 | \`\`\` |
| 102 | |
| 103 | The Cargo package installs \`codewhale\`. Cargo cannot create a second command |
| 104 | alias from one binary target; users who want the shorter spelling can add a |
| 105 | \`codew\` symlink to that installed executable. The npm, Homebrew, archive, |
| 106 | shell-installer, and container channels install both command names directly. |
| 107 | |
| 108 | ### Manual download — platform archives (recommended) |
| 109 | |
| 110 | Each archive below contains the same runtime under the \`codewhale\` and |
| 111 | \`codew\` command names, plus an install script: |
| 112 | |
| 113 | | Platform | Archive | Install script | |
| 114 | |---|---|---| |
| 115 | | Linux x64 | \`codewhale-linux-x64.tar.gz\` | \`install.sh\` | |
| 116 | | Linux ARM64 | \`codewhale-linux-arm64.tar.gz\` | \`install.sh\` | |
| 117 | | Android ARM64 (Termux) | \`codewhale-android-arm64.tar.gz\` | \`install.sh\` | |
| 118 | | HarmonyOS ARM64 (native) | \`codewhale-ohos-arm64.tar.gz\` | \`install.sh\` | |
| 119 | | macOS x64 | \`codewhale-macos-x64.tar.gz\` | \`install.sh\` | |
| 120 | | macOS ARM | \`codewhale-macos-arm64.tar.gz\` | \`install.sh\` | |
| 121 | | Windows x64 (installer) | \`CodeWhaleSetup.exe\` | NSIS setup | |
| 122 | | Windows x64 | \`codewhale-windows-x64.zip\` | \`install.bat\` | |
| 123 | | Windows x64 (portable) | \`codewhale-windows-x64-portable.zip\` | — | |
| 124 | | Windows ARM64 | \`codewhale-windows-arm64.zip\` | \`install.bat\` | |
| 125 | | Windows ARM64 (portable) | \`codewhale-windows-arm64-portable.zip\` | — | |
| 126 | |
| 127 | **Unix (Linux / macOS):** |
| 128 | \`\`\`bash |
| 129 | tar xzf codewhale-<platform>.tar.gz |
| 130 | cd codewhale-<platform> |
| 131 | ./install.sh |
| 132 | \`\`\` |
| 133 | |
| 134 | **Windows:** |
| 135 | - For the installer path, run \`CodeWhaleSetup.exe\`; it installs |
| 136 | \`codewhale.exe\`, \`codew.exe\`, and \`codewhale.bat\` under |
| 137 | \`%LOCALAPPDATA%\\Programs\\CodeWhale\\bin\`, adds that directory to the |
| 138 | current-user PATH, and creates a Start Menu shortcut that prefers |
| 139 | Windows Terminal (\`wt.exe\`) when it is installed. |
| 140 | - Extract the archive for your machine: \`codewhale-windows-x64.zip\` or |
| 141 | \`codewhale-windows-arm64.zip\` |
| 142 | - Double-click \`codewhale.bat\` (not the raw \`.exe\`) to launch |
| 143 | - Run \`install.bat\` to copy the binaries and launcher to \`%USERPROFILE%\\bin\` |
| 144 | - Add \`%USERPROFILE%\\bin\` to your PATH |
| 145 | |
| 146 | The **portable** Windows archive skips the install script — extract and run \`codewhale.bat\` from any directory. The NSIS installer is currently unsigned and may trigger Windows SmartScreen until a signing certificate is wired into the release pipeline. |
| 147 | |
| 148 | Each platform also has **bare, unarchived** \`codewhale-<platform>\` and |
| 149 | \`codew-<platform>\` assets. The seven \`codewhale-tui-<platform>\` filenames |
| 150 | attached to v0.9.5 are byte-identical compatibility copies used only to let |
| 151 | already-installed v0.9.4 clients discover and cross this single-binary |
| 152 | transition; current installers do not expose a third runtime. The legacy npm |
| 153 | package \`deepseek-tui\` is deprecated and is not republished. For migration |
| 154 | from v0.8.x legacy binary names, see \`docs/REBRAND.md\`. |
| 155 | |
| 156 | ### Verify (recommended) |
| 157 | |
| 158 | Download the checksum manifests from this Release and verify: |
| 159 | |
| 160 | \`\`\`bash |
| 161 | # Linux — archive bundles |
| 162 | sha256sum -c codewhale-bundles-sha256.txt --ignore-missing |
| 163 | |
| 164 | # Linux — individual binaries |
| 165 | sha256sum -c codewhale-artifacts-sha256.txt --ignore-missing |
| 166 | |
| 167 | # macOS |
| 168 | shasum -a 256 -c codewhale-bundles-sha256.txt --ignore-missing |
| 169 | shasum -a 256 -c codewhale-artifacts-sha256.txt --ignore-missing |
| 170 | \`\`\` |
| 171 | |
| 172 | EOF |
| 173 | |
| 174 | if [[ -n "${details}" ]]; then |
| 175 | printf '%s\n\n' '<details>' '<summary>Full release notes</summary>' |
| 176 | printf '%s\n\n' "${details}" '</details>' |
| 177 | fi |
| 178 | |
| 179 | cat <<EOF |
| 180 | |
| 181 | ## Contributors |
| 182 | EOF |
| 183 | |
| 184 | if [[ -n "${contributors}" ]]; then |
| 185 | printf '%s\n' "${contributors}" |
| 186 | else |
| 187 | printf '%s\n' "Thank you to everyone whose reports, PRs, reviews, and reproductions shaped this release." |
| 188 | fi |
| 189 | |
| 190 | cat <<EOF |
| 191 | |
| 192 | See [CHANGELOG.md](https://github.com/codewhale-hq/CodeWhale/blob/main/CHANGELOG.md) for full notes and [docs/CHANGELOG_ARCHIVE.md](https://github.com/codewhale-hq/CodeWhale/blob/main/docs/CHANGELOG_ARCHIVE.md) for older releases. |
| 193 | EOF |
| 194 | } |
| 195 | |
| 196 | body="$(render_body)" |
| 197 | if (( ${#body} >= 125000 )); then |
| 198 | if [[ -z "${details}" ]]; then |
| 199 | summary="" |
| 200 | fi |
| 201 | details="The full notes exceed GitHub's release-description limit. Read the [complete changelog for ${tag}](https://github.com/codewhale-hq/CodeWhale/blob/${tag}/CHANGELOG.md)." |
| 202 | body="$(render_body)" |
| 203 | fi |
| 204 | if (( ${#body} >= 125000 )); then |
| 205 | echo "Release summary, installation instructions and contributor credits exceed GitHub's 125000-character limit." >&2 |
| 206 | exit 1 |
| 207 | fi |
| 208 | printf '%s\n' "${body}" |
| 209 |