Skip to content

Commit

Permalink
tools: align update-ada.sh with other scripts
Browse files Browse the repository at this point in the history
PR-URL: #47044
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
  • Loading branch information
tony-go authored and targos committed Mar 18, 2023
1 parent aefe266 commit d1ca5b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/tools.yml
Expand Up @@ -134,12 +134,10 @@ jobs:
subsystem: deps
label: dependencies
run: |
NEW_VERSION=$(gh api repos/ada-url/ada/releases/latest -q '.tag_name|ltrimstr("v")')
CURRENT_VERSION=$(grep "#define ADA_VERSION" ./deps/ada/ada.h | sed -n "s/^.*VERSION \(.*\)/\1/p")
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
./tools/dep_updaters/update-ada.sh "$NEW_VERSION"
fi
./tools/dep_updaters/update-ada.sh > temp-output
cat temp-output
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
rm temp-output
- id: nghttp2
subsystem: deps
label: dependencies
Expand Down
30 changes: 22 additions & 8 deletions tools/dep_updaters/update-ada.sh
Expand Up @@ -4,12 +4,22 @@ set -e

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
DEPS_DIR="$BASE_DIR/deps"
ADA_VERSION=$1
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)

if [ "$#" -le 0 ]; then
echo "Error: please provide an ada version to update to"
echo " e.g. $0 1.0.0"
exit 1
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/ada-url/ada/releases/latest');
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
EOF
)"

CURRENT_VERSION=$(grep "#define ADA_VERSION" "$DEPS_DIR/ada/ada.h" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because ada is on the latest version."
exit 0
fi

echo "Making temporary workspace..."
Expand All @@ -24,8 +34,8 @@ cleanup () {

trap cleanup INT TERM EXIT

ADA_REF="v$ADA_VERSION"
ADA_ZIP="ada-$ADA_VERSION.zip"
ADA_REF="v$NEW_VERSION"
ADA_ZIP="ada-$NEW_VERSION.zip"
ADA_LICENSE="LICENSE-MIT"

cd "$WORKSPACE"
Expand All @@ -47,5 +57,9 @@ echo ""
echo "Please git add ada, commit the new version:"
echo ""
echo "$ git add -A deps/ada"
echo "$ git commit -m \"deps: update ada to $ADA_VERSION\""
echo "$ git commit -m \"deps: update ada to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"

0 comments on commit d1ca5b6

Please sign in to comment.