2021-06-26 22:02:00 +02:00
# SPDX-FileCopyrightText: 2021 Johannes Loher
# SPDX-FileCopyrightText: 2021 Oliver Rümpelein
#
# SPDX-License-Identifier: MIT
2021-02-11 11:19:33 +01:00
image : node:lts
2020-12-23 18:36:41 +01:00
stages :
2020-12-27 13:33:53 +01:00
- test
- build
2021-09-14 11:16:43 +02:00
- publish
2021-01-09 18:20:23 +01:00
- release
2020-12-23 18:36:41 +01:00
2020-12-27 14:03:14 +01:00
cache : &global_cache
2020-12-23 20:23:44 +01:00
paths :
2021-02-11 12:43:52 +01:00
- .yarn/cache
2020-12-27 14:03:14 +01:00
2020-12-27 13:33:53 +01:00
lint :
stage : test
2021-09-14 11:16:43 +02:00
before_script :
- yarn install --immutable
2020-12-23 20:15:28 +01:00
script :
2021-02-11 12:34:01 +01:00
- yarn lint
2020-12-27 14:03:14 +01:00
cache :
<< : *global_cache
2020-12-27 13:33:53 +01:00
2020-12-30 21:30:31 +01:00
test :
stage : test
2021-09-14 11:16:43 +02:00
before_script :
- yarn install --immutable
2020-12-30 21:30:31 +01:00
script :
2021-02-11 12:34:01 +01:00
- yarn test:ci
2020-12-30 21:31:35 +01:00
cache :
<< : *global_cache
2020-12-30 22:37:34 +01:00
artifacts :
when : always
reports :
junit :
2021-02-11 13:42:38 +01:00
- junit.xml
2020-12-27 13:33:53 +01:00
2021-06-27 00:01:53 +02:00
reuse :
stage : test
image :
name : fsfe/reuse:latest
entrypoint : [ "" ]
script :
- reuse lint
2020-12-27 13:33:53 +01:00
build :
stage : build
2021-09-14 11:16:43 +02:00
before_script :
- yarn install --immutable
2020-12-27 13:33:53 +01:00
script :
2021-02-11 12:34:01 +01:00
- yarn build
2021-01-06 00:59:22 +01:00
- mv dist ds4
2020-12-27 14:03:14 +01:00
cache :
<< : *global_cache
2020-12-27 15:19:20 +01:00
artifacts :
paths :
2021-01-06 00:59:22 +01:00
- ds4
2020-12-27 16:43:20 +01:00
expire_in : 1 week
2020-12-27 16:38:16 +01:00
2021-09-14 11:16:43 +02:00
publish-artifacts :
image : alpine:latest
stage : publish
before_script :
- apk update
- apk add zip curl
script : |
zip -r ds4.zip ds4/*
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ds4.zip "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ds4/$CI_COMMIT_TAG/ds4.zip"
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ds4/system.json "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ds4/$CI_COMMIT_TAG/system.json"
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ds4/system.json "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ds4/latest/system.json"
rules :
- if : '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
2021-01-09 18:47:20 +01:00
.release-template : &release-template
2021-01-09 18:20:23 +01:00
stage : release
before_script :
2021-02-11 12:34:01 +01:00
- yarn install
2021-01-09 18:20:23 +01:00
- apt update
2021-01-09 18:23:56 +01:00
- apt install --yes jq
2021-01-09 19:01:22 +01:00
- 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
2021-01-09 18:20:23 +01:00
cache :
<< : *global_cache
script : |
2021-03-17 12:15:25 +01:00
yarn bump-version --release=${RELEASE_TYPE}
2021-01-09 18:20:23 +01:00
RELEASE_VERSION=$(jq -r '.version' < package.json)
2021-02-21 05:57:27 +01:00
git add package.json src/system.json
2021-01-09 18:34:30 +01:00
git --no-pager diff
2021-01-09 18:47:20 +01:00
git commit -m "release version ${RELEASE_VERSION}"
2021-01-09 18:29:30 +01:00
git tag -f ${RELEASE_VERSION}
2021-09-14 11:16:43 +02:00
git push origin ci-processing:${CI_BUILD_REF_NAME} -o ci.skip
2021-01-09 18:49:05 +01:00
git push origin ${RELEASE_VERSION}
2021-09-14 11:16:43 +02:00
rules :
- if : "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
when : manual
2021-01-09 18:47:20 +01:00
release-patch :
variables :
RELEASE_TYPE : patch
<< : *release-template
release-minor :
variables :
2021-01-09 18:55:53 +01:00
RELEASE_TYPE : minor
2021-01-09 18:47:20 +01:00
<< : *release-template
release-major :
variables :
2021-01-09 18:55:53 +01:00
RELEASE_TYPE : major
2021-01-09 18:47:20 +01:00
<< : *release-template
2021-09-14 11:16:43 +02:00
bump-latest-tag :
stage : release
image : alpine:latest
before_script :
- apk update
- apk add git
- 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
script : |
git tag -f latest -m "This tag is only being kept for backwards compatibility. To install the DS4 system, please use the following manifest URL instead: https://git.f3l.de/api/v4/projects/dungeonslayers%2Fds4/packages/generic/ds4/latest/system.json"
git push origin latest -f -o ci.skip
rules :
- if : '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
release :
stage : release
image : registry.gitlab.com/gitlab-org/release-cli:latest
script :
- echo 'release job'
rules :
- if : '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
release :
tag_name : $CI_COMMIT_TAG
description : "# Changelog"
assets :
links :
- name : "ds4.zip"
url : "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ds4/$CI_COMMIT_TAG/ds4.zip"
filepath : /ds4.zip
link_type : package
- name : "system.json"
url : "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ds4/$CI_COMMIT_TAG/system.json"
filepath : /system.json
link_type : other