2022-05-16 02:08:27 +02:00
|
|
|
# SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
# SPDX-FileCopyrightText: 2021 Oliver Rümpelein
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2022-11-28 01:04:49 +01:00
|
|
|
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
|
2022-05-16 02:08:27 +02:00
|
|
|
|
|
|
|
variables:
|
|
|
|
PACKAGE_NAME: tickwerk
|
|
|
|
PACKAGE_TYPE: module
|
|
|
|
PACKAGE_REGISTRY_URL: $CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/$PACKAGE_NAME
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- check
|
|
|
|
- build
|
|
|
|
- prepare-release
|
|
|
|
- release
|
|
|
|
- publish
|
|
|
|
|
2022-11-28 01:04:49 +01:00
|
|
|
image: node:lts
|
|
|
|
|
2022-05-16 02:08:27 +02:00
|
|
|
cache: &global_cache
|
|
|
|
paths:
|
|
|
|
- .yarn/cache
|
|
|
|
|
|
|
|
lint:
|
|
|
|
stage: check
|
|
|
|
before_script:
|
|
|
|
- yarn install --immutable
|
|
|
|
script:
|
|
|
|
- yarn lint
|
|
|
|
cache:
|
|
|
|
<<: *global_cache
|
|
|
|
|
|
|
|
reuse:
|
|
|
|
stage: check
|
|
|
|
image:
|
|
|
|
name: fsfe/reuse:latest
|
|
|
|
entrypoint: ['']
|
|
|
|
script:
|
|
|
|
- reuse lint
|
|
|
|
|
2022-11-28 01:04:49 +01:00
|
|
|
commitlint:
|
|
|
|
stage: check
|
|
|
|
before_script:
|
|
|
|
- yarn install --immutable
|
|
|
|
script:
|
|
|
|
- yarn run commitlint --from $CI_MERGE_REQUEST_DIFF_BASE_SHA
|
|
|
|
rules:
|
|
|
|
- if: "$CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_DIFF_BASE_SHA"
|
|
|
|
|
2022-05-16 02:08:27 +02:00
|
|
|
build:
|
|
|
|
stage: build
|
|
|
|
before_script:
|
|
|
|
- yarn install --immutable
|
|
|
|
- if [[ ! -z ${CI_COMMIT_TAG+x} ]]; then export NODE_ENV=production; fi
|
|
|
|
script:
|
|
|
|
- yarn build
|
|
|
|
cache:
|
|
|
|
<<: *global_cache
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- dist
|
|
|
|
expire_in: 1 week
|
|
|
|
|
|
|
|
publish-artifacts:
|
|
|
|
stage: prepare-release
|
|
|
|
image: alpine:latest
|
|
|
|
before_script:
|
|
|
|
- apk update
|
|
|
|
- apk add zip curl
|
|
|
|
script: |
|
|
|
|
cd dist
|
|
|
|
zip -r ../$PACKAGE_TYPE.zip .
|
|
|
|
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"
|
|
|
|
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
|
|
|
|
|
|
|
|
changelog:
|
|
|
|
stage: prepare-release
|
|
|
|
before_script:
|
|
|
|
- yarn install --immutable
|
|
|
|
script:
|
|
|
|
- yarn changelog
|
|
|
|
cache:
|
|
|
|
<<: *global_cache
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- CHANGELOG.md
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
|
|
|
|
|
|
|
|
.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 module.json
|
|
|
|
git --no-pager diff
|
|
|
|
git commit -m "chore(release): ${RELEASE_VERSION}"
|
|
|
|
git tag -f ${RELEASE_VERSION}
|
|
|
|
git push origin ci-processing:${CI_BUILD_REF_NAME} -o ci.skip
|
|
|
|
git push origin ${RELEASE_VERSION}
|
|
|
|
only:
|
|
|
|
- main
|
|
|
|
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
|
|
|
|
|
|
|
|
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.md'
|
|
|
|
assets:
|
|
|
|
links:
|
|
|
|
- name: '$PACKAGE_TYPE.zip'
|
|
|
|
url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.zip'
|
|
|
|
filepath: /$PACKAGE_TYPE.zip
|
|
|
|
link_type: package
|
|
|
|
- name: '$PACKAGE_TYPE.json'
|
|
|
|
url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.json'
|
|
|
|
filepath: /$PACKAGE_TYPE.json
|
|
|
|
link_type: other
|
|
|
|
|
|
|
|
publish-latest-manifest:
|
|
|
|
stage: publish
|
|
|
|
image: alpine:latest
|
|
|
|
before_script:
|
|
|
|
- apk update
|
|
|
|
- apk add zip curl
|
|
|
|
script: |
|
|
|
|
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file dist/$PACKAGE_TYPE.json "$PACKAGE_REGISTRY_URL/latest/$PACKAGE_TYPE.json"
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
|
|
|
|
# publish-to-foundry-admin:
|
|
|
|
# stage: publish
|
|
|
|
# image: johannesloher/foundry-publish
|
|
|
|
# variables:
|
|
|
|
# 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"
|
|
|
|
# script: foundry-publish
|
|
|
|
# rules:
|
|
|
|
# - if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
|