| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 5 | tmp_dir="$(mktemp -d)" |
| 6 | export GIT_CONFIG_COUNT=2 |
| 7 | export GIT_CONFIG_KEY_0=maintenance.auto GIT_CONFIG_VALUE_0=false |
| 8 | export GIT_CONFIG_KEY_1=gc.auto GIT_CONFIG_VALUE_1=0 |
| 9 | trap 'rm -rf "${tmp_dir}"' EXIT |
| 10 | |
| 11 | root="${tmp_dir}/repo" |
| 12 | mkdir -p \ |
| 13 | "${root}/.github" \ |
| 14 | "${root}/bin" \ |
| 15 | "${root}/crates/config/src/route" \ |
| 16 | "${root}/crates/example" \ |
| 17 | "${root}/crates/tui/src/commands/contract/fixtures/config_policy" \ |
| 18 | "${root}/docs/i18n" \ |
| 19 | "${root}/extensions/vscode" \ |
| 20 | "${root}/npm/codewhale" \ |
| 21 | "${root}/npm/deepseek-tui" \ |
| 22 | "${root}/npm/runtime-sdk" \ |
| 23 | "${root}/scripts/release" \ |
| 24 | "${root}/vendor/codewhale-ratatui" \ |
| 25 | "${root}/web/lib" |
| 26 | |
| 27 | cp "${repo_root}/scripts/release/check-versions.sh" "${root}/scripts/release/check-versions.sh" |
| 28 | cp "${repo_root}/scripts/release/check-npm-binary-version.sh" "${root}/scripts/release/check-npm-binary-version.sh" |
| 29 | cp "${repo_root}/scripts/release/check-feature-release-notes.sh" "${root}/scripts/release/check-feature-release-notes.sh" |
| 30 | cp "${repo_root}/scripts/sync-changelog.sh" "${root}/scripts/sync-changelog.sh" |
| 31 | cp "${repo_root}/scripts/check-docs-drift.py" "${root}/scripts/check-docs-drift.py" |
| 32 | |
| 33 | cat >"${root}/bin/cargo" <<'EOF' |
| 34 | #!/usr/bin/env bash |
| 35 | set -euo pipefail |
| 36 | if [[ "${1:-}" == "metadata" ]]; then |
| 37 | printf '%s\n' '{"packages":[{"name":"codewhale-app-server","targets":[{"kind":["lib"],"name":"codewhale_app_server"}]}]}' |
| 38 | exit 0 |
| 39 | fi |
| 40 | exit 0 |
| 41 | EOF |
| 42 | chmod +x "${root}/bin/cargo" \ |
| 43 | "${root}/scripts/release/check-versions.sh" \ |
| 44 | "${root}/scripts/release/check-npm-binary-version.sh" \ |
| 45 | "${root}/scripts/release/check-feature-release-notes.sh" \ |
| 46 | "${root}/scripts/sync-changelog.sh" |
| 47 | |
| 48 | cat >"${root}/Cargo.toml" <<'EOF' |
| 49 | [workspace] |
| 50 | members = ["crates/example"] |
| 51 | |
| 52 | [workspace.package] |
| 53 | version = "0.10.3" |
| 54 | EOF |
| 55 | |
| 56 | cat >"${root}/crates/example/Cargo.toml" <<'EOF' |
| 57 | [package] |
| 58 | name = "codewhale-example" |
| 59 | version.workspace = true |
| 60 | rust-version.workspace = true |
| 61 | |
| 62 | [dependencies] |
| 63 | codewhale-core = { path = "../core", version = "0.10.3" } |
| 64 | EOF |
| 65 | |
| 66 | cat >"${root}/vendor/codewhale-ratatui/Cargo.toml" <<'EOF' |
| 67 | [package] |
| 68 | name = "codewhale-ratatui" |
| 69 | version = "0.2.0" |
| 70 | |
| 71 | [dependencies] |
| 72 | codewhale-protocol = { path = "../../crates/protocol", version = "0.10.3" } |
| 73 | EOF |
| 74 | |
| 75 | cat >"${root}/npm/codewhale/package.json" <<'EOF' |
| 76 | {"name":"codewhale","version":"0.10.3","codewhaleBinaryVersion":"0.10.3"} |
| 77 | EOF |
| 78 | cat >"${root}/npm/runtime-sdk/package.json" <<'EOF' |
| 79 | {"name":"@codewhale/runtime-sdk","version":"0.10.3"} |
| 80 | EOF |
| 81 | cat >"${root}/npm/deepseek-tui/package.json" <<'EOF' |
| 82 | {"name":"deepseek-tui","version":"0.8.49","private":true} |
| 83 | EOF |
| 84 | cat >"${root}/extensions/vscode/package.json" <<'EOF' |
| 85 | {"name":"codewhale-vscode","version":"0.10.3"} |
| 86 | EOF |
| 87 | cat >"${root}/extensions/vscode/package-lock.json" <<'EOF' |
| 88 | {"name":"codewhale-vscode","version":"0.10.3","packages":{"":{"version":"0.10.3"}}} |
| 89 | EOF |
| 90 | cat >"${root}/package-lock.json" <<'EOF' |
| 91 | {"name":"fixture","packages":{"npm/codewhale":{"version":"0.10.3"},"npm/runtime-sdk":{"version":"0.10.3"}}} |
| 92 | EOF |
| 93 | printf 'Security: hunter@shannonlabs.dev\n' >"${root}/.github/SECURITY.md" |
| 94 | printf 'export const FACTS = { "version": "0.10.3" };\n' >"${root}/web/lib/facts.generated.ts" |
| 95 | printf 'Install Codewhale.\n' >"${root}/README.md" |
| 96 | printf 'Install Codewhale.\n' >"${root}/docs/i18n/README.de.md" |
| 97 | printf 'Install guide for v0.10.3 source candidate.\n' >"${root}/docs/INSTALL.md" |
| 98 | printf '{"runtimeVersion":"0.10.3"}\n' >"${root}/crates/config/src/route/providers-export.golden.json" |
| 99 | printf '{"message":"codewhale 0.10.3\\n"}\n' >"${root}/crates/tui/src/commands/contract/fixtures/config_policy/status.json" |
| 100 | printf 'Old archive\n' >"${root}/docs/CHANGELOG_ARCHIVE.md" |
| 101 | |
| 102 | cat >"${root}/CHANGELOG.md" <<'EOF' |
| 103 | # Changelog |
| 104 | |
| 105 | ## [Unreleased] |
| 106 | |
| 107 | - **New slice (#101):** shipped after the candidate date. |
| 108 | |
| 109 | ## [0.10.3] - 2026-11-08 |
| 110 | |
| 111 | This is the Codewhale v0.10.3 source candidate. It is not a published release. |
| 112 | |
| 113 | ### Work in progress and known limits |
| 114 | |
| 115 | This source candidate is not the final 0.10.3 tag. |
| 116 | |
| 117 | ### Added |
| 118 | |
| 119 | - Initial 0.10.3 item. |
| 120 | |
| 121 | [Unreleased]: https://github.com/codewhale-hq/CodeWhale/compare/v0.10.2...HEAD |
| 122 | [0.10.3]: https://github.com/codewhale-hq/CodeWhale/compare/v0.10.2...v0.10.3 |
| 123 | EOF |
| 124 | |
| 125 | cat >"${root}/docs/CONTRIBUTORS.md" <<'EOF' |
| 126 | <details open> |
| 127 | <summary><strong>Unreleased — landed after v0.10.3</strong></summary> |
| 128 | |
| 129 | - **[alice](https://github.com/alice)** — feature (#101). |
| 130 | |
| 131 | </details> |
| 132 | |
| 133 | <details open> |
| 134 | <summary><strong>v0.10.3 — unreleased candidate</strong></summary> |
| 135 | |
| 136 | - **[bob](https://github.com/bob)** — fix (#100). |
| 137 | |
| 138 | </details> |
| 139 | EOF |
| 140 | |
| 141 | cat >"${root}/web/lib/release-credits.ts" <<'EOF' |
| 142 | export const RELEASE_CONTRIBUTORS: string[] = ["@bob"]; |
| 143 | export const UNRELEASED_CONTRIBUTORS: string[] = ["@alice"]; |
| 144 | export const RELEASE_HELPERS: string[] = []; |
| 145 | EOF |
| 146 | |
| 147 | "${root}/scripts/sync-changelog.sh" >/dev/null |
| 148 | |
| 149 | git -C "${root}" init -q -b main |
| 150 | git -C "${root}" config user.name "Release Test" |
| 151 | git -C "${root}" config user.email "release-test@example.invalid" |
| 152 | git -C "${root}" add . |
| 153 | git -C "${root}" commit -q -m "base" |
| 154 | git -C "${root}" tag v0.10.2 |
| 155 | git -C "${root}" commit -q --allow-empty -m "feat: add new slice (#101)" |
| 156 | |
| 157 | PATH="${root}/bin:${PATH}" "${root}/scripts/release/check-versions.sh" >/dev/null |
| 158 | |
| 159 | set +e |
| 160 | dated_err="$(PATH="${root}/bin:${PATH}" "${root}/scripts/release/check-versions.sh" --require-dated-release 2>&1)" |
| 161 | dated_rc=$? |
| 162 | set -e |
| 163 | [[ "${dated_rc}" -ne 0 ]] |
| 164 | grep -Fq "CHANGELOG.md [Unreleased] to be folded" <<<"${dated_err}" |
| 165 | grep -Fq "replace source-candidate and work-in-progress text" <<<"${dated_err}" |
| 166 | grep -Fq "docs/CONTRIBUTORS.md to fold the Unreleased band" <<<"${dated_err}" |
| 167 | grep -Fq "UNRELEASED_CONTRIBUTORS to be moved" <<<"${dated_err}" |
| 168 | |
| 169 | cat >"${root}/CHANGELOG.md" <<'EOF' |
| 170 | # Changelog |
| 171 | |
| 172 | ## [Unreleased] |
| 173 | |
| 174 | ## [0.10.3] - 2026-11-18 |
| 175 | |
| 176 | Codewhale v0.10.3 ships the new slice and initial item. |
| 177 | |
| 178 | ### Added |
| 179 | |
| 180 | - **New slice (#101):** shipped in 0.10.3. |
| 181 | - Initial 0.10.3 item. |
| 182 | |
| 183 | [Unreleased]: https://github.com/codewhale-hq/CodeWhale/compare/v0.10.3...HEAD |
| 184 | [0.10.3]: https://github.com/codewhale-hq/CodeWhale/compare/v0.10.2...v0.10.3 |
| 185 | EOF |
| 186 | |
| 187 | cat >"${root}/docs/CONTRIBUTORS.md" <<'EOF' |
| 188 | <details open> |
| 189 | <summary><strong>v0.10.3 — plugins, permissions and registry</strong></summary> |
| 190 | |
| 191 | - **[alice](https://github.com/alice)** — feature (#101). |
| 192 | - **[bob](https://github.com/bob)** — fix (#100). |
| 193 | |
| 194 | </details> |
| 195 | EOF |
| 196 | |
| 197 | cat >"${root}/web/lib/release-credits.ts" <<'EOF' |
| 198 | export const RELEASE_CONTRIBUTORS: string[] = ["@bob", "@alice"]; |
| 199 | export const UNRELEASED_CONTRIBUTORS: string[] = []; |
| 200 | export const RELEASE_HELPERS: string[] = []; |
| 201 | EOF |
| 202 | |
| 203 | "${root}/scripts/sync-changelog.sh" >/dev/null |
| 204 | PATH="${root}/bin:${PATH}" "${root}/scripts/release/check-versions.sh" --require-dated-release >/dev/null |
| 205 | |
| 206 | printf 'docker run ghcr.io/hmbown/codewhale:v0.10.0\n' >"${root}/docs/DOCKER.md" |
| 207 | set +e |
| 208 | drift_err="$(PATH="${root}/bin:${PATH}" "${root}/scripts/release/check-versions.sh" --require-dated-release 2>&1)" |
| 209 | drift_rc=$? |
| 210 | set -e |
| 211 | [[ "${drift_rc}" -ne 0 ]] |
| 212 | grep -Fq "stale Docker image tag" <<<"${drift_err}" |
| 213 | rm -f "${root}/docs/DOCKER.md" |
| 214 | |
| 215 | printf 'Security: hunter@shannonlabs.dev or personal@gmail.com\n' >"${root}/.github/SECURITY.md" |
| 216 | set +e |
| 217 | gmail_err="$(PATH="${root}/bin:${PATH}" "${root}/scripts/release/check-versions.sh" --require-dated-release 2>&1)" |
| 218 | gmail_rc=$? |
| 219 | set -e |
| 220 | [[ "${gmail_rc}" -ne 0 ]] |
| 221 | grep -Fq "personal @gmail.com address" <<<"${gmail_err}" |
| 222 | printf 'Security: hunter@shannonlabs.dev\n' >"${root}/.github/SECURITY.md" |
| 223 | |
| 224 | echo "check-versions tests passed" |
| 225 |