mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-26 17:10:48 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a31ba8d6d | ||
|
|
4b8b61e298 | ||
|
|
4269f7d620 | ||
|
|
c92838b65e | ||
|
|
f6e4dc6296 | ||
|
|
d538488fe5 | ||
|
|
6e129b86d0 | ||
|
|
3b58ab42ed | ||
|
|
38250d8ada | ||
|
|
d89f3d4042 | ||
|
|
00f11cb267 | ||
|
|
8db8546a9c | ||
|
|
5fc2b23470 | ||
|
|
aae39e2ce4 | ||
|
|
54eee5470f | ||
|
|
2411265c71 | ||
|
|
8066254c63 | ||
|
|
0feb352bd8 | ||
|
|
9a9630c7b3 | ||
|
|
baf51dce12 | ||
|
|
c096cea2cf | ||
|
|
cde5fb702d |
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -19,7 +19,7 @@ defaults:
|
||||
|
||||
jobs:
|
||||
tidy:
|
||||
uses: taiki-e/workflows/.github/workflows/tidy-rust.yml@main
|
||||
uses: taiki-e/workflows/.github/workflows/tidy.yml@main
|
||||
|
||||
test:
|
||||
strategy:
|
||||
@@ -45,6 +45,7 @@ jobs:
|
||||
- os: windows-2019
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
@@ -91,6 +92,7 @@ jobs:
|
||||
# cargo-udeps,protoc,valgrind,wasmtime,mdbook-linkcheck,cargo-watch don't provide prebuilt binaries for musl host.
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,shellcheck,shfmt,wasm-pack,mdbook,cargo-binstall,grcov
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: Install requirements (ubuntu/debian)
|
||||
@@ -132,6 +134,7 @@ jobs:
|
||||
|
||||
manifest:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
permissions:
|
||||
contents: write # TODO test
|
||||
pull-requests: write
|
||||
@@ -142,6 +145,8 @@ jobs:
|
||||
- name: Install Rust
|
||||
run: rustup toolchain add nightly --no-self-update && rustup default nightly
|
||||
- run: tools/manifest.sh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: git add -N . && git diff --exit-code
|
||||
if: github.repository_owner != 'taiki-e' || github.event_name != 'schedule' && !(github.event_name == 'push' && github.ref == 'refs/heads/main')
|
||||
- id: diff
|
||||
|
||||
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -17,6 +17,7 @@ jobs:
|
||||
create-release:
|
||||
if: github.repository_owner == 'taiki-e'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
|
||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -10,6 +10,18 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.2.2] - 2023-01-15
|
||||
|
||||
- Update `cargo-llvm-cov@latest` to 0.5.8.
|
||||
|
||||
- Update `cargo-nextest@latest` to 0.9.49.
|
||||
|
||||
## [2.2.1] - 2023-01-12
|
||||
|
||||
- Update `cargo-binstall@latest` to 0.19.1.
|
||||
|
||||
- Support `cargo-binstall` on aarch64 Windows.
|
||||
|
||||
## [2.2.0] - 2023-01-11
|
||||
|
||||
- Update `cargo-llvm-cov@latest` to 0.5.7.
|
||||
@@ -543,7 +555,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.2.0...HEAD
|
||||
[Unreleased]: https://github.com/taiki-e/install-action/compare/v2.2.2...HEAD
|
||||
[2.2.2]: https://github.com/taiki-e/install-action/compare/v2.2.1...v2.2.2
|
||||
[2.2.1]: https://github.com/taiki-e/install-action/compare/v2.2.0...v2.2.1
|
||||
[2.2.0]: https://github.com/taiki-e/install-action/compare/v2.1.4...v2.2.0
|
||||
[2.1.4]: https://github.com/taiki-e/install-action/compare/v2.1.3...v2.1.4
|
||||
[2.1.3]: https://github.com/taiki-e/install-action/compare/v2.1.2...v2.1.3
|
||||
|
||||
@@ -125,10 +125,12 @@ To use this action in self-hosted runners or in containers, you will need to ins
|
||||
|
||||
## Related Projects
|
||||
|
||||
- [cache-cargo-install-action]: GitHub Action for `cargo install` with cache.
|
||||
- [create-gh-release-action]: GitHub Action for creating GitHub Releases based on changelog.
|
||||
- [upload-rust-binary-action]: GitHub Action for building and uploading Rust binary to GitHub Releases.
|
||||
- [setup-cross-toolchain-action]: GitHub Action for setup toolchains for cross compilation and cross testing for Rust.
|
||||
|
||||
[cache-cargo-install-action]: https://github.com/taiki-e/cache-cargo-install-action
|
||||
[cargo-binstall]: https://github.com/cargo-bins/cargo-binstall
|
||||
[create-gh-release-action]: https://github.com/taiki-e/create-gh-release-action
|
||||
[setup-cross-toolchain-action]: https://github.com/taiki-e/setup-cross-toolchain-action
|
||||
|
||||
12
main.js
12
main.js
@@ -1,3 +1,15 @@
|
||||
// This is a script that just calls the bash script that does the main
|
||||
// processing of the action. It works like a composite action that calls
|
||||
// a single bash script.
|
||||
//
|
||||
// This was originally a trick adopted to make bash script-based actions work
|
||||
// without docker before composite actions were supported. However, due to
|
||||
// various problems with composite actions, this trick is still needed:
|
||||
// - https://github.com/actions/runner/issues/665
|
||||
// - https://github.com/actions/runner/issues/2185
|
||||
// Although there are ways to work around these like cache-cargo-install-action does:
|
||||
// https://github.com/taiki-e/cache-cargo-install-action/blob/v1.0.1/action.yml#L9-L11
|
||||
|
||||
const { execFileSync } = require('child_process');
|
||||
|
||||
function main() {
|
||||
|
||||
65
main.sh
65
main.sh
@@ -11,7 +11,7 @@ x() {
|
||||
)
|
||||
}
|
||||
retry() {
|
||||
for i in {1..5}; do
|
||||
for i in {1..10}; do
|
||||
if "$@"; then
|
||||
return 0
|
||||
else
|
||||
@@ -226,10 +226,10 @@ install_cargo_binstall() {
|
||||
local install_binstall='1'
|
||||
if [[ -f "${cargo_bin}/cargo-binstall${exe}" ]]; then
|
||||
if [[ "$(cargo binstall -V)" == "${binstall_version}" ]]; then
|
||||
info "cargo-binstall already installed on in ${cargo_bin}/cargo-binstall${exe}"
|
||||
info "cargo-binstall already installed at ${cargo_bin}/cargo-binstall${exe}"
|
||||
install_binstall=''
|
||||
else
|
||||
info "cargo-binstall already installed on in ${cargo_bin}/cargo-binstall${exe}, but is not compatible version with install-action, upgrading"
|
||||
info "cargo-binstall already installed at ${cargo_bin}/cargo-binstall${exe}, but is not compatible version with install-action, upgrading"
|
||||
rm "${cargo_bin}/cargo-binstall${exe}"
|
||||
fi
|
||||
fi
|
||||
@@ -291,9 +291,9 @@ snap_install() {
|
||||
}
|
||||
apk_install() {
|
||||
if type -P doas &>/dev/null; then
|
||||
doas apk add "$@"
|
||||
doas apk add --no-cache "$@"
|
||||
else
|
||||
apk add "$@"
|
||||
apk add --no-cache "$@"
|
||||
fi
|
||||
}
|
||||
dnf_install() {
|
||||
@@ -324,6 +324,11 @@ tools=()
|
||||
if [[ -n "${tool}" ]]; then
|
||||
while read -rd,; do tools+=("${REPLY}"); done <<<"${tool},"
|
||||
fi
|
||||
if [[ ${#tools[@]} -eq 0 ]]; then
|
||||
warn "no tool specified; this could be caused by a dependabot bug where @<tool_name> tags on this action are replaced by @<version> tags"
|
||||
# Exit with 0 for backward compatibility, we want to reject it in the next major release.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
enable_checksum="${INPUT_CHECKSUM:-}"
|
||||
case "${enable_checksum}" in
|
||||
@@ -333,33 +338,16 @@ case "${enable_checksum}" in
|
||||
esac
|
||||
|
||||
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
|
||||
case "$(uname -m)" in
|
||||
aarch64 | arm64) host_arch="aarch64" ;;
|
||||
xscale | arm | armv6l | armv7l | armv8l)
|
||||
# Ignore arm for now, as we need to consider the version and whether hard-float is supported.
|
||||
# https://github.com/rust-lang/rustup/pull/593
|
||||
# https://github.com/cross-rs/cross/pull/1018
|
||||
# Does it seem only armv7l is supported?
|
||||
# https://github.com/actions/runner/blob/6b9e8a6be411a6e63d5ccaf3c47e7b7622c5ec49/src/Misc/externals.sh#L174
|
||||
bail "32-bit ARM runner is not supported yet by this action"
|
||||
;;
|
||||
# GitHub Actions Runner supports Linux (x86_64, aarch64, arm), Windows (x86_64, aarch64),
|
||||
# and macOS (x86_64, aarch64).
|
||||
# https://github.com/actions/runner
|
||||
# https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#supported-architectures-and-operating-systems-for-self-hosted-runners
|
||||
# So we can assume x86_64 unless it is aarch64 or arm.
|
||||
*) host_arch="x86_64" ;;
|
||||
esac
|
||||
base_distro=""
|
||||
exe=""
|
||||
case "$(uname -s)" in
|
||||
Linux)
|
||||
host_os=linux
|
||||
host_env="gnu"
|
||||
ldd_version=$(ldd --version 2>&1 || true)
|
||||
if grep <<<"${ldd_version}" -q 'musl'; then
|
||||
host_env="musl"
|
||||
else
|
||||
host_env="gnu"
|
||||
host_glibc_version=$(grep <<<"${ldd_version}" -E "GLIBC|GNU libc" | sed "s/.* //g")
|
||||
fi
|
||||
if grep -q '^ID_LIKE=' /etc/os-release; then
|
||||
@@ -397,6 +385,24 @@ case "$(uname -s)" in
|
||||
;;
|
||||
*) bail "unrecognized OS type '$(uname -s)'" ;;
|
||||
esac
|
||||
case "$(uname -m)" in
|
||||
aarch64 | arm64) host_arch="aarch64" ;;
|
||||
xscale | arm | armv6l | armv7l | armv8l)
|
||||
# Ignore arm for now, as we need to consider the version and whether hard-float is supported.
|
||||
# https://github.com/rust-lang/rustup/pull/593
|
||||
# https://github.com/cross-rs/cross/pull/1018
|
||||
# Does it seem only armv7l is supported?
|
||||
# https://github.com/actions/runner/blob/caec043085990710070108f375cd0aeab45e1017/src/Misc/externals.sh#L174
|
||||
bail "32-bit ARM runner is not supported yet by this action"
|
||||
;;
|
||||
# GitHub Actions Runner supports Linux (x86_64, aarch64, arm), Windows (x86_64, aarch64),
|
||||
# and macOS (x86_64, aarch64).
|
||||
# https://github.com/actions/runner
|
||||
# https://github.com/actions/runner/blob/caec043085990710070108f375cd0aeab45e1017/.github/workflows/build.yml#L21
|
||||
# https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#supported-architectures-and-operating-systems-for-self-hosted-runners
|
||||
# So we can assume x86_64 unless it is aarch64 or arm.
|
||||
*) host_arch="x86_64" ;;
|
||||
esac
|
||||
|
||||
tmp_dir="${HOME}/.install-action/tmp"
|
||||
cargo_bin="${CARGO_HOME:-"${HOME}/.cargo"}/bin"
|
||||
@@ -419,25 +425,19 @@ if ! type -P jq &>/dev/null || ! type -P curl &>/dev/null || ! type -P tar &>/de
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ ${#tools[@]} -eq 0 ]]; then
|
||||
warn "no tool specified; this could be caused by a dependabot bug where @<tool_name> tags on this action are replaced by @<version> tags"
|
||||
# Exit with 0 for backward compatibility, we want to reject it in the next major release.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for tool in "${tools[@]}"; do
|
||||
if [[ "${tool}" == *"@"* ]]; then
|
||||
version="${tool#*@}"
|
||||
tool="${tool%@*}"
|
||||
if [[ ! "${version}" =~ ^([1-9][0-9]*(\.[0-9]+(\.[0-9]+)?)?|0\.[1-9][0-9]*(\.[0-9]+)?|^0\.0\.[0-9]+)$|^latest$ ]]; then
|
||||
if [[ ! "${version}" =~ ^([1-9][0-9]*(\.[0-9]+(\.[0-9]+)?)?|0\.[1-9][0-9]*(\.[0-9]+)?|^0\.0\.[0-9]+)(-[0-9A-Za-z\.-]+)?(\+[0-9A-Za-z\.-]+)?$|^latest$ ]]; then
|
||||
bail "install-action does not support semver operators"
|
||||
bail "install-action does not support semver operators: '${version}'"
|
||||
fi
|
||||
bail "install-action v2 does not support semver pre-release and build-metadata; please submit an issue if you need these supports again"
|
||||
bail "install-action v2 does not support semver pre-release and build-metadata; please submit an issue if you need these supports again: '${version}'"
|
||||
fi
|
||||
else
|
||||
version="latest"
|
||||
fi
|
||||
tool="${tool%@*}"
|
||||
info "installing ${tool}@${version}"
|
||||
case "${tool}" in
|
||||
protoc)
|
||||
@@ -508,6 +508,7 @@ for tool in "${tools[@]}"; do
|
||||
# Use cargo-binstall fallback if tool is not available.
|
||||
if [[ ! -f "${manifest_dir}/${tool}.json" ]]; then
|
||||
cargo_binstall "${tool}" "${version}"
|
||||
echo
|
||||
continue
|
||||
fi
|
||||
|
||||
|
||||
@@ -14,26 +14,32 @@
|
||||
},
|
||||
"aarch64_macos": {
|
||||
"url": "https://github.com/cargo-bins/cargo-binstall/releases/download/v${version}/cargo-binstall-aarch64-apple-darwin.zip"
|
||||
},
|
||||
"aarch64_windows": {
|
||||
"url": "https://github.com/cargo-bins/cargo-binstall/releases/download/v${version}/cargo-binstall-aarch64-pc-windows-msvc.zip"
|
||||
}
|
||||
},
|
||||
"latest": {
|
||||
"version": "0.18.1"
|
||||
"version": "0.19.1"
|
||||
},
|
||||
"0.18.1": {
|
||||
"0.19.1": {
|
||||
"x86_64_linux_musl": {
|
||||
"checksum": "ef05f04e951665b617fe0796ec72e5dc51e8724ee0b09a0da129fa24162369a0"
|
||||
"checksum": "b270f25fd21fe27b99b99cb4f6dd5ed98ec01284cf450994974f632c77a823a8"
|
||||
},
|
||||
"x86_64_macos": {
|
||||
"checksum": "291ad8f69e3f31a620c17a68cb456f64ab736947a76c57ffcc6f8602a09b4cb5"
|
||||
"checksum": "dd46485e17b12211684fcb3e55e966f9f4cb75c14bb715f6c905373640e98a4e"
|
||||
},
|
||||
"x86_64_windows": {
|
||||
"checksum": "bfc078cb22626bb80e1bb23a3cc74f4362c1326ec3f3dfc1cc46e1bd13528906"
|
||||
"checksum": "b120023e546562bfea5ca4ef1a3b67fc6571968ae459a34aa0b4414eff38f5e3"
|
||||
},
|
||||
"aarch64_linux_musl": {
|
||||
"checksum": "d26b5bbe14bbf7bd0f5fdd5b843f7f6df2c75d01168d42909932a422f17a4d5b"
|
||||
"checksum": "98264b5342db7a7b68d215d105a42a81961de02743b8c369b476dc892d12f2fa"
|
||||
},
|
||||
"aarch64_macos": {
|
||||
"checksum": "9ea261b7617bf6161447aa42b8e8979a7369aed3e5cef6b3774bec55fa4c70b6"
|
||||
"checksum": "dd099af7147d856bcf6cc713c1bf53c4be003f597f92fe9c2e3a58d0ad7d6fd2"
|
||||
},
|
||||
"aarch64_windows": {
|
||||
"checksum": "ed5023a73f3bb8a8b8fb80e5a7476cab2487d7e16ed3fe04b51cf25ec1644d92"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,27 @@
|
||||
}
|
||||
},
|
||||
"latest": {
|
||||
"version": "0.5.7"
|
||||
"version": "0.5.8"
|
||||
},
|
||||
"0.5": {
|
||||
"version": "0.5.7"
|
||||
"version": "0.5.8"
|
||||
},
|
||||
"0.5.8": {
|
||||
"x86_64_linux_musl": {
|
||||
"checksum": "78a2b85c54d2ecf76ad7309278901c2f4d6dcc611ef095844e8c6bd87b2d6a72"
|
||||
},
|
||||
"x86_64_macos": {
|
||||
"checksum": "b1227359e4994f9ee96247bc2d47e36612f0b5344f9010f31ac965163a44e98c"
|
||||
},
|
||||
"x86_64_windows": {
|
||||
"checksum": "d18f4da434596eb2c4aa2eaa95e00482130affa0a1710046c2d29c5c6edcb202"
|
||||
},
|
||||
"aarch64_linux_musl": {
|
||||
"checksum": "11a3018bd91ff62806e7aa3413c5dc9af22ede870af4850866dbfe94cec0bd70"
|
||||
},
|
||||
"aarch64_macos": {
|
||||
"checksum": "d4c67fac1dfa16cb130142bb572b310de856a8ec0494cc95351b5d82507793f2"
|
||||
}
|
||||
},
|
||||
"0.5.7": {
|
||||
"x86_64_linux_musl": {
|
||||
|
||||
@@ -17,10 +17,27 @@
|
||||
}
|
||||
},
|
||||
"latest": {
|
||||
"version": "0.9.48"
|
||||
"version": "0.9.49"
|
||||
},
|
||||
"0.9": {
|
||||
"version": "0.9.48"
|
||||
"version": "0.9.49"
|
||||
},
|
||||
"0.9.49": {
|
||||
"x86_64_linux_gnu": {
|
||||
"checksum": "5e19c5038c9940da4c47a9ae87f94b352dc98c2ab75b4b9aeae227cdff8440d2"
|
||||
},
|
||||
"x86_64_linux_musl": {
|
||||
"checksum": "b09d7870bba824af1acfce505811951f0d81cf21b144490c6a3f34f59bcc182b"
|
||||
},
|
||||
"x86_64_macos": {
|
||||
"checksum": "171bc696474667208587c74d9acce0250f3b2eac1faad39458e828a65c3f1c93"
|
||||
},
|
||||
"x86_64_windows": {
|
||||
"checksum": "e9c532bb99c6e8e7edb65578f8c251fb3d87a3377bef1128763442dc7f088ebb"
|
||||
},
|
||||
"aarch64_linux_gnu": {
|
||||
"checksum": "40ff81ed279e8a6d38ebe06ee75bba47785e8cb006267e35a15c157724e8e437"
|
||||
}
|
||||
},
|
||||
"0.9.48": {
|
||||
"x86_64_linux_gnu": {
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
"aarch64_linux_musl": {},
|
||||
"aarch64_macos": {
|
||||
"asset_name": "${package}-${rust_target}.zip"
|
||||
},
|
||||
"aarch64_windows": {
|
||||
"asset_name": "${package}-${rust_target}.zip"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ fn main() -> Result<()> {
|
||||
.join(format!("{package}.json"));
|
||||
let download_cache_dir = &workspace_root.join("tools/codegen/tmp/cache").join(package);
|
||||
fs::create_dir_all(download_cache_dir)?;
|
||||
|
||||
let base_info: BaseManifest = serde_json::from_slice(&fs::read(
|
||||
workspace_root
|
||||
.join("tools/codegen/base")
|
||||
@@ -41,6 +42,8 @@ fn main() -> Result<()> {
|
||||
|
||||
eprintln!("downloading releases of https://github.com/{repo}");
|
||||
let mut releases: github::Releases = vec![];
|
||||
// GitHub API returns up to 100 results at a time. If the number of releases
|
||||
// is greater than 100, multiple fetches are needed.
|
||||
for page in 1.. {
|
||||
let per_page = 100;
|
||||
let mut r: github::Releases = download(&format!(
|
||||
@@ -286,10 +289,37 @@ fn main() -> Result<()> {
|
||||
);
|
||||
}
|
||||
|
||||
let ManifestRef::Ref { version: latest_version } = manifests.map.first_key_value().unwrap().1.clone() else { unreachable!() };
|
||||
if latest_only {
|
||||
manifests
|
||||
.map
|
||||
.retain(|k, m| k.0 == Version::latest() || matches!(m, ManifestRef::Real(..)));
|
||||
.retain(|k, _| k.0 == Version::latest() || k.0 == latest_version);
|
||||
}
|
||||
let ManifestRef::Real(latest_manifest) = &manifests.map[&Reverse(latest_version.clone())] else { unreachable!() };
|
||||
for &p in base_info.platform.keys() {
|
||||
if latest_manifest.download_info.contains_key(&p) {
|
||||
continue;
|
||||
}
|
||||
if !base_info.prefer_linux_gnu {
|
||||
if p == HostPlatform::x86_64_linux_gnu
|
||||
&& latest_manifest
|
||||
.download_info
|
||||
.contains_key(&HostPlatform::x86_64_linux_musl)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if p == HostPlatform::aarch64_linux_gnu
|
||||
&& latest_manifest
|
||||
.download_info
|
||||
.contains_key(&HostPlatform::aarch64_linux_musl)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
bail!(
|
||||
"platform list in base manifest for {package} contains {p:?}, \
|
||||
but latest release ({latest_version}) doesn't contain it"
|
||||
);
|
||||
}
|
||||
|
||||
let original_manifests = manifests.clone();
|
||||
@@ -355,21 +385,36 @@ fn replace_vars(s: &str, package: &str, version: &str, platform: HostPlatform) -
|
||||
}
|
||||
|
||||
fn download(url: &str) -> Result<ureq::Response> {
|
||||
let token = env::var("INTERNAL_CODEGEN_GH_PAT").ok();
|
||||
let mut token1 = env::var("INTERNAL_CODEGEN_GH_PAT")
|
||||
.ok()
|
||||
.filter(|v| !v.is_empty());
|
||||
let mut token2 = env::var("GITHUB_TOKEN").ok().filter(|v| !v.is_empty());
|
||||
let mut retry = 0;
|
||||
let mut last_error = None;
|
||||
while retry < 5 {
|
||||
let mut last_error;
|
||||
loop {
|
||||
let mut req = ureq::get(url);
|
||||
if let Some(token) = &token {
|
||||
if let Some(token) = &token1 {
|
||||
req = req.set("Authorization", token);
|
||||
} else if let Some(token) = &token2 {
|
||||
req = req.set("Authorization", token);
|
||||
}
|
||||
match req.call() {
|
||||
Ok(res) => return Ok(res),
|
||||
Err(e) => last_error = Some(e),
|
||||
}
|
||||
if retry == 3 || retry == 6 {
|
||||
if token1.is_some() {
|
||||
token1 = None;
|
||||
} else if token2.is_some() {
|
||||
token2 = None;
|
||||
}
|
||||
}
|
||||
retry += 1;
|
||||
eprintln!("download failed; retrying ({retry}/5)");
|
||||
std::thread::sleep(Duration::from_secs(retry));
|
||||
if retry > 10 {
|
||||
break;
|
||||
}
|
||||
eprintln!("download failed; retrying ({retry}/10)");
|
||||
std::thread::sleep(Duration::from_secs(retry * 2));
|
||||
}
|
||||
Err(last_error.unwrap().into())
|
||||
}
|
||||
@@ -562,6 +607,7 @@ struct ManifestTemplateDownloadInfo {
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct BaseManifest {
|
||||
/// Link to the GitHub repository.
|
||||
repository: String,
|
||||
@@ -582,6 +628,7 @@ struct BaseManifest {
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct BaseManifestPlatformInfo {
|
||||
/// Asset name patterns. Default to the value at `BaseManifest::asset_name`.
|
||||
asset_name: Option<StringOrArray>,
|
||||
@@ -610,6 +657,7 @@ impl StringOrArray {
|
||||
/// GitHub Actions Runner supports Linux (x86_64, aarch64, arm), Windows (x86_64, aarch64),
|
||||
/// and macOS (x86_64, aarch64).
|
||||
/// https://github.com/actions/runner
|
||||
/// https://github.com/actions/runner/blob/caec043085990710070108f375cd0aeab45e1017/.github/workflows/build.yml#L21
|
||||
/// https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#supported-architectures-and-operating-systems-for-self-hosted-runners
|
||||
///
|
||||
/// Note:
|
||||
@@ -622,7 +670,7 @@ impl StringOrArray {
|
||||
/// https://github.com/rust-lang/rustup/pull/593
|
||||
/// https://github.com/cross-rs/cross/pull/1018
|
||||
/// Does it seem only armv7l is supported?
|
||||
/// https://github.com/actions/runner/blob/6b9e8a6be411a6e63d5ccaf3c47e7b7622c5ec49/src/Misc/externals.sh#L174
|
||||
/// https://github.com/actions/runner/blob/caec043085990710070108f375cd0aeab45e1017/src/Misc/externals.sh#L174
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
enum HostPlatform {
|
||||
|
||||
@@ -21,7 +21,9 @@ bail() {
|
||||
|
||||
version="${1:?}"
|
||||
version="${version#v}"
|
||||
tag="v${version}"
|
||||
tag_prefix="v"
|
||||
tag="${tag_prefix}${version}"
|
||||
changelog="CHANGELOG.md"
|
||||
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z\.-]+)?(\+[0-9A-Za-z\.-]+)?$ ]]; then
|
||||
bail "invalid version format '${version}'"
|
||||
fi
|
||||
@@ -38,44 +40,55 @@ if gh release view "${tag}" &>/dev/null; then
|
||||
bail "tag '${tag}' has already been created and pushed"
|
||||
fi
|
||||
|
||||
if ! git branch | grep -q '\* main'; then
|
||||
if ! git branch | grep -q '\* main$'; then
|
||||
bail "current branch is not 'main'"
|
||||
fi
|
||||
|
||||
tags=$(git --no-pager tag)
|
||||
release_date=$(date -u '+%Y-%m-%d')
|
||||
tags=$(git --no-pager tag | (grep -E "^${tag_prefix}[0-9]+" || true))
|
||||
if [[ -n "${tags}" ]]; then
|
||||
# Make sure the same release does not exist in CHANGELOG.md.
|
||||
release_date=$(date -u '+%Y-%m-%d')
|
||||
if grep -Eq "^## \\[${version//./\\.}\\] - ${release_date}$" CHANGELOG.md; then
|
||||
bail "release ${version} already exist in CHANGELOG.md"
|
||||
# Make sure the same release does not exist in changelog.
|
||||
if grep -Eq "^## \\[${version//./\\.}\\]" "${changelog}"; then
|
||||
bail "release ${version} already exist in ${changelog}"
|
||||
fi
|
||||
if grep -Eq "^\\[${version//./\\.}\\]: " CHANGELOG.md; then
|
||||
bail "link to ${version} already exist in CHANGELOG.md"
|
||||
if grep -Eq "^\\[${version//./\\.}\\]: " "${changelog}"; then
|
||||
bail "link to ${version} already exist in ${changelog}"
|
||||
fi
|
||||
|
||||
# Update changelog.
|
||||
remote_url=$(grep -E '^\[Unreleased\]: https://' CHANGELOG.md | sed 's/^\[Unreleased\]: //; s/\.\.\.HEAD$//')
|
||||
remote_url=$(grep -E '^\[Unreleased\]: https://' "${changelog}" | sed 's/^\[Unreleased\]: //; s/\.\.\.HEAD$//')
|
||||
before_tag="${remote_url#*/compare/}"
|
||||
remote_url="${remote_url%/compare/*}"
|
||||
sed -i "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n## [${version}] - ${release_date}/" CHANGELOG.md
|
||||
sed -i "s#^\[Unreleased\]: https://.*#[Unreleased]: ${remote_url}/compare/v${version}...HEAD\\n[${version}]: ${remote_url}/compare/${before_tag}...v${version}#" CHANGELOG.md
|
||||
if ! grep -Eq "^## \\[${version//./\\.}\\] - ${release_date}$" CHANGELOG.md; then
|
||||
bail "failed to update CHANGELOG.md"
|
||||
sed -i "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n## [${version}] - ${release_date}/" "${changelog}"
|
||||
sed -i "s#^\[Unreleased\]: https://.*#[Unreleased]: ${remote_url}/compare/${tag}...HEAD\\n[${version}]: ${remote_url}/compare/${before_tag}...${tag}#" "${changelog}"
|
||||
if ! grep -Eq "^## \\[${version//./\\.}\\] - ${release_date}$" "${changelog}"; then
|
||||
bail "failed to update ${changelog}"
|
||||
fi
|
||||
if ! grep -Eq "^\\[${version//./\\.}\\]: " CHANGELOG.md; then
|
||||
bail "failed to update CHANGELOG.md"
|
||||
if ! grep -Eq "^\\[${version//./\\.}\\]: " "${changelog}"; then
|
||||
bail "failed to update ${changelog}"
|
||||
fi
|
||||
else
|
||||
# Make sure the release exists in changelog.
|
||||
if ! grep -Eq "^## \\[${version//./\\.}\\] - ${release_date}$" "${changelog}"; then
|
||||
bail "release ${version} does not exist in ${changelog} or has wrong release date"
|
||||
fi
|
||||
if ! grep -Eq "^\\[${version//./\\.}\\]: " "${changelog}"; then
|
||||
bail "link to ${version} does not exist in ${changelog}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Make sure that a valid release note for this version exists.
|
||||
# https://github.com/taiki-e/parse-changelog
|
||||
changes=$(parse-changelog "${changelog}" "${version}")
|
||||
if [[ -z "${changes}" ]]; then
|
||||
bail "changelog for ${version} has no body"
|
||||
fi
|
||||
echo "============== CHANGELOG =============="
|
||||
parse-changelog CHANGELOG.md "${version}"
|
||||
echo "${changes}"
|
||||
echo "======================================="
|
||||
|
||||
if [[ -n "${tags}" ]]; then
|
||||
# Create a release commit.
|
||||
git add CHANGELOG.md
|
||||
git add "${changelog}"
|
||||
git commit -m "Release ${version}"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user