-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Improve automated checks; NPM release scripts
Signed-off-by: Matt Roberts <[email protected]>
- Loading branch information
Showing
30 changed files
with
3,902 additions
and
9,909 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
## this is a script soley for inclusion in the main build scripts. | ||
## Common functions that are executed both all types of builds | ||
|
||
ME=`basename "$0"` | ||
echo "-->-- Starting ${ME}" | ||
echo "--I-- ${TRAVIS_TAG} ${TRAVIS_BRANCH}" | ||
|
||
function _exit(){ | ||
printf "%s Exiting %s because %s exit code:%s\n" "--<--" "${ME}" "$1" "$2" | ||
exit $2 | ||
} | ||
|
||
function _abortBuild(){ | ||
echo "ABORT_BUILD=true" > ${DIR}/build.cfg | ||
echo "ABORT_CODE=$1" >> ${DIR}/build.cfg | ||
echo "BUILD_FOCUS=${BUILD_FOCUS}" >> ${DIR}/build.cfg | ||
echo "BUILD_RELEASE=${BUILD_RELEASE}" >> ${DIR}/build.cfg | ||
} | ||
|
||
#check to see if the build.cfg file (that holds state between scripts) | ||
if [ ! -f ${DIR}/build.cfg ]; then | ||
|
||
echo "ABORT_BUILD=false" > ${DIR}/build.cfg | ||
echo "ABORT_CODE=0" >> ${DIR}/build.cfg | ||
## determine the build type here | ||
if [ -z "${TRAVIS_TAG}" ]; then | ||
BUILD_RELEASE="unstable" | ||
BUILD_FOCUS="latest" | ||
else | ||
BUILD_RELEASE="stable" | ||
BUILD_FOCUS="latest" | ||
fi | ||
|
||
echo "BUILD_FOCUS=${BUILD_FOCUS}" >> ${DIR}/build.cfg | ||
echo "BUILD_RELEASE=${BUILD_RELEASE}" >> ${DIR}/build.cfg | ||
fi | ||
|
||
source ${DIR}/build.cfg | ||
|
||
echo "--I-- Build focus is ${BUILD_FOCUS}" | ||
echo "--I-- Build release is ${BUILD_RELEASE}" | ||
|
||
if [ "${ABORT_BUILD}" == "true" ]; then | ||
_exit "exiting early from" ${ABORT_CODE} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
ABORT_BUILD=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Script for the deploy phase, to push NPM modules, docker images and | ||
# cloud playground images | ||
|
||
# Exit on first error, print all commands. | ||
set -ev | ||
set -o pipefail | ||
|
||
# Bring in the standard set of script utilities | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" | ||
source ${DIR}/.travis/base.sh | ||
|
||
# ---- | ||
|
||
# Check that this is the main repository. | ||
if [[ "${TRAVIS_REPO_SLUG}" != accordproject* ]]; then | ||
_exit "Skipping deploy; wrong repository slug." 0 | ||
fi | ||
|
||
# Check that this is the main repository. | ||
if [[ "${TRAVIS_BRANCH}" != master ]]; then | ||
_exit "Skipping deploy; Not a master branch build." 0 | ||
fi | ||
|
||
## Start of release process | ||
|
||
# Set the NPM access token we will use to publish. | ||
npm config set registry https://registry.npmjs.org/ | ||
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} | ||
|
||
# Set the GitHub deploy key we will use to publish. | ||
set-up-ssh --key "$encrypted_50be70a02dcf_key" \ | ||
--iv "$encrypted_50be70a02dcf_iv" \ | ||
--path-encrypted-key ".travis/github_deploy_key.enc" | ||
|
||
# Change from HTTPS to SSH. | ||
./.travis/fix_github_https_repo.sh | ||
|
||
# Test the GitHub deploy key. | ||
git ls-remote | ||
|
||
# Determine the details of the suffixes NPM tags | ||
if [[ "${BUILD_RELEASE}" == "unstable" ]]; then | ||
|
||
# Set the prerelease version. | ||
npm run pkgstamp | ||
|
||
TAG="unstable" | ||
elif [[ "${BUILD_RELEASE}" == "stable" ]]; then | ||
TAG="latest" | ||
else | ||
_exit "Unknown build focus" 1 | ||
fi | ||
|
||
# Hold onto the version number | ||
export VERSION=$(node -e "console.log(require('${DIR}/package.json').version)") | ||
|
||
# Publish with tag | ||
echo "Pushing with tag ${TAG}" | ||
lerna exec -- npm publish --tag="${TAG}" 2>&1 | ||
|
||
# Check that all required modules have been published to npm and are retrievable | ||
for j in ${NPM_MODULES}; do | ||
# check the next in the list | ||
while ! npm view ${j}@${VERSION} | grep dist-tags > /dev/null 2>&1; do | ||
sleep 10 | ||
done | ||
done | ||
|
||
## Stable releases only; both latest and next then clean up git, and bump version number | ||
if [[ "${BUILD_RELEASE}" = "stable" ]]; then | ||
|
||
# Configure the Git repository and clean any untracked and unignored build files. | ||
git config user.name "${GH_USER_NAME}" | ||
git config user.email "${GH_USER_EMAIL}" | ||
git checkout -b master | ||
git reset --hard | ||
git clean -d -f | ||
|
||
# Bump the version number. | ||
npm run pkgbump | ||
export NEW_VERSION=$(node -e "console.log(require('${DIR}/package.json').version)") | ||
|
||
# Add the version number changes and push them to Git. | ||
git add . | ||
git commit -m "Automatic version bump to ${NEW_VERSION}" | ||
git push origin master | ||
|
||
fi | ||
|
||
_exit "All complete" 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#/bin/bash | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password | ||
|
||
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'` | ||
if [ -z "$REPO_URL" ]; then | ||
echo "-- ERROR: Could not identify Repo url." | ||
echo " It is possible this repo is already using SSH instead of HTTPS." | ||
exit | ||
fi | ||
|
||
USER=`echo $REPO_URL | sed -Ene's#https://github.com/([^/]*)/(.*).git#\1#p'` | ||
if [ -z "$USER" ]; then | ||
echo "-- ERROR: Could not identify User." | ||
exit | ||
fi | ||
|
||
REPO=`echo $REPO_URL | sed -Ene's#https://github.com/([^/]*)/(.*).git#\2#p'` | ||
if [ -z "$REPO" ]; then | ||
echo "-- ERROR: Could not identify Repo." | ||
exit | ||
fi | ||
|
||
NEW_URL="[email protected]:$USER/$REPO.git" | ||
echo "Changing repo url from " | ||
echo " '$REPO_URL'" | ||
echo " to " | ||
echo " '$NEW_URL'" | ||
echo "" | ||
|
||
CHANGE_CMD="git remote set-url origin $NEW_URL" | ||
`$CHANGE_CMD` | ||
|
||
echo "Success" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.