Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions tools/dep_updaters/update-c-ares.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ 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: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
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
Expand All @@ -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"
Expand Down