Files
mdrs-client-rust/build.rs
T
orrisrootandCopilot 2b31122640 feat: selfupdate コマンドを実装
- Gitea API を既存 reqwest で呼び出し最新リリース取得
- BUILD_TARGET でアセット名(tar.gz / zip)を照合して自動選択
- バージョン比較 → 確認プロンプト(-y/--yes でスキップ)
- ダウンロード → アーカイブ展開 → self-replace でアトミック置換
- GITEA_TOKEN 環境変数でプライベートリポジトリ対応
- build.rs に BUILD_TARGET 環境変数の出力を追加
- .gitea/workflows/release.yml を追加(v* タグ push でマルチプラットフォームビルド)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-17 20:13:52 +09:00

23 lines
752 B
Rust

fn main() {
let output = std::process::Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to run rustc --version");
let full = String::from_utf8(output.stdout).unwrap();
// "rustc 1.79.0 (129f3b996 2024-06-10)" → "1.79.0"
let version = full
.trim()
.trim_start_matches("rustc ")
.split_whitespace()
.next()
.unwrap_or("unknown")
.to_string();
println!("cargo:rustc-env=RUSTC_VERSION={}", version);
// Expose the build target triple so selfupdate can match release assets.
println!(
"cargo:rustc-env=BUILD_TARGET={}",
std::env::var("TARGET").unwrap_or_default()
);
println!("cargo:rerun-if-changed=build.rs");
}