Skip to content

Commit eda4ae5

Browse files
facutuescaRafaelGSS
authored andcommitted
tools: add automation for updating base64 dependency
Add a Github Action that checks for new versions of the `base64` C library, and creates a PR to update it if a newer version than the one present in the repo is found. Refs: nodejs/security-wg#828 PR-URL: #45300 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 4d38bf2 commit eda4ae5

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.github/workflows/tools.yml

+13
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,24 @@ jobs:
7878
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
7979
./tools/update-undici.sh
8080
fi
81+
- id: base64
82+
subsystem: deps
83+
label: dependencies
84+
run: |
85+
NEW_VERSION=$(gh api repos/aklomp/base64/releases/latest -q '.tag_name|ltrimstr("v")')
86+
CURRENT_VERSION=$(grep "base64 LANGUAGES C VERSION" ./deps/base64/base64/CMakeLists.txt | \
87+
sed -n "s/^.*VERSION \(.*\))/\1/p")
88+
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
89+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
90+
./tools/update-base64.sh "$NEW_VERSION"
91+
fi
8192
steps:
8293
- uses: actions/checkout@v3
8394
with:
8495
persist-credentials: false
8596
- run: ${{ matrix.run }}
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
8699
- uses: gr2m/create-or-update-pull-request-action@dc1726cbf4dd3ce766af4ec29cfb660e0125e8ee
87100
# Creates a PR or update the Action's existing PR, or
88101
# no-op if the base branch is already up-to-date.

tools/update-base64.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update base64 in the source tree to a specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
6+
DEPS_DIR="$BASE_DIR/deps"
7+
BASE64_VERSION=$1
8+
9+
if [ "$#" -le 0 ]; then
10+
echo "Error: please provide an base64 version to update to"
11+
echo " e.g. $0 0.4.0"
12+
exit 1
13+
fi
14+
15+
echo "Making temporary workspace"
16+
17+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
18+
19+
cleanup () {
20+
EXIT_CODE=$?
21+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
22+
exit $EXIT_CODE
23+
}
24+
25+
trap cleanup INT TERM EXIT
26+
27+
cd "$WORKSPACE"
28+
29+
echo "Fetching base64 source archive"
30+
curl -sL "https://api.github.com/repos/aklomp/base64/tarball/v$BASE64_VERSION" | tar xzf -
31+
mv aklomp-base64-* base64
32+
33+
echo "Replacing existing base64"
34+
rm -rf "$DEPS_DIR/base64/base64"
35+
mv "$WORKSPACE/base64" "$DEPS_DIR/base64/"
36+
37+
echo "All done!"
38+
echo ""
39+
echo "Please git add base64/base64, commit the new version:"
40+
echo ""
41+
echo "$ git add -A deps/base64/base64"
42+
echo "$ git commit -m \"deps: update base64 to $BASE64_VERSION\""
43+
echo ""

0 commit comments

Comments
 (0)