feat: add release workflow, --version flag, and $RSHELL_VERSION#183
feat: add release workflow, --version flag, and $RSHELL_VERSION#183
Conversation
Add internal/version package with a source constant as single source of truth for the release version, overridable via ldflags for dev builds. Update the Makefile to inject version + commit at build time via git describe. Add a GitHub Actions release workflow (workflow_dispatch) that auto-computes the next version from the latest git tag. Pick patch/minor/major from a dropdown and click Run — no version to type. The workflow bumps the constant, commits, tags, and creates the release. Access is gated by a "release" environment requiring reviewer approval. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the major/minor/patch dropdown from the release workflow — it now always bumps the patch version, reducing room for human error. Add `--version` flag to the CLI via cobra's built-in Version field. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the hardcoded version constant with debug.ReadBuildInfo() to read the version from Go's embedded dependency info. When rshell is imported as a library (e.g. by the Datadog Agent), this automatically picks up the version from go.mod — no source constant to maintain. This also simplifies the release workflow: it no longer needs to sed the version file and commit before tagging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rshell is only used as a library via the agent, so the ldflags version override for standalone dev builds adds complexity for no benefit. Remove VERSION/COMMIT/LDFLAGS from the Makefile and the Commit variable from the version package. ldflags can still be used if needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use testdata/depcheck/ — a small Go program that imports rshell as a dependency and prints the version from debug.ReadBuildInfo(). The test copies it to a temp dir with a replace directive pointing to local rshell, builds and runs it, and verifies it finds a version in the deps list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use a realistic version (v1.2.3) instead of v0.0.0, and assert the exact value instead of just checking it's non-empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add missing copyright header to testdata/depcheck/main.go (compliance check failure). Move ldflags note to buildVersion doc comment to reduce redundancy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
would be nice to have a scenario test that tests |
Since in tests rshell is the main module, running |
- Set $RSHELL_VERSION in the interpreter environment (like $BASH_VERSION) - Add TestVersion for rshell --version CLI output - Simplify depcheck e2e test: use published v0.0.10 with a plain go.mod instead of runtime replace directive patching - Add scenario test for $RSHELL_VERSION Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Added Also added a scenario test |
CombinedOutput() captures stderr too, so "go: downloading ..." progress lines from `go run` polluted stdout on CI (where the module isn't cached). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
internal/versionpackage that reads the version from Go's embedded build info viaruntime/debug— no hardcoded constant to maintain--versionflag to the CLI (rshell --version)$RSHELL_VERSIONshell variable (like$BASH_VERSIONin bash)This PR adds a GitHub Actions workflow that fully automates patch releases. After merging, releasing a new version of rshell is:
That's it — no version number to type, no bump type to choose. The workflow automatically:
v0.0.10)v0.0.11)No commits to
main— the workflow only creates a tag and release.Access control
The workflow uses a GitHub environment (
release) that requires approval from designated reviewers. Anyone with write access can trigger it, but it won't execute until someone on the reviewer list approves it.Setup required after merging: Go to Settings > Environments > New environment > name it
release> check "Required reviewers" > add the people who can approve releases.Version in builds
runtime/debugreads version fromgo.moddepsgo install ...@v0.0.11runtime/debugreads main module versionmake build/go build(standalone)dev(standalone usage is not a supported use case)$RSHELL_VERSION
Scripts can access the version via
$RSHELL_VERSION, similar to$BASH_VERSION:Test plan
rshell --versionworks$RSHELL_VERSIONis set in the interpreter environmentruntime/debugcorrectly reads version from dependency info (e2e test with published v0.0.10)go test ./...)🤖 Generated with Claude Code