Report version via --version using sbt-buildinfo - #10
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
バイナリが自分のバージョンを名乗る手段がなく、ダウンロードした
comportをどのリリースのものか照合できませんでした。sbt-buildinfo を導入し、--versionでバージョンを出力するようにします。変更内容
com.eed3si9n % sbt-buildinfo % 0.13.1を追加し、dev.capslock.comport.BuildInfoを生成します。キーはname/version/scalaVersion/sbtVersion。build.sbtにversionの定義がなかったため、環境変数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 --version→comport 0.0.0-SNAPSHOTCOMPORT_VERSION=1.2.3 sbt run --version→comport 1.2.3scalafmtSbtCheck/scalafmtCheckAll/scalafixAll --checkすべて通過run --names web,db) が従来どおりであることリリースワークフローはタグを push するまで実行されないため、
COMPORT_VERSIONの受け渡しは実地では未検証です。🤖 Generated with Claude Code