image: node:10.16 stages: - install-deps - build - pre-publish - publish install-deps: stage: install-deps script: - npm install artifacts: paths: - node_modules/ cache: key: ${CI_COMMIT_REF_SLUG} paths: - node_modules/ only: - merge_requests - master except: variables: - $CI_COMMIT_MESSAGE =~ /^(chore\(release\):)/ build: stage: build script: - npm run build dependencies: - install-deps artifacts: paths: - dist/ only: - merge_requests - master except: variables: - $CI_COMMIT_MESSAGE =~ /^(chore\(release\):)/ verify-commit: stage: pre-publish script: - bash -f ./scripts/verify-commit.sh only: - master except: variables: - $CI_COMMIT_MESSAGE =~ /^(chore\(release\):)/ git-publish: stage: publish except: variables: - $CI_COMMIT_MESSAGE =~ /^(chore\(release\):)/ before_script: - git config --local user.name "gitlab runner" - git config --local user.email "gitlab@nomail" script: # Reset tags, since workers are keeping garbage tags - git tag -l | xargs git tag -d - git fetch --prune --tags # Reset branches, since workers are keeping garbage branches - git checkout origin/master - git branch | grep -v -E '^\*' | xargs -r git branch -D # Create local master branch and track origin/master - git checkout master # Cut a release - npx standard-version --infile docs/CHANGELOG.md - git remote set-url origin https://gitlab-ci-token:${GL_TOKEN}@git.trendcapital.io/johnny/semver-sandbox.git - git push --follow-tags only: - master npm-publish: stage: publish only: refs: - master variables: - $CI_COMMIT_MESSAGE =~ /^(chore\(release\):)/ before_script: - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc script: - npm publish