[AAE-11259] Pipeline - Decoupling the build from release (#7935)

* Decoupling the build from release

* test if we are still able to release on npm and docker

* Split docker tag from deploy

* Fix storybook

* Decouple build lib/apps from releasing

* Remove useless or
This commit is contained in:
Maurizio Vitale 2022-11-02 11:31:54 +00:00 committed by GitHub
parent b48784a04e
commit 1c46bb83a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 87 additions and 77 deletions

View File

@ -22,6 +22,7 @@ env:
- S3_DBP_PATH="s3://alfresco-travis-builds/adf" - S3_DBP_PATH="s3://alfresco-travis-builds/adf"
- DEMO_SHELL_DIR="./dist/demo-shell" - DEMO_SHELL_DIR="./dist/demo-shell"
- STORYBOOK_DIR="./dist/storybook/stories"
- BUILT_LIBS_DIR="./dist/libs" - BUILT_LIBS_DIR="./dist/libs"
- NODE_MODULES_DIR="./node_modules" - NODE_MODULES_DIR="./node_modules"
- SMART_RUNNER_DIRECTORY=".protractor-smartrunner" - SMART_RUNNER_DIRECTORY=".protractor-smartrunner"
@ -49,8 +50,6 @@ branches:
- /^develop(-patch.*)?$/ - /^develop(-patch.*)?$/
- master - master
- develop - develop
#remove after upgrade
- angular-14-rebase
- /.*old-env.*/ - /.*old-env.*/
- /.*next-release.*/ - /.*next-release.*/
- /.*beta.*/ - /.*beta.*/
@ -66,6 +65,8 @@ stages:
if: (branch = develop AND (type = cron || type = api)) OR commit_message =~ /\[trigger adf\]/ if: (branch = develop AND (type = cron || type = api)) OR commit_message =~ /\[trigger adf\]/
- name: "Build Demo shell" - name: "Build Demo shell"
if: tag IS blank if: tag IS blank
- name: "Release"
if: type = push OR type = cron || type = api
- name: "Unit test Lib" - name: "Unit test Lib"
if: type = pull_request || (type = cron || type = api) if: type = pull_request || (type = cron || type = api)
- name: "e2e Test" - name: "e2e Test"
@ -104,12 +105,10 @@ jobs:
- "$NODE_MODULES_DIR" - "$NODE_MODULES_DIR"
use: node_modules_cache use: node_modules_cache
# Run Only for any PR
- stage: "Build lib" - stage: "Build lib"
name: "Lib::Build" name: "Lib::Build"
script: script:
- ./scripts/travis/build/build-libs.sh || travis_terminate 1 - nx affected:build $NX_CALCULATION_FLAGS --prod --exclude="demoshell"
- ./scripts/travis/release/release-npm.sh || travis_terminate 1
workspaces: workspaces:
create: create:
name: built_libs_cache name: built_libs_cache
@ -125,19 +124,19 @@ jobs:
use: node_modules_cache use: node_modules_cache
- stage: "Build Demo shell" - stage: "Build Demo shell"
name: "Demo Shell & Storybook :Build && dockerize" name: "Demo Shell & Storybook :Build"
before_script: before_script:
- NODE_OPTIONS="--max-old-space-size=8192" $(npm bin)/nx run cli:build --prod - NODE_OPTIONS="--max-old-space-size=8192" $(npm bin)/nx run cli:build --prod
script: script:
# Build Demo shell & Storybook for production docker" # Build Demo shell & Storybook for production docker"
- NODE_OPTIONS=--max_old_space_size=8192 nx build demoshell --configuration production - NODE_OPTIONS=--max_old_space_size=8192 nx build demoshell --configuration production
- NODE_OPTIONS=--max_old_space_size=8192 nx run stories:build-storybook --configuration ci - NODE_OPTIONS=--max_old_space_size=8192 nx run stories:build-storybook --configuration ci
- ./scripts/travis/release/release-docker.sh
workspaces: workspaces:
create: create:
name: built_demo_shell_cache name: built_demo_shell_cache
paths: paths:
- "$DEMO_SHELL_DIR" - "$DEMO_SHELL_DIR"
- "$STORYBOOK_DIR"
use: use:
- built_libs_cache - built_libs_cache
@ -171,6 +170,22 @@ jobs:
workspaces: workspaces:
use: built_libs_cache use: built_libs_cache
- stage: "Release"
name: "release::npm"
script:
- ./scripts/travis/release/prepublish.sh || travis_terminate 1
- ./scripts/travis/release/release-npm.sh || travis_terminate 1
workspaces:
use: built_libs_cache
- stage: "Release"
name: "release::docker"
script:
- ./scripts/travis/release/docker-tag.sh
- ./scripts/travis/release/release-docker.sh
workspaces:
use: built_demo_shell_cache
- stage: "Release tag" - stage: "Release tag"
script: ./scripts/travis/release/git-tag.sh script: ./scripts/travis/release/git-tag.sh

View File

@ -19,7 +19,6 @@
"01": "echo -------------------------------------------- Build Lib -----------------------------------------------", "01": "echo -------------------------------------------- Build Lib -----------------------------------------------",
"01s": "", "01s": "",
"unit-test": "concurrently \"nx test content-services --watch=false\" \"nx test process-services --watch=false\" \"nx test core --watch=false\" \"nx test extensions --watch=false\" \"nx test insights --watch=false\" \"nx test process-services-cloud --watch=false\" ", "unit-test": "concurrently \"nx test content-services --watch=false\" \"nx test process-services --watch=false\" \"nx test core --watch=false\" \"nx test extensions --watch=false\" \"nx test insights --watch=false\" \"nx test process-services-cloud --watch=false\" ",
"build-lib": "./scripts/build/build-all-lib.sh",
"affected:libs": "nx affected:libs", "affected:libs": "nx affected:libs",
"inspect.bundle": "nx build demoshell --configuration production --stats-json && npx webpack-bundle-analyzer dist/demo-shell/stats.json", "inspect.bundle": "nx build demoshell --configuration production --stats-json && npx webpack-bundle-analyzer dist/demo-shell/stats.json",
"coverage": "./lib/config/create-coverage-index.sh && lite-server -c ./lib/config/proxy-coverage.json", "coverage": "./lib/config/create-coverage-index.sh && lite-server -c ./lib/config/proxy-coverage.json",

View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../
if [[ $TRAVIS_BRANCH =~ ^master(-patch.*)?$ ]]; then
export TAGS=$(grep -m1 version package.json | awk '{ print $2 }' | sed 's/[", ]//g')
else
if [[ "${TRAVIS_PULL_REQUEST_BRANCH}" != "" ]];
then
export TAGS=""$TRAVIS_PULL_REQUEST_BRANCH-$TRAVIS_BUILD_NUMBER""
else
export TAGS="$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER,$TRAVIS_BRANCH"
fi;
fi;

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../
if [[ $TRAVIS_BRANCH =~ ^develop(-patch.*)?$ ]]
then
isSameADFSha=$(node ./scripts/travis/update/adf-same-commit-verify.js --token=$TOKEN --head=$BRANCH_TO_CREATE --repo=$NAME_REPO --commit=$COMMIT )
if [ "$isSameADFSha" = 'true' ]; then
echo 'ADF sha is the same. No need to publish again on NPM'
else
echo "Replace NPM version with new Alpha tag"
NEXT_VERSION=-nextalpha
./scripts/update-version.sh -gnu $NEXT_VERSION || exit 1;
fi
fi
node ./scripts/pre-publish.js
echo "====== Prebuilt Themes ====="
nx affected $NX_CALCULATION_FLAGS --target=pretheme

View File

@ -1,54 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../
echo " demo-shell: Running the docker with tag" $TAGS
DOCKER_PROJECT_ARGS="PROJECT_NAME=demo-shell"
# Publish Image to docker
./node_modules/@alfresco/adf-cli/bin/adf-cli docker --loginCheck --loginUsername "$DOCKER_REPOSITORY_USER" --loginPassword "$DOCKER_REPOSITORY_PASSWORD" --loginRepo "$DOCKER_REPOSITORY_DOMAIN" --dockerRepo "$DOCKER_REPOSITORY" --buildArgs "$DOCKER_PROJECT_ARGS" --dockerTags "$TAGS" --pathProject "$(pwd)"
echo " storybook-shell: Running the docker with tag" $TAGS
DOCKER_PROJECT_ARGS="PROJECT_NAME=storybook/stories"
echo "{}" > $DIR/../../../dist/storybook/stories/app.config.json
# Publish Image to docker
./node_modules/@alfresco/adf-cli/bin/adf-cli docker --loginCheck --loginUsername "$DOCKER_REPOSITORY_USER" --loginPassword "$DOCKER_REPOSITORY_PASSWORD" --loginRepo "$DOCKER_REPOSITORY_DOMAIN" --dockerRepo "$DOCKER_REPOSITORY_STORYBOOK" --buildArgs "$DOCKER_PROJECT_ARGS" --dockerTags "$TAGS" --pathProject "$(pwd)"
if [[ $TRAVIS_EVENT_TYPE == "pull_request" ]];
then
HEAD_COMMIT_HASH=${TRAVIS_PULL_REQUEST_SHA:-${TRAVIS_COMMIT}}
COMMIT_MESSAGE=`git log --format=%B -n 1 $HEAD_COMMIT_HASH`
fi;
echo " Check Docker Image release for $COMMIT_MESSAGE type $TRAVIS_EVENT_TYPE on branch $TRAVIS_PULL_REQUEST_BRANCH"
if [[ $TRAVIS_EVENT_TYPE == "push" || $TRAVIS_EVENT_TYPE == "cron" || ( $TRAVIS_EVENT_TYPE == "pull_request" && $COMMIT_MESSAGE == *"[create docker image]"* )]];
then
if [[ $TRAVIS_BRANCH =~ ^develop(-patch.*)?$ || $TRAVIS_BRANCH =~ ^master(-patch.*)?$ ]];
then
cd $DIR/../../../
if [[ $TRAVIS_BRANCH =~ ^master(-patch.*)?$ ]]; then
TAGS=$(grep -m1 version package.json | awk '{ print $2 }' | sed 's/[", ]//g')
else
if [[ "${TRAVIS_PULL_REQUEST_BRANCH}" != "" ]];
then
TAGS=""$TRAVIS_PULL_REQUEST_BRANCH-$TRAVIS_BUILD_NUMBER""
else
TAGS="$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER,$TRAVIS_BRANCH"
fi;
fi;
echo " demo-shell: Running the docker with tag" $TAGS
DOCKER_PROJECT_ARGS="PROJECT_NAME=demo-shell"
# Publish Image to docker
./node_modules/@alfresco/adf-cli/bin/adf-cli docker --loginCheck --loginUsername "$DOCKER_REPOSITORY_USER" --loginPassword "$DOCKER_REPOSITORY_PASSWORD" --loginRepo "$DOCKER_REPOSITORY_DOMAIN" --dockerRepo "$DOCKER_REPOSITORY" --buildArgs "$DOCKER_PROJECT_ARGS" --dockerTags "$TAGS" --pathProject "$(pwd)"
echo " storybook-shell: Running the docker with tag" $TAGS
DOCKER_PROJECT_ARGS="PROJECT_NAME=storybook/stories"
echo "{}" > $DIR/../../../dist/storybook/stories/app.config.json
# Publish Image to docker
./node_modules/@alfresco/adf-cli/bin/adf-cli docker --loginCheck --loginUsername "$DOCKER_REPOSITORY_USER" --loginPassword "$DOCKER_REPOSITORY_PASSWORD" --loginRepo "$DOCKER_REPOSITORY_DOMAIN" --dockerRepo "$DOCKER_REPOSITORY_STORYBOOK" --buildArgs "$DOCKER_PROJECT_ARGS" --dockerTags "$TAGS" --pathProject "$(pwd)"
fi;
else
echo "✅ No need to release a docker image"
fi;

View File

@ -4,26 +4,15 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../ cd $DIR/../../../
if [[ $TRAVIS_EVENT_TYPE == "push" ]] || [[ $TRAVIS_EVENT_TYPE == "cron" ]] || [[ $TRAVIS_EVENT_TYPE == "api" ]] if [[ $TRAVIS_BRANCH =~ ^master(-patch.*)?$ ]]
then then
TAG_NPM=latest
fi
if [[ $TRAVIS_BRANCH =~ ^master(-patch.*)?$ ]] if [[ $TRAVIS_BRANCH =~ ^develop(-patch.*)?$ ]]
then then
TAG_NPM=latest TAG_NPM=alpha
fi fi
if [[ $TRAVIS_BRANCH =~ ^develop(-patch.*)?$ ]] echo "Publishing on npm with tag $TAG_NPM"
then ./node_modules/@alfresco/adf-cli/bin/adf-cli npm-publish --npmRegistry $NPM_REGISTRY_ADDRESS --tokenRegistry $NPM_REGISTRY_TOKEN --tag $TAG_NPM --pathProject "$(pwd)"
TAG_NPM=alpha
fi
if [[ $TRAVIS_BRANCH =~ angular-14-rebase ]]
then
TAG_NPM=a14
fi
echo "Publishing on npm with tag $TAG_NPM"
./node_modules/@alfresco/adf-cli/bin/adf-cli npm-publish --npmRegistry $NPM_REGISTRY_ADDRESS --tokenRegistry $NPM_REGISTRY_TOKEN --tag $TAG_NPM --pathProject "$(pwd)"
else
echo "PR No need to release in NPM"
fi;