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: 'GitLab CI' 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://gitlab-ci-token:$GL_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" # Checkout the development branch so that we're not on a detached HEAD (which GitLab CI will default to). - git checkout development # Setup npm config for npmjs.com - npm config set registry https://registry.npmjs.org/ - npm config set //registry.npmjs.org/:_authToken ${NPM_AUTH_TOKEN} # Version and publish - npx lerna publish --yes --canary --preid ${NPM_TAG} --dist-tag ${NPM_TAG} only: - development # TODO: Document the Lerna Recursive problem when we run lerna version on our main branch. # NOTE: The "lerna version" command will create a new commit and push it to our main branch. # This can create a problem where our CI on the "main" branch is recursively triggered. # To prevent this, we add [ci skip] to our Lerna Version commit message. # This is supported OOTB by GitLab (and GitHub). # See: https://docs.gitlab.com/ee/ci/pipelines/#skip-a-pipeline # 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