mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
tools: fix c-ares update script
PR-URL: https://github.com/nodejs/node/pull/53414 Fixes: https://github.com/nodejs/node/issues/53407 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
473410d379
commit
c64a00a12d
|
|
@ -11,7 +11,7 @@ DEPS_DIR="$BASE_DIR/deps"
|
|||
# shellcheck disable=SC1091
|
||||
. "$BASE_DIR/tools/dep_updaters/utils.sh"
|
||||
|
||||
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
|
||||
NEW_VERSION_METADATA="$("$NODE" --input-type=module <<'EOF'
|
||||
const res = await fetch('https://api.github.com/repos/c-ares/c-ares/releases/latest',
|
||||
process.env.GITHUB_TOKEN && {
|
||||
headers: {
|
||||
|
|
@ -19,11 +19,17 @@ const res = await fetch('https://api.github.com/repos/c-ares/c-ares/releases/lat
|
|||
},
|
||||
});
|
||||
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
|
||||
const { tag_name } = await res.json();
|
||||
console.log(tag_name.replace('cares-', '').replaceAll('_', '.'));
|
||||
const { tag_name, assets } = await res.json();
|
||||
const { browser_download_url, name } = assets.find(({ name }) => name.endsWith('.tar.gz'));
|
||||
if(!browser_download_url || !name) throw new Error('No tarball found');
|
||||
console.log(`${tag_name} ${browser_download_url} ${name}`);
|
||||
EOF
|
||||
)"
|
||||
|
||||
IFS=' ' read -r NEW_VERSION NEW_VERSION_URL ARES_TARBALL <<EOF
|
||||
$NEW_VERSION_METADATA
|
||||
EOF
|
||||
|
||||
CURRENT_VERSION=$(grep "#define ARES_VERSION_STR" ./deps/cares/include/ares_version.h | sed -n "s/^.*VERSION_STR \"\(.*\)\"/\1/p")
|
||||
|
||||
# This function exit with 0 if new version and current version are the same
|
||||
|
|
@ -41,17 +47,17 @@ cleanup () {
|
|||
|
||||
trap cleanup INT TERM EXIT
|
||||
|
||||
ARES_REF="cares-$(echo "$NEW_VERSION" | tr . _)"
|
||||
ARES_TARBALL="c-ares-$NEW_VERSION.tar.gz"
|
||||
|
||||
cd "$WORKSPACE"
|
||||
|
||||
echo "Fetching c-ares source archive"
|
||||
curl -sL -o "$ARES_TARBALL" "https://github.com/c-ares/c-ares/releases/download/$ARES_REF/$ARES_TARBALL"
|
||||
curl -sL -o "$ARES_TARBALL" "$NEW_VERSION_URL"
|
||||
log_and_verify_sha256sum "c-ares" "$ARES_TARBALL"
|
||||
gzip -dc "$ARES_TARBALL" | tar xf -
|
||||
rm "$ARES_TARBALL"
|
||||
mv "c-ares-$NEW_VERSION" cares
|
||||
rm -- "$ARES_TARBALL"
|
||||
|
||||
FOLDER=$(ls -d -- */)
|
||||
|
||||
mv -- "$FOLDER" cares
|
||||
|
||||
echo "Removing tests"
|
||||
rm -rf "$WORKSPACE/cares/test"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user