From 81eff4fcdd8fe8501cb5db82fc3e56cc8b312d5f Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 14 Sep 2021 11:16:43 +0200 Subject: [PATCH] improve pipeline --- .gitlab-ci.yml | 72 ++++++++++++++++++++++++++++++++++++++++++------- README.md | 2 +- gulpfile.js | 3 +-- src/system.json | 2 +- 4 files changed, 65 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f311ec09..8695b06b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,17 +8,17 @@ image: node:lts stages: - test - build + - publish - release -before_script: - - yarn install --immutable - cache: &global_cache paths: - .yarn/cache lint: stage: test + before_script: + - yarn install --immutable script: - yarn lint cache: @@ -26,6 +26,8 @@ lint: test: stage: test + before_script: + - yarn install --immutable script: - yarn test:ci cache: @@ -41,12 +43,13 @@ reuse: image: name: fsfe/reuse:latest entrypoint: [""] - before_script: [] script: - reuse lint build: stage: build + before_script: + - yarn install --immutable script: - yarn build - mv dist ds4 @@ -57,6 +60,20 @@ build: - ds4 expire_in: 1 week +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]+$/' + .release-template: &release-template stage: release before_script: @@ -77,14 +94,12 @@ build: git add package.json src/system.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 ci-processing:${CI_BUILD_REF_NAME} -o ci.skip git push origin ${RELEASE_VERSION} - only: - - master - when: manual + rules: + - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH" + when: manual release-patch: variables: @@ -100,3 +115,40 @@ release-major: variables: RELEASE_TYPE: major <<: *release-template + +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 diff --git a/README.md b/README.md index 8980467a..281189a6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ To install and use the Dungeonslayers 4 system for Foundry Virtual Tabletop, simply paste the following URL into the **Install System** dialog on the Setup menu of the application. -https://git.f3l.de/dungeonslayers/ds4/-/raw/latest/src/system.json?inline=false +https://git.f3l.de/api/v4/projects/dungeonslayers%2Fds4/packages/generic/ds4/latest/system.json ## Development diff --git a/gulpfile.js b/gulpfile.js index 0d576100..192a85c2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,8 +23,7 @@ const stylesDirectory = path.join(sourceDirectory, "scss"); const stylesExtension = ".scss"; const sourceFileExtension = ".ts"; const staticFiles = ["assets", "fonts", "lang", "packs", "templates", "system.json", "template.json"]; -const getDownloadURL = (version) => - `https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/${version}/download?job=build`; +const getDownloadURL = (version) => `https://git.f3l.de/dungeonslayers/ds4/-/releases/${version}/downloads/ds4.zip`; /********************/ /* BUILD */ diff --git a/src/system.json b/src/system.json index 98a42c5f..390452f8 100644 --- a/src/system.json +++ b/src/system.json @@ -91,7 +91,7 @@ "gridUnits": "m", "primaryTokenAttribute": "combatValues.hitPoints", "url": "https://git.f3l.de/dungeonslayers/ds4", - "manifest": "https://git.f3l.de/dungeonslayers/ds4/-/raw/latest/src/system.json?inline=false", + "manifest": "https://git.f3l.de/api/v4/projects/dungeonslayers%2Fds4/packages/generic/ds4/latest/system.json", "download": "https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/1.4.0/download?job=build", "license": "https://git.f3l.de/dungeonslayers/ds4#licensing", "initiative": "@combatValues.initiative.total",