mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[AAE-11496] Publish libraries to npm (#2880)
* [AAE-11496] Publish libraries to npm registry * update * update * added md * deprecate old version
This commit is contained in:
parent
87c1c2b5df
commit
a8268c680a
@ -35,6 +35,8 @@ stages:
|
|||||||
if: branch = master AND type = push
|
if: branch = master AND type = push
|
||||||
- name: e2e
|
- name: e2e
|
||||||
if: type = cron || type = pull_request
|
if: type = cron || type = pull_request
|
||||||
|
- name: Release Libraries
|
||||||
|
if: type = push
|
||||||
- name: Trigger DW
|
- name: Trigger DW
|
||||||
if: branch = develop AND (type = cron OR (type = api AND commit_message =~ /\[trigger aca\]/))
|
if: branch = develop AND (type = cron OR (type = api AND commit_message =~ /\[trigger aca\]/))
|
||||||
|
|
||||||
@ -190,6 +192,13 @@ jobs:
|
|||||||
name: Release Tag
|
name: Release Tag
|
||||||
script: ./scripts/travis/release/git-tag.sh
|
script: ./scripts/travis/release/git-tag.sh
|
||||||
|
|
||||||
|
- stage: Release Libraries
|
||||||
|
name: Release Libraries
|
||||||
|
script:
|
||||||
|
- npm ci
|
||||||
|
- ./scripts/ci/npm/publish-libs.sh
|
||||||
|
cache: false
|
||||||
|
|
||||||
- name: Publish to Dockerhub
|
- name: Publish to Dockerhub
|
||||||
script: ./scripts/travis/deploy/publish.sh "content-ce" "$DOCKER_HUB_REPOSITORY_DOMAIN" "$DOCKER_HUB_USERNAME" "$DOCKER_HUB_PASSWORD"
|
script: ./scripts/travis/deploy/publish.sh "content-ce" "$DOCKER_HUB_REPOSITORY_DOMAIN" "$DOCKER_HUB_USERNAME" "$DOCKER_HUB_PASSWORD"
|
||||||
|
|
||||||
|
@ -430,7 +430,8 @@
|
|||||||
"production": {
|
"production": {
|
||||||
"tsConfig": "projects/aca-shared/tsconfig.lib.prod.json"
|
"tsConfig": "projects/aca-shared/tsconfig.lib.prod.json"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"defaultConfiguration": "production"
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"builder": "@angular-devkit/build-angular:karma",
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
37
docs/extending/publish-to-npm.md
Normal file
37
docs/extending/publish-to-npm.md
Normal file
@ -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
|
@ -14,6 +14,7 @@
|
|||||||
"prebuild": "mkdir -p ./app/.tmp && cp ./app/src/app.config.json.tpl ./app/.tmp/app.config.json",
|
"prebuild": "mkdir -p ./app/.tmp && cp ./app/src/app.config.json.tpl ./app/.tmp/app.config.json",
|
||||||
"build": "ng build content-ce",
|
"build": "ng build content-ce",
|
||||||
"build.release": "npm run build -- --configuration=production,release",
|
"build.release": "npm run build -- --configuration=production,release",
|
||||||
|
"build-libs": "ng build aca-shared",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"test:ci": "ng test adf-office-services-ext && ng test content-ce --code-coverage",
|
"test:ci": "ng test adf-office-services-ext && ng test content-ce --code-coverage",
|
||||||
"lint": "NODE_OPTIONS=--max_old_space_size=4096 ng lint && npm run spellcheck && npm run e2e.typecheck",
|
"lint": "NODE_OPTIONS=--max_old_space_size=4096 ng lint && npm run spellcheck && npm run e2e.typecheck",
|
||||||
|
83
scripts/ci/npm/publish-libs.sh
Executable file
83
scripts/ci/npm/publish-libs.sh
Executable file
@ -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
|
Loading…
x
Reference in New Issue
Block a user