You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
YAML
46 lines
1.4 KiB
YAML
---
|
|
# You need to setup some CI/CD variables
|
|
# I recommend to set it on Group to make things easier
|
|
# see https://docs.gitlab.com/ee/ci/examples/semantic-release.html#set-up-cicd-variables
|
|
|
|
.caching_node: &caching_node
|
|
cache:
|
|
key: semantic-release-cache
|
|
paths:
|
|
- node_modules/
|
|
|
|
semantic-release-with-npm:
|
|
image: node:lts
|
|
stage: review
|
|
variables:
|
|
NPM_TOKEN: "${CI_JOB_TOKEN}"
|
|
before_script:
|
|
- npm run build --if-present
|
|
- yarn add semantic-release @semantic-release/git @semantic-release/gitlab @semantic-release/npm @semantic-release/changelog semantic-release-cli
|
|
- |
|
|
cat <<-EOF >> .releaserc.yml
|
|
branches:
|
|
- $CI_COMMIT_BRANCH
|
|
plugins:
|
|
- "@semantic-release/commit-analyzer"
|
|
- "@semantic-release/release-notes-generator"
|
|
- "@semantic-release/changelog"
|
|
- "@semantic-release/gitlab"
|
|
- "@semantic-release/npm"
|
|
- "@semantic-release/git"
|
|
EOF
|
|
- |
|
|
{
|
|
echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/"
|
|
echo "${CI_API_V4_URL#https?}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=\${CI_JOB_TOKEN}"
|
|
} | tee -a .npmrc
|
|
script:
|
|
- yarn run semantic-release
|
|
rules:
|
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
|
exists:
|
|
- package.json
|
|
when: always
|
|
- when: never
|
|
<<: *caching_node
|