Compare commits

...

6 Commits

Author SHA1 Message Date
Taiki Endo
c25f50bacd Release 2.13.6 2023-08-04 22:58:42 +09:00
Taiki Endo
94d8a59049 codegen: Clean up rust crate handling 2023-08-04 21:58:05 +09:00
Taiki Endo
8e67e37b45 Update mdbook@latest to 0.4.33 (#181) 2023-08-04 06:07:57 +00:00
Taiki Endo
26fe17aa20 codegen: Prevent yanked version from being selected as candidate for latest or omitted version 2023-08-03 22:00:35 +09:00
Taiki Endo
0825c0beeb Release 2.13.5 2023-08-03 11:50:09 +09:00
Taiki Endo
0e33aaec49 Update cargo-nextest@latest to 0.9.57 (#179) 2023-08-03 10:49:36 +10:00
57 changed files with 181 additions and 67 deletions

View File

@@ -10,6 +10,14 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased]
## [2.13.6] - 2023-08-04
- Update `mdbook@latest` to 0.4.33.
## [2.13.5] - 2023-08-03
- Update `cargo-nextest@latest` to 0.9.57.
## [2.13.4] - 2023-08-02
- Update `cargo-nextest@latest` to 0.9.56.
@@ -1023,7 +1031,9 @@ Note: This release is considered a breaking change because installing on version
Initial release
[Unreleased]: https://github.com/taiki-e/install-action/compare/v2.13.4...HEAD
[Unreleased]: https://github.com/taiki-e/install-action/compare/v2.13.6...HEAD
[2.13.6]: https://github.com/taiki-e/install-action/compare/v2.13.5...v2.13.6
[2.13.5]: https://github.com/taiki-e/install-action/compare/v2.13.4...v2.13.5
[2.13.4]: https://github.com/taiki-e/install-action/compare/v2.13.3...v2.13.4
[2.13.3]: https://github.com/taiki-e/install-action/compare/v2.13.2...v2.13.3
[2.13.2]: https://github.com/taiki-e/install-action/compare/v2.13.1...v2.13.2

15
main.sh
View File

@@ -152,6 +152,7 @@ read_manifest() {
local tool="$1"
local version="$2"
local manifest
rust_crate=$(jq -r ".rust_crate" "${manifest_dir}/${tool}.json")
manifest=$(jq -r ".\"${version}\"" "${manifest_dir}/${tool}.json")
if [[ "${manifest}" == "null" ]]; then
download_info="null"
@@ -220,15 +221,14 @@ read_download_info() {
template=$(jq -r ".template.${host_platform}" "${manifest_dir}/${tool}.json")
url=$(jq <<<"${template}" -r '.url')
url="${url//\$\{version\}/${exact_version}}"
bin_dir=$(jq <<<"${template}" -r '.bin_dir')
bin_dir="${bin_dir//\$\{version\}/${exact_version}}"
bin_in_archive=$(jq <<<"${template}" -r '.bin')
bin_in_archive="${bin_in_archive//\$\{version\}/${exact_version}}"
else
bin_dir=$(jq <<<"${download_info}" -r '.bin_dir')
bin_in_archive=$(jq <<<"${download_info}" -r '.bin')
fi
if [[ "${bin_dir}" == "null" ]]; then
if [[ "${rust_crate}" == "null" ]]; then
bin_dir="/usr/local/bin"
else
bin_dir="${cargo_bin}"
fi
if [[ "${bin_in_archive}" == "null" ]]; then
@@ -563,10 +563,13 @@ for tool in "${tools[@]}"; do
# Use cargo-binstall fallback if tool is available but the specified version not available.
read_manifest "${tool}" "${version}"
if [[ "${download_info}" == "null" ]]; then
if [[ "${rust_crate}" == "null" ]]; then
bail "${tool}@${version} for '${host_os}' is not supported"
fi
warn "${tool}@${version} for '${host_os}' is not supported; fallback to cargo-binstall"
case "${version}" in
latest) unsupported_tools+=("${tool}") ;;
*) unsupported_tools+=("${tool}@${version}") ;;
latest) unsupported_tools+=("${rust_crate}") ;;
*) unsupported_tools+=("${rust_crate}@${version}") ;;
esac
continue
fi

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-binstall",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/cargo-bins/cargo-binstall/releases/download/v${version}/cargo-binstall-x86_64-unknown-linux-musl.tgz"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-careful",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/RalfJung/cargo-careful/releases/download/v${version}/cargo-careful.x86_64-unknown-linux-musl"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-deny",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/EmbarkStudios/cargo-deny/releases/download/${version}/cargo-deny-${version}-x86_64-unknown-linux-musl.tar.gz",

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-dinghy",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/sonos/dinghy/releases/download/${version}/cargo-dinghy-linux-${version}.tgz",

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-hack",
"template": null,
"latest": {
"version": "0.5.28"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-llvm-cov",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/taiki-e/cargo-llvm-cov/releases/download/v${version}/cargo-llvm-cov-x86_64-unknown-linux-musl.tar.gz"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-make",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/sagiegurari/cargo-make/releases/download/${version}/cargo-make-v${version}-x86_64-unknown-linux-musl.zip",

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-minimal-versions",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/taiki-e/cargo-minimal-versions/releases/download/v${version}/cargo-minimal-versions-x86_64-unknown-linux-musl.tar.gz"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-nextest",
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-${version}/cargo-nextest-${version}-x86_64-unknown-linux-gnu.tar.gz"
@@ -17,10 +18,27 @@
}
},
"latest": {
"version": "0.9.56"
"version": "0.9.57"
},
"0.9": {
"version": "0.9.56"
"version": "0.9.57"
},
"0.9.57": {
"x86_64_linux_gnu": {
"checksum": "5fc2416dd001ec89d904a345465da0b91452896b74621a82fec33e33d4856320"
},
"x86_64_linux_musl": {
"checksum": "c9275cb47f75936ad9a6ff24557f210c7a248d284f9b9d6953e128e907b1a926"
},
"x86_64_macos": {
"checksum": "8a66df687d857f173ca6ac7773c699883beca09ce558852bc620d023336ee3b4"
},
"x86_64_windows": {
"checksum": "75e2b29d49b1b86d15f61051620aeffb159322f9c262cec2646a96ec79bfac85"
},
"aarch64_linux_gnu": {
"checksum": "e567e43446969205fd26da6f09c03f965fce20df3a0c476c4f2f77ed30ff2538"
}
},
"0.9.56": {
"x86_64_linux_gnu": {

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-no-dev-deps",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/taiki-e/cargo-no-dev-deps/releases/download/v${version}/cargo-no-dev-deps-x86_64-unknown-linux-musl.tar.gz"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-tarpaulin",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/xd009642/tarpaulin/releases/download/${version}/cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-udeps",
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/est31/cargo-udeps/releases/download/v${version}/cargo-udeps-v${version}-x86_64-unknown-linux-gnu.tar.gz",

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cargo-valgrind",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/jfrimmel/cargo-valgrind/releases/download/v${version}/cargo-valgrind-${version}-x86_64-unknown-linux-musl.tar.gz"

1
manifests/cross.json generated
View File

@@ -1,4 +1,5 @@
{
"rust_crate": "cross",
"template": null,
"latest": {
"version": "0.2.5"

1
manifests/dprint.json generated
View File

@@ -1,4 +1,5 @@
{
"rust_crate": "dprint",
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/dprint/dprint/releases/download/${version}/dprint-x86_64-unknown-linux-gnu.zip"

1
manifests/grcov.json generated
View File

@@ -1,4 +1,5 @@
{
"rust_crate": "grcov",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/mozilla/grcov/releases/download/v${version}/grcov-x86_64-unknown-linux-musl.tar.bz2"

1
manifests/just.json generated
View File

@@ -1,4 +1,5 @@
{
"rust_crate": "just",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/casey/just/releases/download/${version}/just-${version}-x86_64-unknown-linux-musl.tar.gz"

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "mdbook-linkcheck",
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/download/v${version}/mdbook-linkcheck.x86_64-unknown-linux-gnu.zip"

19
manifests/mdbook.json generated
View File

@@ -1,4 +1,5 @@
{
"rust_crate": "mdbook",
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/rust-lang/mdBook/releases/download/v${version}/mdbook-v${version}-x86_64-unknown-linux-gnu.tar.gz"
@@ -17,10 +18,24 @@
}
},
"latest": {
"version": "0.4.32"
"version": "0.4.33"
},
"0.4": {
"version": "0.4.32"
"version": "0.4.33"
},
"0.4.33": {
"x86_64_linux_musl": {
"checksum": "f56043b14b2d554b98aa6cd5e15bcbe81c095cea67a937c6c724300da4fc4005"
},
"x86_64_macos": {
"checksum": "172e83fea640b41afecf46d5bec3b09d0d54c5e6234b9e3777715b6c6a4a58a3"
},
"x86_64_windows": {
"checksum": "573acc650654cca12c77d73f0f7c8d22fdce92d7348c0bd4676579c60ee3c0b9"
},
"aarch64_linux_musl": {
"checksum": "dbafc64ee0bd616ee10ab367686fc7a000d817ddb7c6634e8b878e6c322bb38f"
}
},
"0.4.32": {
"x86_64_linux_musl": {

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "parse-changelog",
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/taiki-e/parse-changelog/releases/download/v${version}/parse-changelog-x86_64-unknown-linux-gnu.tar.gz"

1
manifests/protoc.json generated
View File

@@ -1,4 +1,5 @@
{
"rust_crate": null,
"template": null,
"latest": {
"version": "3.23.4"

View File

@@ -1,23 +1,20 @@
{
"rust_crate": null,
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/koalaman/shellcheck/releases/download/v${version}/shellcheck-v${version}.linux.x86_64.tar.xz",
"bin_dir": "/usr/local/bin",
"bin": "shellcheck-v${version}/shellcheck"
},
"x86_64_macos": {
"url": "https://github.com/koalaman/shellcheck/releases/download/v${version}/shellcheck-v${version}.darwin.x86_64.tar.xz",
"bin_dir": "/usr/local/bin",
"bin": "shellcheck-v${version}/shellcheck"
},
"x86_64_windows": {
"url": "https://github.com/koalaman/shellcheck/releases/download/v${version}/shellcheck-v${version}.zip",
"bin_dir": "/usr/local/bin",
"bin": "shellcheck.exe"
},
"aarch64_linux_gnu": {
"url": "https://github.com/koalaman/shellcheck/releases/download/v${version}/shellcheck-v${version}.linux.aarch64.tar.xz",
"bin_dir": "/usr/local/bin",
"bin": "shellcheck-v${version}/shellcheck"
}
},

16
manifests/shfmt.json generated
View File

@@ -1,24 +1,20 @@
{
"rust_crate": null,
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_linux_amd64",
"bin_dir": "/usr/local/bin"
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_linux_amd64"
},
"x86_64_macos": {
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_darwin_amd64",
"bin_dir": "/usr/local/bin"
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_darwin_amd64"
},
"x86_64_windows": {
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_windows_amd64.exe",
"bin_dir": "/usr/local/bin"
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_windows_amd64.exe"
},
"aarch64_linux_gnu": {
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_linux_arm64",
"bin_dir": "/usr/local/bin"
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_linux_arm64"
},
"aarch64_macos": {
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_darwin_arm64",
"bin_dir": "/usr/local/bin"
"url": "https://github.com/mvdan/sh/releases/download/v${version}/shfmt_v${version}_darwin_arm64"
}
},
"latest": {

6
manifests/syft.json generated
View File

@@ -1,28 +1,24 @@
{
"rust_crate": null,
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/anchore/syft/releases/download/v${version}/syft_${version}_linux_amd64.tar.gz",
"bin_dir": "/usr/local/bin",
"bin": "syft"
},
"x86_64_macos": {
"url": "https://github.com/anchore/syft/releases/download/v${version}/syft_${version}_darwin_amd64.tar.gz",
"bin_dir": "/usr/local/bin",
"bin": "syft"
},
"x86_64_windows": {
"url": "https://github.com/anchore/syft/releases/download/v${version}/syft_${version}_windows_amd64.zip",
"bin_dir": "/usr/local/bin",
"bin": "syft.exe"
},
"aarch64_linux_musl": {
"url": "https://github.com/anchore/syft/releases/download/v${version}/syft_${version}_linux_arm64.tar.gz",
"bin_dir": "/usr/local/bin",
"bin": "syft"
},
"aarch64_macos": {
"url": "https://github.com/anchore/syft/releases/download/v${version}/syft_${version}_darwin_arm64.tar.gz",
"bin_dir": "/usr/local/bin",
"bin": "syft"
}
},

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "wasm-pack",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/rustwasm/wasm-pack/releases/download/v${version}/wasm-pack-v${version}-x86_64-unknown-linux-musl.tar.gz",

View File

@@ -1,4 +1,5 @@
{
"rust_crate": "wasmtime-cli",
"template": null,
"latest": {
"version": "11.0.1"

1
manifests/zola.json generated
View File

@@ -1,4 +1,5 @@
{
"rust_crate": "zola",
"template": {
"x86_64_linux_gnu": {
"url": "https://github.com/getzola/zola/releases/download/v${version}/zola-v${version}-x86_64-unknown-linux-gnu.tar.gz"

View File

@@ -7,7 +7,7 @@ publish = false
[dependencies]
anyhow = "1"
fs-err = "2"
semver = "1"
semver = { version = "1", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/cargo-bins/cargo-binstall",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tgz",
"version_range": "latest",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/RalfJung/cargo-careful",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}.${rust_target}",
"platform": {
"x86_64_linux_musl": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/EmbarkStudios/cargo-deny",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"bin": "${package}-${version}-${rust_target}/${package}${exe}",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/sonos/dinghy",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${os_name}-${version}.tgz",
"bin": "${package}-${version}/${package}${exe}",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-hack",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": [
"${package}-${rust_target}.tar.gz",
"${package}-v${version}-${rust_target}.tar.gz"

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-llvm-cov",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/sagiegurari/cargo-make",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-v${version}-${rust_target}.zip",
"bin": "${package}-v${version}-${rust_target}/${package}${exe}",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-minimal-versions",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/nextest-rs/nextest",
"tag_prefix": "cargo-nextest-",
"rust_crate": "${package}",
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_gnu": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-no-dev-deps",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/xd009642/tarpaulin",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"version_range": "> 0.22.0",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/est31/cargo-udeps",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-v${version}-${rust_target}.tar.gz",
"bin": "./${package}-v${version}-${rust_target}/${package}${exe}",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/jfrimmel/cargo-valgrind",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/cross-rs/cross",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": [
"${package}-${rust_target}.tar.gz",
"${package}-v${version}-${rust_target}.tar.gz"

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/dprint/dprint",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.zip",
"platform": {
"x86_64_linux_gnu": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/mozilla/grcov",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.bz2",
"version_range": ">= 0.8.7",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/casey/just",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/Michael-F-Bryan/mdbook-linkcheck",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}.${rust_target}.zip",
"platform": {
"x86_64_linux_gnu": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/rust-lang/mdBook",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-v${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/parse-changelog",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_gnu": {},

View File

@@ -1,7 +1,6 @@
{
"repository": "https://github.com/koalaman/shellcheck",
"tag_prefix": "v",
"bin_dir": "/usr/local/bin",
"bin": "${package}-v${version}/${package}${exe}",
"platform": {
"x86_64_linux_gnu": {

View File

@@ -1,7 +1,6 @@
{
"repository": "https://github.com/mvdan/sh",
"tag_prefix": "v",
"bin_dir": "/usr/local/bin",
"platform": {
"x86_64_linux_gnu": {
"asset_name": "${package}_v${version}_linux_amd64"

View File

@@ -1,7 +1,6 @@
{
"repository": "https://github.com/anchore/syft",
"tag_prefix": "v",
"bin_dir": "/usr/local/bin",
"bin": "${package}${exe}",
"version_range": ">= 0.83.0",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/rustwasm/wasm-pack",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-v${version}-${rust_target}.tar.gz",
"bin": "${package}-v${version}-${rust_target}/${package}${exe}",
"platform": {

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/bytecodealliance/wasmtime",
"tag_prefix": "v",
"rust_crate": "wasmtime-cli",
"platform": {
"x86_64_linux_gnu": {
"asset_name": "${package}-v${version}-x86_64-linux.tar.xz",

View File

@@ -1,6 +1,7 @@
{
"repository": "https://github.com/getzola/zola",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-v${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_gnu": {},

View File

@@ -31,7 +31,7 @@ fn main() -> Result<()> {
fs::create_dir_all(manifest_path.parent().unwrap())?;
fs::create_dir_all(download_cache_dir)?;
let base_info: BaseManifest = serde_json::from_slice(&fs::read(
let mut base_info: BaseManifest = serde_json::from_slice(&fs::read(
workspace_root
.join("tools/codegen/base")
.join(format!("{package}.json")),
@@ -74,6 +74,20 @@ fn main() -> Result<()> {
})
.collect();
let mut crates_io_info = None;
base_info.rust_crate = base_info
.rust_crate
.as_ref()
.map(|s| replace_vars(s, package, None, None))
.transpose()?;
if let Some(crate_name) = &base_info.rust_crate {
eprintln!("downloading crate info from https://crates.io/api/v1/crates/{crate_name}");
crates_io_info = Some(
download(&format!("https://crates.io/api/v1/crates/{crate_name}"))?
.into_json::<crates_io::Crate>()?,
);
}
let mut manifests: Manifests = Manifests::default();
let mut semver_versions = BTreeSet::new();
let mut has_build_metadata = false;
@@ -97,10 +111,6 @@ fn main() -> Result<()> {
for (platform, d) in &mut manifest.download_info {
let template = &template.download_info[platform];
d.url = Some(template.url.replace("${version}", version));
d.bin_dir = template
.bin_dir
.as_ref()
.map(|s| s.replace("${version}", version));
d.bin = template
.bin
.as_ref()
@@ -177,7 +187,7 @@ fn main() -> Result<()> {
.with_context(|| format!("asset_name is needed for {package} on {platform:?}"))?
.as_slice()
.iter()
.map(|asset_name| replace_vars(asset_name, package, version, platform))
.map(|asset_name| replace_vars(asset_name, package, Some(version), Some(platform)))
.collect::<Result<Vec<_>>>()?;
let (url, asset_name) = match asset_names.iter().find_map(|asset_name| {
release
@@ -218,16 +228,11 @@ fn main() -> Result<()> {
ManifestDownloadInfo {
url: Some(url),
checksum: hash,
bin_dir: base_download_info
.bin_dir
.as_ref()
.or(base_info.bin_dir.as_ref())
.cloned(),
bin: base_download_info
.bin
.as_ref()
.or(base_info.bin.as_ref())
.map(|s| replace_vars(s, package, version, platform))
.map(|s| replace_vars(s, package, Some(version), Some(platform)))
.transpose()?,
},
);
@@ -250,6 +255,14 @@ fn main() -> Result<()> {
download_info.remove(&HostPlatform::aarch64_linux_gnu);
}
}
if download_info.contains_key(&HostPlatform::x86_64_macos)
&& download_info.contains_key(&HostPlatform::aarch64_macos)
&& download_info[&HostPlatform::x86_64_macos].url
== download_info[&HostPlatform::aarch64_macos].url
{
// macOS universal binary or x86_64 binary that works on both x86_64 and aarch64 (rosetta).
download_info.remove(&HostPlatform::aarch64_macos);
}
has_build_metadata |= !semver_version.build.is_empty();
if semver_version.pre.is_empty() {
semver_versions.insert(semver_version.clone());
@@ -266,6 +279,13 @@ fn main() -> Result<()> {
} else if !semver_versions.is_empty() {
let mut prev_version = semver_versions.iter().next().unwrap();
for version in &semver_versions {
if let Some(crates_io_info) = &crates_io_info {
if let Some(v) = crates_io_info.versions.iter().find(|v| v.num == *version) {
if v.yanked {
continue;
}
}
}
if !(version.major == 0 && version.minor == 0) {
manifests.map.insert(
Reverse(Version::omitted(version.major, Some(version.minor))),
@@ -345,10 +365,9 @@ fn main() -> Result<()> {
let t = template.as_mut().unwrap();
for (platform, d) in &mut manifest.download_info {
let template_url = d.url.take().unwrap().replace(version, "${version}");
let template_bin_dir = d.bin_dir.take().map(|s| s.replace(version, "${version}"));
let template_bin = d.bin.take().map(|s| s.replace(version, "${version}"));
if let Some(d) = t.download_info.get(platform) {
if template_url != d.url || template_bin_dir != d.bin_dir || template_bin != d.bin {
if template_url != d.url || template_bin != d.bin {
template = None;
break 'outer;
}
@@ -357,7 +376,6 @@ fn main() -> Result<()> {
*platform,
ManifestTemplateDownloadInfo {
url: template_url,
bin_dir: template_bin_dir,
bin: template_bin,
},
);
@@ -370,6 +388,8 @@ fn main() -> Result<()> {
manifests.template = template;
}
manifests.rust_crate = base_info.rust_crate;
let mut buf = serde_json::to_vec_pretty(&manifests)?;
buf.push(b'\n');
fs::write(manifest_path, buf)?;
@@ -384,14 +404,22 @@ fn workspace_root() -> PathBuf {
dir
}
fn replace_vars(s: &str, package: &str, version: &str, platform: HostPlatform) -> Result<String> {
let s = s
.replace("${package}", package)
.replace("${tool}", package)
.replace("${rust_target}", platform.rust_target())
.replace("${os_name}", platform.os_name())
.replace("${version}", version)
.replace("${exe}", platform.exe_suffix());
fn replace_vars(
s: &str,
package: &str,
version: Option<&str>,
platform: Option<HostPlatform>,
) -> Result<String> {
let mut s = s.replace("${package}", package).replace("${tool}", package);
if let Some(platform) = platform {
s = s
.replace("${rust_target}", platform.rust_target())
.replace("${os_name}", platform.os_name())
.replace("${exe}", platform.exe_suffix());
}
if let Some(version) = version {
s = s.replace("${version}", version);
}
if s.contains('$') {
bail!("variable not fully replaced: '{s}'");
}
@@ -563,6 +591,7 @@ impl<'de> Deserialize<'de> for Version {
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
struct Manifests {
rust_crate: Option<String>,
template: Option<ManifestTemplate>,
#[serde(flatten)]
map: BTreeMap<Reverse<Version>, ManifestRef>,
@@ -586,9 +615,6 @@ struct ManifestDownloadInfo {
#[serde(skip_serializing_if = "Option::is_none")]
url: Option<String>,
checksum: String,
/// Default to ${cargo_bin}
#[serde(skip_serializing_if = "Option::is_none")]
bin_dir: Option<String>,
/// Default to ${tool}${exe}
#[serde(skip_serializing_if = "Option::is_none")]
bin: Option<String>,
@@ -603,9 +629,6 @@ struct ManifestTemplate {
#[derive(Debug, Clone, Serialize, Deserialize)]
struct ManifestTemplateDownloadInfo {
url: String,
/// Default to ${cargo_bin}
#[serde(skip_serializing_if = "Option::is_none")]
bin_dir: Option<String>,
/// Default to ${tool}${exe}
#[serde(skip_serializing_if = "Option::is_none")]
bin: Option<String>,
@@ -618,11 +641,11 @@ struct BaseManifest {
repository: String,
/// Prefix of release tag.
tag_prefix: String,
/// Crate name, if this is Rust crate.
rust_crate: Option<String>,
default_major_version: Option<String>,
/// Asset name patterns.
asset_name: Option<StringOrArray>,
/// Directory where binary is installed. Default to `${cargo_bin}`.
bin_dir: Option<String>,
/// Path to binary in archive. Default to `${tool}${exe}`.
bin: Option<String>,
platform: BTreeMap<HostPlatform, BaseManifestPlatformInfo>,
@@ -637,8 +660,6 @@ struct BaseManifest {
struct BaseManifestPlatformInfo {
/// Asset name patterns. Default to the value at `BaseManifest::asset_name`.
asset_name: Option<StringOrArray>,
/// Directory where binary is installed. Default to the value at `BaseManifest::bin_dir`.
bin_dir: Option<String>,
/// Path to binary in archive. Default to the value at `BaseManifest::bin`.
bin: Option<String>,
}
@@ -741,3 +762,19 @@ mod github {
pub browser_download_url: String,
}
}
mod crates_io {
use serde::Deserialize;
// https://crates.io/api/v1/crates/<crate>
#[derive(Debug, Deserialize)]
pub struct Crate {
pub versions: Vec<Version>,
}
#[derive(Debug, Deserialize)]
pub struct Version {
pub num: semver::Version,
pub yanked: bool,
}
}