Skip to content

Commit

Permalink
Publish script added (#517)
Browse files Browse the repository at this point in the history
Publish script added

---------

Co-authored-by: Gangadhar <[email protected]>
  • Loading branch information
froala-travis-bot and Gangadhar authored May 8, 2023
1 parent bcef4ff commit 7bacead
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
script:
- chmod u+x push-image-to-nexus.sh && bash push-image-to-nexus.sh
- chmod u+x deploy_sdk.sh && bash deploy_sdk.sh
- chmod u+x publish-npm.sh && bash publish-npm.sh

notifications:
email:
recipients:
Expand Down
44 changes: 44 additions & 0 deletions publish-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

#
# Publish to Nexus NPM repository if it's not a pull request
#

if [ ${TRAVIS_PULL_REQUEST} != "false" ]; then echo "Not publishing a pull request !!!" && exit 0; fi

npm config set strict-ssl false
npm install -g npm-cli-login
npm-cli-login --scope @froala-org -u ${NEXUS_USER} -p ${NEXUS_USER_PWD} -e dummy-email@[email protected] -r ${NEXUS_URL}/repository/Froala-npm

echo "seting up nexus as default registry to publish ..."
npm-cli-login -u ${NEXUS_USER} -p ${NEXUS_USER_PWD} -e dummy-email@[email protected] -r ${NEXUS_URL}/repository/Froala-npm

jq '.publishConfig |= . + {"registry": "https://nexus.tools.froala-infra.com/repository/Froala-npm/" }' package.json > new.file && cat new.file > package.json && rm -f new.file

PACKAGE_NAME=`jq '.name' version.json | tr -d '"'`
PACKAGE_VERSION=`jq '.version' version.json | tr -d '"'`
echo "Package name : ${PACKAGE_NAME}"

jq --arg froalaeditor "file:${PACKAGE_NAME}-${PACKAGE_VERSION}.tgz" '.dependencies["froala-editor"] |= $froalaeditor' package.json > new.file && cat new.file > package.json && rm -f new.file
jq --arg froalaeditor "file:${PACKAGE_NAME}-${PACKAGE_VERSION}.tgz" '.dependencies["froala-editor"] |= $froalaeditor' projects/library/package.json > new.file && cat new.file > projects/library/package.json && rm -f new.file

echo " Angular demo package.json file: " && cat projects/library/package.json

export DEFAULT_NAME=`cat package.json | jq '.name '`
export DEFAULT_NAME=`sed -e 's/^"//' -e 's/"$//' <<<"$DEFAULT_NAME"`
echo ${DEFAULT_NAME}
export ANGULAR_EDITOR_NAME=${DEFAULT_NAME}-${TRAVIS_BRANCH}
jq --arg newval "$ANGULAR_EDITOR_NAME" '.name |= $newval' projects/library/package.json > tmp.json && mv tmp.json projects/library/package.json

wget --no-check-certificate --user ${NEXUS_USER} --password ${NEXUS_USER_PWD} https://nexus.tools.froala-infra.com/repository/Froala-npm/${PACKAGE_NAME}/-/${PACKAGE_NAME}-${PACKAGE_VERSION}.tgz

npm install
npm run build
cd dist
jq --arg newval "$ANGULAR_EDITOR_NAME" '.name |= $newval' projects/library/package.json > tmp.json && mv tmp.json projects/library/package.json
# set nexus npm repo
jq '.publishConfig |= . + {"registry": "https://nexus.tools.froala-infra.com/repository/Froala-npm/" }' package.json > new.file && cat new.file > package.json && rm -f new.file

npm publish

echo "Published ${ANGULAR_EDITOR_NAME} to nexus "
echo "Please create/verify branch update ${TRAVIS_BRANCH} for https://github.com/froala/ionic-froala-demo-mcs/blob/devops/version.json and update version.json with ${ANGULAR_EDITOR_NAME} and version "

0 comments on commit 7bacead

Please sign in to comment.