Skip to content

Commit

Permalink
copy over prebuild file?
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Jun 18, 2024
1 parent 893eb52 commit 87288ec
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/run-prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

set -o errexit # Exit the script with error if any of the commands fail
set -o xtrace

source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"

# mongodbtoolchain is necessary for building on Windows
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"

echo "Node Version $(node -v)"

get_version_at_git_rev () {
local REV=$1
local VERSION
VERSION=$(node -r child_process -e "console.log(JSON.parse(child_process.execSync('git show $REV:./package.json', { encoding: 'utf8' })).version);")
echo "$VERSION"
}

run_prebuild() {
set +o xtrace # Don't log the token
if [[ -z $NODE_GITHUB_TOKEN ]];then
echo "No github token set. Cannot run prebuild."
exit 1
else
echo "Github token detected. Running prebuild."
npm run prebuild -- -u "${NODE_GITHUB_TOKEN}"
echo "Prebuild's successfully submitted"
fi
set -o xtrace
}


VERSION_AT_HEAD=$(get_version_at_git_rev "HEAD")
VERSION_AT_HEAD_1=$(get_version_at_git_rev "HEAD~1")

if [[ -n $NODE_FORCE_PUBLISH ]]; then
echo 'NODE_FORCE_PUBLISH detected'
echo "Beginning prebuild"
run_prebuild
elif [[ $VERSION_AT_HEAD != "$VERSION_AT_HEAD_1" ]]; then
echo "Difference is package version ($VERSION_AT_HEAD_1 -> $VERSION_AT_HEAD)"
echo "Beginning prebuild"
run_prebuild
else
echo "No difference is package version ($VERSION_AT_HEAD_1 -> $VERSION_AT_HEAD)"
echo "Will prebuild without submit"
npm run prebuild
echo "Local prebuild successful."
ls prebuilds
fi

0 comments on commit 87288ec

Please sign in to comment.