-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [AAE-11496] Publish libraries to npm registry * update * update * added md * deprecate old version
- Loading branch information
Showing
5 changed files
with
132 additions
and
1 deletion.
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,37 @@ | ||
--- | ||
Title: Publish to npm | ||
--- | ||
|
||
# Create a new library | ||
|
||
New library can be created using standard `ng` command | ||
|
||
e.g. if we would like to create `aca-new-lib` we need to run the following: | ||
|
||
``` | ||
ng generate @schematics/angular:library aca-new-lib | ||
``` | ||
|
||
# Publish library | ||
|
||
## Build library | ||
In order to publish new library, we need to build it first. You need to add build of your library to `build-libs` command in `package.json` | ||
|
||
``` | ||
"build-libs": "ng build aca-shared && ng build aca-new-lib", | ||
``` | ||
|
||
## Update publish script | ||
If we would like to publish the new library we need to update `scripts/ci/npm/publish-libs.sh` | ||
|
||
The only thing that need to be done is to update `PROJECTS` variable by adding your library name i.e. | ||
|
||
``` | ||
PROJECTS=( | ||
'aca-shared', | ||
'aca-new-lib' | ||
); | ||
``` | ||
# Caveats | ||
- The versions of libraries are updated automatically by the script (should not be done manually) | ||
- In travis setting you can find `PUBLISH_PROJECTS` variable, which can be used for enabling dry mode when running the publish command |
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,83 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
ROOT_DIR=${DIR}/../../.. | ||
DIST_DIR=${ROOT_DIR}/dist/@alfresco | ||
PROJECTS_DIR=${ROOT_DIR}/projects | ||
|
||
DRY_RUN="" | ||
if [ "$PUBLISH_PROJECTS" = "false" ]; then | ||
DRY_RUN=true | ||
echo "PUBLISH_PROJECTS is set to false, run in dry mode" | ||
fi | ||
|
||
VERSION_IN_PACKAGE_JSON=`node -p "require('$ROOT_DIR/package.json')".version;`; | ||
|
||
if [[ $TRAVIS_BRANCH =~ ^master.*?$ ]] ; then | ||
NEW_LIBRARY_VERSION=VERSION_IN_PACKAGE_JSON | ||
else | ||
NEW_LIBRARY_VERSION="${VERSION_IN_PACKAGE_JSON}-${TRAVIS_BUILD_NUMBER}" | ||
fi | ||
|
||
if [[ $TRAVIS_BRANCH =~ ^master(-patch.*)?$ ]] | ||
then | ||
# Pre-release versions | ||
if [[ $VERSION_IN_PACKAGE_JSON =~ ^[0-9]*\.[0-9]*\.[0-9]*-A\.[0-9]*$ ]]; | ||
then | ||
TAG_NPM=next | ||
# Stable major versions | ||
else | ||
TAG_NPM=latest | ||
fi | ||
fi | ||
|
||
if [[ $TRAVIS_BRANCH =~ ^develop(-patch.*)?$ ]] | ||
then | ||
TAG_NPM=alpha | ||
fi | ||
|
||
echo -e "Branch is '$TRAVIS_BRANCH', therefore publish with '$TAG_NPM' tag\n" | ||
|
||
PROJECTS=( | ||
'aca-shared' | ||
); | ||
|
||
for PROJECT in "${PROJECTS[@]}" | ||
do | ||
echo "Update ${PROJECT} version to ${NEW_LIBRARY_VERSION}" | ||
|
||
cd $PROJECTS_DIR/${PROJECT} | ||
npm version ${NEW_LIBRARY_VERSION}; | ||
done | ||
|
||
echo -e "\n\nBuild projects" | ||
cd ${ROOT_DIR} | ||
|
||
npm run build-libs | ||
|
||
for PROJECT in "${PROJECTS[@]}" | ||
do | ||
cd $DIST_DIR/${PROJECT} | ||
PREVIOUS_LIBRARY_VERSION=$(npm view @alfresco/${PROJECT} version) | ||
|
||
if [ "$DRY_RUN" = "true" ] ; then | ||
echo -e "Publish with dry mode for project: $PROJECT\n" | ||
echo -e "npm publish --dry-run --tag $TAG_NPM \n" | ||
|
||
npm publish --dry-run --tag $TAG_NPM | ||
|
||
echo -e "Deprecating old version of @alfresco/$PROJECT the old version is $PREVIOUS_LIBRARY_VERSION\n" | ||
|
||
echo "npm deprecate @alfresco/$PROJECT@$PREVIOUS_LIBRARY_VERSION 'Upgrade to @latest or $NEW_LIBRARY_VERSION'" | ||
else | ||
echo -e "Publish $PROJECT\n" | ||
echo -e "npm publish --tag $TAG_NPM\n" | ||
|
||
echo 'strict-ssl=false' >> .npmrc | ||
echo 'registry=http://${NPM_REGISTRY_ADDRESS}' >> .npmrc | ||
echo '//${NPM_REGISTRY_ADDRESS}/:_authToken="${NPM_REGISTRY_TOKEN}"' >> .npmrc | ||
|
||
npm publish --tag $TAG_NPM | ||
npm deprecate "@alfresco/$PROJECT@$PREVIOUS_LIBRARY_VERSION" "Upgrade to @latest or $NEW_LIBRARY_VERSION" | ||
fi | ||
done |