Skip to content
Snippets Groups Projects
Commit 9e2eff7d authored by Bartek Wrona's avatar Bartek Wrona
Browse files

1. Introduced `npm_process_built_package_tarball` base to allow reusing package.tgz unpack code.

2. Added definition of `.registry_npmjs_org_deploy_package_template` job.
parent 42baa907
No related branches found
No related tags found
1 merge request!49Implemented common version of bump_npm_version.sh script ( based on work being...
...@@ -56,7 +56,7 @@ variables: ...@@ -56,7 +56,7 @@ variables:
when: always when: always
expire_in: 1 week expire_in: 1 week
.npm_test_template: .npm_process_built_package_tarball:
extends: .npm_based_job_base extends: .npm_based_job_base
variables: variables:
# Path pointing the source directory containing a package.json file - it can be overrided by derived job # Path pointing the source directory containing a package.json file - it can be overrided by derived job
...@@ -64,11 +64,22 @@ variables: ...@@ -64,11 +64,22 @@ variables:
# Path to the built package tarball - it should be overrided by derived job # Path to the built package tarball - it should be overrided by derived job
PACKAGE_TGZ_PATH: "" PACKAGE_TGZ_PATH: ""
script: before_script:
- !reference [.npm_based_job_base, before_script]
- echo -e "\e[0Ksection_start:$(date +%s):package_tgz_unpack[collapsed=true]\r\e[0KAttempting to unpack ${PACKAGE_TGZ_PATH}" - echo -e "\e[0Ksection_start:$(date +%s):package_tgz_unpack[collapsed=true]\r\e[0KAttempting to unpack ${PACKAGE_TGZ_PATH}"
- cd "${CI_PROJECT_DIR}" - cd "${CI_PROJECT_DIR}"
- tar -xf "${PACKAGE_TGZ_PATH}" -C "${SOURCE_DIR}" --strip-components=1 - tar -xf "${PACKAGE_TGZ_PATH}" -C "${SOURCE_DIR}" --strip-components=1
- echo -e "\e[0Ksection_end:$(date +%s):package_tgz_unpack\r\e[0K" - echo -e "\e[0Ksection_end:$(date +%s):package_tgz_unpack\r\e[0K"
.npm_test_template:
extends: .npm_process_built_package_tarball
variables:
# Path pointing the source directory containing a package.json file - it can be overrided by derived job
SOURCE_DIR: "${CI_PROJECT_DIR}"
# Path to the built package tarball - it should be overrided by derived job
PACKAGE_TGZ_PATH: ""
script:
- echo -e "\e[0Ksection_start:$(date +%s):testing[collapsed=false]\r\e[0KAttempting to start tests..." - echo -e "\e[0Ksection_start:$(date +%s):testing[collapsed=false]\r\e[0KAttempting to start tests..."
- cd "${SOURCE_DIR}" - cd "${SOURCE_DIR}"
- npm run test - npm run test
...@@ -88,7 +99,7 @@ variables: ...@@ -88,7 +99,7 @@ variables:
# Base definition for NPM package publishing job. # Base definition for NPM package publishing job.
# The derived job, should have in its dependencies a final job performing a npm-build (derived from `.npm_build_template`) # The derived job, should have in its dependencies a final job performing a npm-build (derived from `.npm_build_template`)
.npm_deploy_package_template: .npm_deploy_package_template:
extends: .npm_based_job_base extends: .npm_process_built_package_tarball
variables: variables:
# The directory containing sources to be built - it can be overrided by derived job # The directory containing sources to be built - it can be overrided by derived job
SOURCE_DIR: "${CI_PROJECT_DIR}" SOURCE_DIR: "${CI_PROJECT_DIR}"
...@@ -100,10 +111,32 @@ variables: ...@@ -100,10 +111,32 @@ variables:
NPM_PUBLISH_TOKEN: "${CI_JOB_TOKEN}" NPM_PUBLISH_TOKEN: "${CI_JOB_TOKEN}"
script: script:
- echo -e "\e[0Ksection_start:$(date +%s):package_tgz_unpack[collapsed=true]\r\e[0KAttempting to unpack ${PACKAGE_TGZ_PATH}"
- cd "${CI_PROJECT_DIR}"
- tar -xf "${PACKAGE_TGZ_PATH}" -C "${SOURCE_DIR}" --strip-components=1
- echo -e "\e[0Ksection_end:$(date +%s):package_tgz_unpack\r\e[0K"
- echo -e "\e[0Ksection_start:$(date +%s):publishing[collapsed=false]\r\e[0KAttempting to publish a package..." - echo -e "\e[0Ksection_start:$(date +%s):publishing[collapsed=false]\r\e[0KAttempting to publish a package..."
- /home/emscripten/scripts/npm_publish.sh "${SOURCE_DIR}" "${NPM_REGISTRY_URL}" "${NPM_PACKAGE_SCOPE}" "${NPM_PUBLISH_TOKEN}" - /home/emscripten/scripts/npm_publish.sh "${SOURCE_DIR}" "${NPM_REGISTRY_URL}" "${NPM_PACKAGE_SCOPE}" "${NPM_PUBLISH_TOKEN}"
- echo -e "\e[0Ksection_end:$(date +%s):publishing\r\e[0K" - echo -e "\e[0Ksection_end:$(date +%s):publishing\r\e[0KDone"
# Base definition for NPM package publishing job to the registry.npmjs.org.
# The derived job, should have in its dependencies a final job performing a npm-build (derived from `.npm_build_template`)
.registry_npmjs_org_deploy_package_template:
extends: .npm_process_built_package_tarball
variables:
# The directory containing sources to be built - it can be overrided by derived job
SOURCE_DIR: "${CI_PROJECT_DIR}"
# Target package name - it should be overrided by derived job
NPM_PACKAGE_NAME: ""
# Path to the built package tarball - it should be overrided by derived job
PACKAGE_TGZ_PATH: ""
# registry.npmjs.org authentication token - it should be overrided by derived job
NPM_PUBLISH_TOKEN: ""
script:
# project version info must be regenerated accoring to correct target registry, package scope and name
- "/home/emscripten/scripts/npm_generate_version.sh" "${SOURCE_DIR}" "registry.npmjs.org/" "@hiveio" "${NPM_PACKAGE_NAME}"
- echo -e "\e[0Ksection_start:$(date +%s):publishing[collapsed=false]\r\e[0KAttempting to publish a package to registry.npmjs.org..."
- /home/emscripten/scripts/npm_publish.sh "${SOURCE_DIR}" "registry.npmjs.org/" "@hiveio" "${NPM_PUBLISH_TOKEN}"
- echo -e "\e[0Ksection_end:$(date +%s):publishing\r\e[0KDone"
rules:
- if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
when: manual
allow_failure: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment