ds4/.gitlab-ci.yml

198 lines
5.1 KiB
YAML
Raw Normal View History

2021-06-26 22:02:00 +02:00
# SPDX-FileCopyrightText: 2021 Johannes Loher
# SPDX-FileCopyrightText: 2021 Oliver Rümpelein
#
# SPDX-License-Identifier: MIT
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
2020-12-23 18:36:41 +01:00
2022-05-23 07:02:50 +02:00
variables:
PACKAGE_NAME: ds4
PACKAGE_TYPE: system
PACKAGE_REGISTRY_URL: $CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/$PACKAGE_NAME
2020-12-23 18:36:41 +01:00
stages:
2022-02-13 19:41:47 +01:00
- check
2020-12-27 13:33:53 +01:00
- build
2021-09-17 19:46:36 +02:00
- prepare-release
2021-01-09 18:20:23 +01:00
- release
2021-09-17 19:46:36 +02:00
- publish
2020-12-23 18:36:41 +01:00
image: node:lts
cache: &global_cache
2023-03-23 00:47:54 +01:00
key:
files:
- pnpm-lock.yaml
2020-12-23 20:23:44 +01:00
paths:
2023-03-23 00:47:54 +01:00
- .pnpm-store
2023-03-23 00:47:54 +01:00
.pnpm_install: &pnpm_install
- corepack enable
- corepack prepare pnpm@latest --activate
- pnpm config set store-dir .pnpm-store
- pnpm install --frozen-lockfile
.pnpm_job: &pnpm_job
2021-09-14 11:16:43 +02:00
before_script:
2023-03-23 00:47:54 +01:00
- *pnpm_install
cache:
<<: *global_cache
2020-12-27 13:33:53 +01:00
2023-03-23 00:47:54 +01:00
lint:
stage: check
<<: *pnpm_job
script:
- pnpm lint
2022-02-13 19:41:47 +01:00
typecheck:
stage: check
2023-03-23 00:47:54 +01:00
<<: *pnpm_job
2022-02-13 19:41:47 +01:00
script:
2023-03-23 00:47:54 +01:00
- pnpm typecheck
2022-02-13 19:41:47 +01:00
2020-12-30 21:30:31 +01:00
test:
2022-02-13 19:41:47 +01:00
stage: check
2023-03-23 00:47:54 +01:00
<<: *pnpm_job
2020-12-30 21:30:31 +01:00
script:
2023-03-23 00:47:54 +01:00
- pnpm test:ci
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:
2022-02-13 19:41:47 +01:00
stage: check
2021-06-27 00:01:53 +02:00
image:
name: fsfe/reuse:latest
entrypoint: [""]
script:
- reuse lint
commitlint:
stage: check
2023-03-23 00:47:54 +01:00
<<: *pnpm_job
script:
2023-03-23 00:47:54 +01:00
- pnpm exec commitlint --from $CI_MERGE_REQUEST_DIFF_BASE_SHA
rules:
- if: "$CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_DIFF_BASE_SHA"
2020-12-27 13:33:53 +01:00
build:
stage: build
2023-03-23 00:47:54 +01:00
<<: *pnpm_job
2021-09-14 11:16:43 +02:00
before_script:
2023-03-23 00:47:54 +01:00
- *pnpm_install
- if [[ ! -z ${CI_COMMIT_TAG+x} ]]; then export NODE_ENV=production; fi
2020-12-27 13:33:53 +01:00
script:
2023-03-23 00:47:54 +01:00
- pnpm build
2020-12-27 15:19:20 +01:00
artifacts:
paths:
2022-05-23 07:02:50 +02:00
- dist
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:
2021-09-17 19:46:36 +02:00
stage: prepare-release
2021-09-14 11:16:43 +02:00
image: alpine:latest
before_script:
- apk update
- apk add zip curl
script: |
2022-05-23 07:02:50 +02:00
cd dist
zip -r ../$PACKAGE_TYPE.zip .
2022-05-23 07:02:50 +02:00
cd ..
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file $PACKAGE_TYPE.zip "$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.zip"
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file dist/$PACKAGE_TYPE.json "$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.json"
2021-09-14 11:16:43 +02:00
rules:
2022-05-23 07:02:50 +02:00
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
2021-09-14 11:16:43 +02:00
2021-09-14 17:10:23 +02:00
changelog:
2021-09-17 19:46:36 +02:00
stage: prepare-release
2023-03-23 00:47:54 +01:00
<<: *pnpm_job
2021-09-14 17:10:23 +02:00
script:
2023-03-23 00:47:54 +01:00
- pnpm changelog
2021-09-14 17:10:23 +02:00
artifacts:
paths:
- CHANGELOG.md
rules:
2022-05-23 07:02:50 +02:00
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
2021-09-14 17:10:23 +02:00
2021-01-09 18:47:20 +01:00
.release-template: &release-template
2021-01-09 18:20:23 +01:00
stage: release
2023-03-23 00:47:54 +01:00
<<: *pnpm_job
2021-01-09 18:20:23 +01:00
before_script:
2023-03-23 00:47:54 +01:00
- *pnpm_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
script: |
2023-03-23 00:47:54 +01:00
pnpm bump-version --release=${RELEASE_TYPE}
2021-01-09 18:20:23 +01:00
RELEASE_VERSION=$(jq -r '.version' < package.json)
2022-05-23 07:02:50 +02:00
git add package.json $PACKAGE_TYPE.json
2021-01-09 18:34:30 +01:00
git --no-pager diff
git commit -m "chore(release): ${RELEASE_VERSION}"
2022-05-23 07:02:50 +02:00
git tag -f v${RELEASE_VERSION}
2021-09-14 11:16:43 +02:00
git push origin ci-processing:${CI_BUILD_REF_NAME} -o ci.skip
git push origin v${RELEASE_VERSION}
2021-09-14 16:57:53 +02:00
only:
2022-05-23 07:02:50 +02:00
- main
2021-09-14 16:57:53 +02:00
when: manual
2021-01-09 18:47:20 +01:00
release-patch:
variables:
RELEASE_TYPE: patch
<<: *release-template
release-minor:
variables:
RELEASE_TYPE: minor
2021-01-09 18:47:20 +01:00
<<: *release-template
release-major:
variables:
RELEASE_TYPE: major
2021-01-09 18:47:20 +01:00
<<: *release-template
2021-09-14 11:16:43 +02:00
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo 'release job'
rules:
2022-05-23 07:02:50 +02:00
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
2021-09-14 11:16:43 +02:00
release:
name: ${CI_COMMIT_TAG:1}
2021-09-14 11:16:43 +02:00
tag_name: $CI_COMMIT_TAG
2021-09-14 17:10:23 +02:00
description: "./CHANGELOG.md"
2021-09-14 11:16:43 +02:00
assets:
links:
2022-05-23 07:02:50 +02:00
- name: "$PACKAGE_TYPE.zip"
url: "$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.zip"
filepath: /$PACKAGE_TYPE.zip
2021-09-14 11:16:43 +02:00
link_type: package
2022-05-23 07:02:50 +02:00
- name: "$PACKAGE_TYPE.json"
url: "$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.json"
filepath: /$PACKAGE_TYPE.json
2021-09-14 11:16:43 +02:00
link_type: other
2021-09-17 19:46:36 +02:00
publish-to-foundry-admin:
stage: publish
image: johannesloher/foundry-publish
variables:
2022-05-23 07:02:50 +02:00
FVTT_MANIFEST_PATH: dist/$PACKAGE_TYPE.json
FVTT_MANIFEST_URL: ${CI_PROJECT_URL}/-/releases/${CI_COMMIT_TAG}/downloads/$PACKAGE_TYPE.json
FVTT_DELETE_OBSOLETE_VERSIONS: "true"
2021-09-17 19:46:36 +02:00
script: foundry-publish
rules:
2022-05-23 07:02:50 +02:00
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'