Skip to content

Conversation

@yutannihilation
Copy link
Contributor

@yutannihilation yutannihilation commented Jun 2, 2025

概要

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 によって自動生成されたものです。中身はレビューしなくて大丈夫です。
  • gdal crate は、bundled feature を有効にするためフォークしたバージョンを使っています (参考:Expose bundled feature on gdal crate georust/gdal#646
  • Windows はビルドできなかったので含めていません。

⚠ cargo-dist について⚠

Rust でこういうことをするにはいくつか選択肢があります。

  • cargo-dist: いちばん有名
  • GoReleaser: Go 向けのツールだが Rust もサポートされている
  • cargo-packager: Tauri などが使っている

実は、cargo-dist は、開発元の会社が資金難になり開発がストップしている、という難しい状況にあります。この pull request では uv や ruff をメンテナンスしている Astral がフォークしているバージョン(astral-sh/cargo-dist)を使っています。README には

This is an unofficial fork of axodotdev/cargo-dist 0.28.0 to apply minor updates and fixes for astral's projects.

と書かれていて、あくまで 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 ファイルを生成するときも更新するときも、

dist init

です。

ドキュメント

ドキュメントはウェブサイトが落ちて読めなくなっているので、ここで読めます。

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

Comment on lines +22 to +23
# TODO: link.exe fails with 1120 error. Some incompatibility with other C++ libraries...?
# "x86_64-pc-windows-msvc"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows はこういうエラーになっていて、よくわからないのですが、エラーで検索して出てきた StackOverflow などを見る感じ、gdal 以外にも何らかの C/C++ ライブラリがビルドに使われていて、それが互換性のないバイナリになっている?みたいです。解決できなかったので Windows はコメントアウトしました。

https://github.com/yutannihilation/japan-dem/actions/runs/15397842638/job/43323063361#step:8:158

error: linking with `link.exe` failed: exit code: 1120

anyhow = "1.0.98"
clap = { version = "4.5.38", features = ["derive"] }
gdal = "0.18.0"
gdal = { version = "0.18.0", git = "https://github.com/yutannihilation/gdal-rs", branch = "feat/expose-bundled-feature" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yutannihilation ありがとうございます!
本家にPR出している最中という感じですかね…!

であれば本家に取り込まれた場合は

gdal = "0.18.1"

のように戻してあげる必要がありそうですか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あ、たしかに、バージョンは実際のに修正する必要ありますね!

# Config for 'dist'
[dist]
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.28.5"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo-dist自体初めて知りましたー!
とても助かります!ありがとうございます!

@nokonoko1203 nokonoko1203 merged commit 5891e87 into nokonoko1203:main Jun 3, 2025
@yutannihilation yutannihilation deleted the ci/cargo-dist branch June 3, 2025 00:42
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.

2 participants