68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
image: node:22
|
|
|
|
stages:
|
|
- test
|
|
- publish
|
|
|
|
cache:
|
|
# The cache is shared for same values of cache key
|
|
# Here, we use CI_PIPELINE_ID which is defined as:
|
|
# "The instance-level ID of the current pipeline. This ID is unique across all projects on the GitLab instance."
|
|
# This should ensure that we only cache the "node_modules" folder for this given pipeline instance.
|
|
# Refer to this docs to know more about the predefined variables used in the key here: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
|
|
key: $CI_PIPELINE_ID
|
|
# configure the path to be cached
|
|
paths:
|
|
- node_modules/
|
|
|
|
before_script:
|
|
- npm install
|
|
- npm run build
|
|
|
|
test:
|
|
stage: test
|
|
script:
|
|
# Run tests
|
|
- npm run test
|
|
# Ensure no circular dependencies
|
|
- npm run madge
|
|
|
|
publish:development:
|
|
stage: publish
|
|
# Configure what tag to use for this publication.
|
|
variables:
|
|
NPM_TAG: 'development'
|
|
GITLAB_USER_EMAIL: 'ci@stack.xo.cash'
|
|
GITLAB_USER_NAME: 'CI - Stack'
|
|
script:
|
|
# Setup git config
|
|
- git config --global user.email "${GITLAB_USER_EMAIL}"
|
|
- git config --global user.name "${GITLAB_USER_NAME}"
|
|
|
|
# Configure git to push with CI token
|
|
- git remote set-url origin "https://oauth2:${CI_JOB_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"
|
|
|
|
# Setup npm authentication
|
|
- |
|
|
echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=https://gitlab.com/api/v4/packages/npm/" > .npmrc
|
|
echo "//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
|
|
echo "//gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
|
|
|
|
# Skip git checks when versioning and publishing
|
|
- npx lerna version patch --yes --force-publish --no-git-reset
|
|
- npx lerna publish from-git --yes --no-git-reset
|
|
only:
|
|
- development
|
|
|
|
# Publish the documentation to GitLab Pages (for now).
|
|
pages:
|
|
stage: publish
|
|
script:
|
|
- npm run docs:build
|
|
- mv packages/docs/dist public
|
|
artifacts:
|
|
paths:
|
|
- public
|
|
only:
|
|
- development
|