|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Shell script to update @reporters/github in the source tree to the latest release. |
| 4 | + |
| 5 | +# This script must be in the tools directory when it runs because it uses the |
| 6 | +# script source file path to determine directories to work in. |
| 7 | + |
| 8 | +set -ex |
| 9 | + |
| 10 | +ROOT=$(cd "$(dirname "$0")/../.." && pwd) |
| 11 | +[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" |
| 12 | +[ -x "$NODE" ] || NODE=$(command -v node) |
| 13 | +NPM="$ROOT/deps/npm/bin/npm-cli.js" |
| 14 | + |
| 15 | +# shellcheck disable=SC1091 |
| 16 | +. "$ROOT/tools/dep_updaters/utils.sh" |
| 17 | + |
| 18 | +NEW_VERSION=$("$NODE" "$NPM" view @reporters/github dist-tags.latest) |
| 19 | +CURRENT_VERSION=$("$NODE" -p "require('./tools/github_reporter/package.json').version") |
| 20 | + |
| 21 | +# This function exit with 0 if new version and current version are the same |
| 22 | +compare_dependency_version "@reporters/github" "$NEW_VERSION" "$CURRENT_VERSION" |
| 23 | + |
| 24 | +cd "$( dirname "$0" )/../.." || exit |
| 25 | +rm -rf tools/github_reporter |
| 26 | + |
| 27 | +( |
| 28 | + rm -rf github-reporter-tmp |
| 29 | + mkdir github-reporter-tmp |
| 30 | + cd github-reporter-tmp || exit |
| 31 | + |
| 32 | + "$NODE" "$NPM" init --yes |
| 33 | + "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "@reporters/github@$NEW_VERSION" |
| 34 | + "$NODE" "$NPM" exec --package=esbuild@0.17.15 --yes -- esbuild ./node_modules/@reporters/github --bundle --platform=node --outfile=bundle.js |
| 35 | +) |
| 36 | + |
| 37 | +mkdir tools/github_reporter |
| 38 | +mv github-reporter-tmp/bundle.js tools/github_reporter/index.js |
| 39 | +mv github-reporter-tmp/node_modules/@reporters/github/package.json tools/github_reporter/package.json |
| 40 | +rm -rf github-reporter-tmp/ |
| 41 | + |
| 42 | +# The last line of the script should always print the new version, |
| 43 | +# as we need to add it to $GITHUB_ENV variable. |
| 44 | +echo "NEW_VERSION=$NEW_VERSION" |
0 commit comments