Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: standardize update-nghttp2.sh #47197

Merged
merged 1 commit into from Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/tools.yml
Expand Up @@ -142,12 +142,10 @@ jobs:
subsystem: deps
label: dependencies
run: |
NEW_VERSION=$(gh api repos/nghttp2/nghttp2/releases/latest -q '.tag_name|ltrimstr("v")')
CURRENT_VERSION=$(grep "#define NGHTTP2_VERSION" ./deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h | sed -n "s/^.*VERSION \(.*\)/\1/p")
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
./tools/update-nghttp2.sh "$NEW_VERSION"
fi
./tools/dep_updaters/nghttp2.sh > temp-output
marco-ippolito marked this conversation as resolved.
Show resolved Hide resolved
cat temp-output
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
rm temp-output
- id: llhttp
subsystem: deps
label: dependencies
Expand Down
9 changes: 1 addition & 8 deletions doc/contributing/maintaining-nghttp2.md
Expand Up @@ -13,16 +13,9 @@ directory and C++ code in the

## Step 1: Updating nghttp2

The `tools/update-nghttp2.sh` script automates the update of the
The `tools/dep_updaters/update-nghttp2.sh` script automates the update of the
postject source files.

In the following examples, `x.y.z` should match the nghttp2
version to update to.

```console
$ ./tools/update-nghttp2.sh x.y.z
```

## Step 2: Test the build

```console
Expand Down
36 changes: 27 additions & 9 deletions tools/update-nghttp2.sh → tools/dep_updaters/update-nghttp2.sh
Expand Up @@ -2,13 +2,27 @@
set -e
# Shell script to update nghttp2 in the source tree to specific version

BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
DEPS_DIR="$BASE_DIR/deps"
NGHTTP2_VERSION=$1

if [ "$#" -le 0 ]; then
echo "Error: please provide an nghttp2 version to update to"
exit 1
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/nghttp2/nghttp2/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 NGHTTP2_VERSION" ./deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

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

echo "Making temporary workspace"
Expand All @@ -23,16 +37,16 @@ cleanup () {

trap cleanup INT TERM EXIT

NGHTTP2_REF="v$NGHTTP2_VERSION"
NGHTTP2_TARBALL="nghttp2-$NGHTTP2_VERSION.tar.gz"
NGHTTP2_REF="v$NEW_VERSION"
NGHTTP2_TARBALL="nghttp2-$NEW_VERSION.tar.gz"

cd "$WORKSPACE"

echo "Fetching nghttp2 source archive"
curl -sL -o "$NGHTTP2_TARBALL" "https://github.com/nghttp2/nghttp2/releases/download/$NGHTTP2_REF/$NGHTTP2_TARBALL"
gzip -dc "$NGHTTP2_TARBALL" | tar xf -
rm "$NGHTTP2_TARBALL"
mv "nghttp2-$NGHTTP2_VERSION" nghttp2
mv "nghttp2-$NEW_VERSION" nghttp2

echo "Removing everything, except lib/ and COPYING"
cd nghttp2
Expand All @@ -59,5 +73,9 @@ echo ""
echo "Please git add nghttp2, commit the new version:"
echo ""
echo "$ git add -A deps/nghttp2"
echo "$ git commit -m \"deps: update nghttp2 to $NGHTTP2_VERSION\""
echo "$ git commit -m \"deps: update nghttp2 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"