还原历史发布版本的构建环境
从历史标签提取工具链与依赖要求,在隔离环境重建旧版本,并记录故障和产物差异。
完整提示词
<context>
Checking out an old tag gives the old source but not the old build. Builds of a two-year-old release usually fail for reasons outside the code: the language runtime and build tool have moved on, dependency ranges now resolve to newer incompatible versions when no lockfile was committed, registries have removed or yanked packages, base images have changed under the same tag, submodules point at commits that were force-pushed away, and CI configuration describes an environment that no longer exists. The fastest reliable approach reads the environment from the tag itself (version files such as `.nvmrc`, `.tool-versions`, `rust-toolchain.toml`, `go.mod`, the CI file and Dockerfile at that tag), builds in an isolated worktree or container with those exact versions, installs dependencies strictly from the lockfile, and compares the output with the shipped artifact where one exists. Doing this in a separate worktree keeps the current checkout untouched.
</context>
<task>
<release>
{{release}}
</release>
1. Create an isolated checkout: `git worktree add ../build-<tag> <tag>` (or a fresh clone), then `git submodule update --init --recursive` inside it. Report any submodule commit that no longer exists on its remote.
2. Read the environment from the tag: runtime and tool version files, the manifest's engine or toolchain fields, the CI config and Dockerfile at that tag, and the README build instructions. List the exact versions it expects.
3. Choose the isolation: a container image of the matching runtime version pinned by digest if possible, or a version manager on the host. Explain the choice.
4. Install dependencies strictly from the lockfile (`npm ci`, `pip install` with hashes or a lock, `cargo build --locked`, `go mod download` with the existing sums). If there is no lockfile, say that dependency versions cannot be recovered exactly, and constrain them to the latest versions published before the tag date where the ecosystem allows it.
5. Build with the release's own command. For each failure, find whether the cause is the environment, a vanished dependency or the code, and fix the environment first; never change the release's code to make it build unless the user agrees.
6. If a shipped artifact or checksum exists, compare it with the rebuild and explain differences (timestamps, paths, compiler version).
7. Suggest what to commit so the next rebuild is easier, such as a pinned toolchain file or a build container definition, on the release branch only if the user wants it.
</task>
<constraints>
- Do not modify the current working tree or rewrite the tag; work in the worktree or clone.
- Record every version and substitution used, so the rebuild can be repeated.
- If a dependency is gone from every registry, stop and report it rather than substituting a different package silently.
{{> guardrails/verify-before-done}}
</constraints>
<output_format>
## Release
Tag, commit, date and submodule state.
## Environment
Table: tool, version expected, version used, source of the version.
## Build
Commands run, failures and how each was fixed.
## Differences
Comparison with the shipped artifact, if available.
## Make it easier next time
One or two concrete suggestions.
</output_format>可替换内容
- {{release}}
- {{> guardrails/verify-before-done}}
分类与标签
编程开发、历史版本构建、隔离工作区、工具链还原、依赖锁定、产物比对