This repository has been archived on 2023-06-20. You can view files and clone it, but cannot push or open issues or pull requests.
risk-dice-modifier/.gitlab-ci.yml

89 lines
2 KiB
YAML

# SPDX-FileCopyrightText: 2021 Johannes Loher <johannes.loher@fg4f.de>
#
# SPDX-License-Identifier: MIT
image: node:lts
stages:
- test
- build
- release
before_script:
- yarn install --immutable
cache: &global_cache
paths:
- .yarn/cache
lint:
stage: test
script:
- yarn lint
cache:
<<: *global_cache
license-validation:
stage: test
image:
name: fsfe/reuse:latest
entrypoint: [""]
before_script: []
script:
- reuse lint
build:
stage: build
script:
- yarn build
- mv dist risk-dice-modifier
cache:
<<: *global_cache
artifacts:
paths:
- risk-dice-modifier
expire_in: 1 week
.release-template: &release-template
stage: release
before_script:
- yarn install
- apt update
- apt install --yes jq
- REPOSITORY_URL=$(echo "${CI_REPOSITORY_URL}" | sed -e "s|gitlab-ci-token:.*@|${RELEASE_TOKEN}:${RELEASE_TOKEN_SECRET}@|g")
- git remote set-url origin $REPOSITORY_URL
- git config user.name $GITLAB_USER_LOGIN
- git config user.email $GITLAB_USER_EMAIL
- git branch -D ci-processing || true
- git checkout -b ci-processing
cache:
<<: *global_cache
script: |
yarn bump-version --release=${RELEASE_TYPE}
RELEASE_VERSION=$(jq -r '.version' < package.json)
git add package.json src/module.json
git --no-pager diff
git commit -m "release version ${RELEASE_VERSION}"
git tag -f latest
git tag -f ${RELEASE_VERSION}
git push origin ci-processing:${CI_BUILD_REF_NAME}
git push origin latest -f
git push origin ${RELEASE_VERSION}
only:
- master
when: manual
release-patch:
variables:
RELEASE_TYPE: patch
<<: *release-template
release-minor:
variables:
RELEASE_TYPE: minor
<<: *release-template
release-major:
variables:
RELEASE_TYPE: major
<<: *release-template