Skip to content

Report version via --version using sbt-buildinfo - #10

Merged
windymelt merged 1 commit into
mainfrom
buildinfo-version
Aug 11, 2026
Merged

windymelt merged 1 commit into
mainfrom
buildinfo-version

Conversation

@windymelt

Copy link
Copy Markdown
Owner

概要

バイナリが自分のバージョンを名乗る手段がなく、ダウンロードした comport をどのリリースのものか照合できませんでした。sbt-buildinfo を導入し、--version でバージョンを出力するようにします。

$ comport --version
comport 0.1.0

変更内容

  • sbt-buildinfo の導入: sbt 2 対応版の com.eed3si9n % sbt-buildinfo % 0.13.1 を追加し、dev.capslock.comport.BuildInfo を生成します。キーは name / version / scalaVersion / sbtVersion
  • バージョンの供給元: build.sbtversion の定義がなかったため、環境変数 COMPORT_VERSION から取り、未設定なら 0.0.0-SNAPSHOT とします。release.yml の各ビルドジョブがタグから切り出した値を渡します。Alpine コンテナビルドは docker run-e COMPORT_VERSION を追加して透過させています。この経路では空文字が渡りうるので、build.sbt 側で空文字を未設定と同じ扱いにしています。
  • --version の実装: mainargs のパース前に main で処理しています。comport は git rev-parse に失敗すると exit 1 するため、この位置にしないと git リポジトリ外で --version が使えません。代わりに --help の一覧には出ないので、README の Options に追記しました。

確認したこと

  • sbt run --versioncomport 0.0.0-SNAPSHOT
  • COMPORT_VERSION=1.2.3 sbt run --versioncomport 1.2.3
  • scalafmtSbtCheck / scalafmtCheckAll / scalafixAll --check すべて通過
  • 通常動作 (run --names web,db) が従来どおりであること

リリースワークフローはタグを push するまで実行されないため、COMPORT_VERSION の受け渡しは実地では未検証です。

🤖 Generated with Claude Code

The binaries had no way to identify themselves, so a downloaded comport
could not be matched against a release.

sbt-buildinfo generates dev.capslock.comport.BuildInfo from the build's
version, which release.yml now sets from the git tag (COMPORT_VERSION,
passed through to the Alpine container build). Local builds report
0.0.0-SNAPSHOT.

--version is handled in main before mainargs so it works outside a git
repository, where the normal path exits with an error.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@windymelt
windymelt merged commit 2f9f912 into main Aug 11, 2026
5 checks passed
@windymelt
windymelt deleted the buildinfo-version branch August 11, 2026 11:40
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.

1 participant