Skip to content

feat: add release workflow, --version flag, and $RSHELL_VERSION#183

Merged
julesmcrt merged 9 commits intomainfrom
jules.macret/Q/release-workflow
Apr 16, 2026
Merged

feat: add release workflow, --version flag, and $RSHELL_VERSION#183
julesmcrt merged 9 commits intomainfrom
jules.macret/Q/release-workflow

Conversation

@julesmcrt
Copy link
Copy Markdown
Collaborator

@julesmcrt julesmcrt commented Apr 14, 2026

Summary

  • Adds internal/version package that reads the version from Go's embedded build info via runtime/debug — no hardcoded constant to maintain
  • Adds --version flag to the CLI (rshell --version)
  • Exposes $RSHELL_VERSION shell variable (like $BASH_VERSION in bash)
  • Adds an automated patch release workflow

⚠️ New release process

This PR adds a GitHub Actions workflow that fully automates patch releases. After merging, releasing a new version of rshell is:

  1. Go to Actions > Release > Run workflow
  2. Click Run workflow

That's it — no version number to type, no bump type to choose. The workflow automatically:

  • Finds the latest tag (e.g. v0.0.10)
  • Bumps the patch version (e.g. v0.0.11)
  • Tags the commit
  • Creates the GitHub release with auto-generated changelog

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

Build method Version source
Datadog Agent (library import) runtime/debug reads version from go.mod deps
go install ...@v0.0.11 runtime/debug reads main module version
make 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:

echo $RSHELL_VERSION

Test plan

  • rshell --version works
  • $RSHELL_VERSION is set in the interpreter environment
  • runtime/debug correctly reads version from dependency info (e2e test with published v0.0.10)
  • Full test suite passes (go test ./...)

🤖 Generated with Claude Code

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>
Comment thread internal/version/version.go
Comment thread Makefile Outdated
Comment thread .github/workflows/release.yml
julesmcrt and others added 3 commits April 15, 2026 17:04
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>
@julesmcrt julesmcrt changed the title feat: add version package and automated release workflow feat: add automated release workflow and --version flag Apr 15, 2026
Comment thread cmd/rshell/main.go
Comment thread internal/version/version_test.go
julesmcrt and others added 3 commits April 15, 2026 17:40
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>
@matt-dz
Copy link
Copy Markdown
Collaborator

matt-dz commented Apr 15, 2026

would be nice to have a scenario test that tests rshell --version. the output would be something like rshell version v0.0.11-0.20260415155454-850201aab166 and you can have an stdout_contains field with rshell version.

Comment thread internal/version/testdata/depcheck/go.mod.test Outdated
@julesmcrt
Copy link
Copy Markdown
Collaborator Author

#183 (comment)

would be nice to have a scenario test that tests rshell --version. the output would be something like rshell version v0.0.11-0.20260415155454-850201aab166 and you can have an stdout_contains field with rshell version.

Since in tests rshell is the main module, running rshell --version will output dev
I still added a test, with a comment explaining that

- 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>
@julesmcrt julesmcrt changed the title feat: add automated release workflow and --version flag feat: add release workflow, --version flag, and $RSHELL_VERSION Apr 16, 2026
@julesmcrt
Copy link
Copy Markdown
Collaborator Author

Added TestVersion in cmd/rshell/main_test.go — asserts rshell --version outputs rshell version dev\n (standalone builds return "dev" since rshell is the main module; see comment on the test for details).

Also added a scenario test tests/scenarios/shell/environment/rshell_version_is_set.yaml that tests $RSHELL_VERSION — a new shell variable exposed like $BASH_VERSION in bash (per Alex's suggestion).

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>
@julesmcrt julesmcrt added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit cc19048 Apr 16, 2026
34 checks passed
@julesmcrt julesmcrt deleted the jules.macret/Q/release-workflow branch April 16, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants