Enable cargo-dist to release pre-compiled binary #33
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.
概要
cargo-dist によるリリースを有効にします。
具体的には、
v0.1.3のようなタグを打って GitHub に push すると、以下のように、GitHub Actions によってコンパイル済みのバイナリが生成されます。インストールスクリプトもあって、curlでインストールできます。https://github.com/yutannihilation/japan-dem/releases/tag/v0.1.4-rc.3
変更点
.github/workflows/release.ymlは、名前がかぶってしまうので.github/workflows/release-crates.io.ymlにリネームしています.github/workflows/release.ymlは、長いですが、dist initによって自動生成されたものです。中身はレビューしなくて大丈夫です。bundledfeature を有効にするためフォークしたバージョンを使っています (参考:Exposebundledfeature on gdal crate georust/gdal#646)⚠ cargo-dist について⚠
Rust でこういうことをするにはいくつか選択肢があります。
実は、cargo-dist は、開発元の会社が資金難になり開発がストップしている、という難しい状況にあります。この pull request では uv や ruff をメンテナンスしている Astral がフォークしているバージョン(astral-sh/cargo-dist)を使っています。README には
と書かれていて、あくまで Astral が使うために Astral がメンテしているものです。
こういう状況で cargo-dist を使うかは悩むのですが、自分が使ったことがあるのが cargo-dist だけなのでこれを選びました。あと、GoReleaser は
cargo-zigbuildでクロスコンパイルしているので、C/C++ のライブラリが絡むとトラブルがあると聞いたので避けたのもあるんですが、bundledなら大丈夫なのかもしれません。セットアップ
ローカルで cargo-dist を使う必要があるのは、cargo-dist 自体をアップデートして GitHub Actions の YAML ファイルを生成・更新するときだけなので、インストールする必要はないですが、以下の GitHub releases から最新のリリースのインストール手順に従えばインストールできます。
https://github.com/astral-sh/cargo-dist/releases
使い方
GitHub Actions の YAML ファイルを生成するときも更新するときも、
です。
ドキュメント
ドキュメントはウェブサイトが落ちて読めなくなっているので、ここで読めます。
https://github.com/astral-sh/cargo-dist/tree/main/book/src
設定ファイルの書き方とかは参照することがあるかもです。
https://github.com/astral-sh/cargo-dist/blob/main/book/src/reference/config.md