-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add ci to publish npm package (#909)
* chore: add ci to publish npm package * chore(snapshot): 15.1.3-snapshot.0 * chore: dep audit * chore(snapshot): 15.1.3-snapshot.1 * chore: audit * chore(snapshot): 15.1.3-snapshot.2 * chore: address comments * chore: address comments * chore: npmignore
- Loading branch information
Showing
6 changed files
with
321 additions
and
934 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,10 @@ version: 2.1 | |
# Orbs used in this pipeline | ||
## | ||
orbs: | ||
anchore: anchore/[email protected] | ||
slack: circleci/[email protected] # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates | ||
pr-tools: mojaloop/[email protected] # Ref: https://github.com/mojaloop/ci-config/ | ||
gh: circleci/[email protected] | ||
anchore: anchore/[email protected] | ||
deploy-kube: mojaloop/[email protected] | ||
|
||
## | ||
# defaults | ||
|
@@ -38,6 +37,17 @@ defaults_license_scanner: &defaults_license_scanner | |
git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner | ||
cd /tmp/license-scanner && make build default-files set-up | ||
defaults_npm_auth: &defaults_npm_auth | ||
name: Update NPM registry auth token | ||
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc | ||
|
||
defaults_npm_publish_release: &defaults_npm_publish_release | ||
name: Publish NPM $RELEASE_TAG artifact | ||
command: | | ||
source $BASH_ENV | ||
echo "Publishing tag $RELEASE_TAG" | ||
npm publish --tag $RELEASE_TAG --access public | ||
defaults_export_version_from_package: &defaults_export_version_from_package | ||
name: Format the changelog into the github release body and get release tag | ||
command: | | ||
|
@@ -181,16 +191,6 @@ jobs: | |
prefix: test | ||
- store_test_results: | ||
path: coverage | ||
- run: | ||
name: Copy code coverage to SonarQube | ||
command: | | ||
if [ "${CIRCLE_BRANCH}" == "master" ]; | ||
then | ||
echo "Sending lcov.info to SonarQube..." | ||
aws s3 cp coverage/lcov.info $AWS_S3_DIR_SONARQUBE/${CIRCLE_PROJECT_REPONAME}/lcov.info | ||
else | ||
echo "Not a release (env CIRCLE_BRANCH != 'master'), skipping sending lcov.info to SonarQube." | ||
fi | ||
|
||
test-integration: | ||
executor: default-machine | ||
|
@@ -207,17 +207,17 @@ jobs: | |
name: Build and start the docker containers | ||
command: | | ||
## This is not needed as we are only doing narrow-integration tests. | ||
# docker-compose build | ||
# docker-compose build | ||
## Lets pull only the Services needed for the Integration Test | ||
docker-compose pull mysql kafka | ||
## Lets startup only the Services needed for the Integration Test | ||
docker-compose up -d mysql kafka | ||
## Check straight away to see if any containers have exited | ||
docker-compose ps | ||
## wait for services to be up and running | ||
npm run wait-4-docker | ||
- run: | ||
|
@@ -226,7 +226,7 @@ jobs: | |
npm rebuild | ||
npm run test:int | ||
environment: | ||
ENDPOINT_URL: http://localhost:4545/notification | ||
ENDPOINT_URL: http://localhost:4545/notification | ||
- store_artifacts: | ||
path: ./test/results | ||
prefix: test | ||
|
@@ -499,7 +499,7 @@ jobs: | |
event: fail | ||
template: SLACK_TEMP_RELEASE_FAILURE | ||
|
||
publish: | ||
publish-docker: | ||
executor: default-machine | ||
steps: | ||
- checkout | ||
|
@@ -524,7 +524,7 @@ jobs: | |
at: /tmp | ||
- run: | ||
name: Load the pre-built docker image from workspace | ||
command: | | ||
command: | | ||
docker load -i /tmp/docker-image.tar | ||
- run: | ||
name: Login to Docker Hub | ||
|
@@ -557,7 +557,7 @@ jobs: | |
event: fail | ||
template: SLACK_TEMP_RELEASE_FAILURE | ||
|
||
publish-snapshot: | ||
publish-docker-snapshot: | ||
executor: default-machine | ||
steps: | ||
- checkout | ||
|
@@ -582,7 +582,7 @@ jobs: | |
at: /tmp | ||
- run: | ||
name: Load the pre-built docker image from workspace | ||
command: | | ||
command: | | ||
docker load -i /tmp/docker-image.tar | ||
- run: | ||
name: Login to Docker Hub | ||
|
@@ -615,6 +615,82 @@ jobs: | |
event: fail | ||
template: SLACK_TEMP_RELEASE_FAILURE | ||
|
||
publish-npm: | ||
executor: default-docker | ||
steps: | ||
- run: | ||
name: Install general dependencies | ||
command: *defaults_Dependencies | ||
- checkout | ||
- restore_cache: | ||
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }} | ||
- run: | ||
name: Setup for LATEST release | ||
command: | | ||
echo "export RELEASE_TAG=$RELEASE_TAG_PROD" >> $BASH_ENV | ||
echo "RELEASE_TAG=$RELEASE_TAG_PROD" | ||
PACKAGE_VERSION=$(cat package-lock.json | jq -r .version) | ||
echo "export PACKAGE_VERSION=${PACKAGE_VERSION}" >> $BASH_ENV | ||
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" | ||
- run: | ||
name: Setup Slack config | ||
command: | | ||
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV | ||
echo "export SLACK_RELEASE_TYPE='NPM Release'" >> $BASH_ENV | ||
echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV | ||
echo "export SLACK_RELEASE_URL=https://www.npmjs.com/package/@mojaloop/${CIRCLE_PROJECT_REPONAME}/v/${CIRCLE_TAG:1}" >> $BASH_ENV | ||
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV | ||
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV | ||
- run: | ||
<<: *defaults_npm_auth | ||
- run: | ||
<<: *defaults_npm_publish_release | ||
- slack/notify: | ||
event: pass | ||
template: SLACK_TEMP_RELEASE_SUCCESS | ||
- slack/notify: | ||
event: fail | ||
template: SLACK_TEMP_RELEASE_FAILURE | ||
|
||
publish-npm-snapshot: | ||
executor: default-docker | ||
steps: | ||
- run: | ||
name: Install general dependencies | ||
command: *defaults_Dependencies | ||
- checkout | ||
- restore_cache: | ||
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }} | ||
- run: | ||
name: Setup for SNAPSHOT release | ||
command: | | ||
echo "export RELEASE_TAG=${RELEASE_TAG_SNAPSHOT}" >> $BASH_ENV | ||
echo "RELEASE_TAG=${RELEASE_TAG_SNAPSHOT}" | ||
echo "Override package version: ${CIRCLE_TAG:1}" | ||
npx standard-version --skip.tag --skip.commit --skip.changelog --release-as ${CIRCLE_TAG:1} | ||
PACKAGE_VERSION=$(cat package-lock.json | jq -r .version) | ||
echo "export PACKAGE_VERSION=${PACKAGE_VERSION}" >> $BASH_ENV | ||
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" | ||
- run: | ||
name: Setup Slack config | ||
command: | | ||
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV | ||
echo "export SLACK_RELEASE_TYPE='NPM Snapshot'" >> $BASH_ENV | ||
echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV | ||
echo "export SLACK_RELEASE_URL=https://www.npmjs.com/package/@mojaloop/${CIRCLE_PROJECT_REPONAME}/v/${CIRCLE_TAG:1}" >> $BASH_ENV | ||
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV | ||
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV | ||
- run: | ||
<<: *defaults_npm_auth | ||
- run: | ||
<<: *defaults_npm_publish_release | ||
- slack/notify: | ||
event: pass | ||
template: SLACK_TEMP_RELEASE_SUCCESS | ||
- slack/notify: | ||
event: fail | ||
template: SLACK_TEMP_RELEASE_FAILURE | ||
|
||
## | ||
# Workflows | ||
# | ||
|
@@ -803,7 +879,49 @@ workflows: | |
only: | ||
- master | ||
- /release\/v.*/ | ||
- publish: | ||
- publish-docker: | ||
context: org-global | ||
requires: | ||
- pr-tools/pr-title-check | ||
- test-dependencies | ||
- test-lint | ||
- test-unit | ||
- build | ||
- test-coverage | ||
- test-integration | ||
- test-functional | ||
- vulnerability-check | ||
- audit-licenses | ||
- license-scan | ||
- image-scan | ||
filters: | ||
tags: | ||
only: /v[0-9]+(\.[0-9]+)*/ | ||
branches: | ||
ignore: | ||
- /.*/ | ||
- publish-docker-snapshot: | ||
context: org-global | ||
requires: | ||
- pr-tools/pr-title-check | ||
- test-dependencies | ||
- test-lint | ||
- test-unit | ||
- build | ||
- test-coverage | ||
- test-integration | ||
- test-functional | ||
- vulnerability-check | ||
- audit-licenses | ||
- license-scan | ||
- image-scan | ||
filters: | ||
tags: | ||
only: /v[0-9]+(\.[0-9]+)*\-snapshot+((\.[0-9]+)?)/ | ||
branches: | ||
ignore: | ||
- /.*/ | ||
- publish-npm: | ||
context: org-global | ||
requires: | ||
- pr-tools/pr-title-check | ||
|
@@ -823,7 +941,7 @@ workflows: | |
branches: | ||
ignore: | ||
- /.*/ | ||
- publish-snapshot: | ||
- publish-npm-snapshot: | ||
context: org-global | ||
requires: | ||
- pr-tools/pr-title-check | ||
|
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 |
---|---|---|
|
@@ -63,3 +63,4 @@ devspace* | |
# Add ignores | ||
*IGNORE* | ||
*ignore* | ||
!.npmignore |
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,3 @@ | ||
# Ignore tests for publishing | ||
test/* | ||
.circleci/* |
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.