From 694641c1da21b8750d2a137324dd35885b715d7d Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 10 Jul 2023 00:00:23 +0200 Subject: [PATCH] ci: switch to gitea + woodpecker --- .gitea/ISSUE_TEMPLATE/bug_report.yaml | 99 ++++++++++ .gitea/ISSUE_TEMPLATE/config.yaml | 5 + .gitea/ISSUE_TEMPLATE/feature_request.yaml | 28 +++ .gitlab-ci.yml | 173 ------------------ .gitlab/issue_templates/Bug Report.md | 48 ----- .gitlab/issue_templates/Bug Report.md.license | 3 - .gitlab/issue_templates/Feature Request.md | 11 -- .../Feature Request.md.license | 3 - .vscode/launch.json | 2 +- .vscode/settings.json | 6 - .woodpecker/checks.yaml | 45 +++++ .woodpecker/publish.yaml | 92 ++++++++++ .woodpecker/release.yaml | 41 +++++ README.md | 8 +- package.json | 2 +- tools/bump-version.js | 42 +++-- 16 files changed, 349 insertions(+), 259 deletions(-) create mode 100644 .gitea/ISSUE_TEMPLATE/bug_report.yaml create mode 100644 .gitea/ISSUE_TEMPLATE/config.yaml create mode 100644 .gitea/ISSUE_TEMPLATE/feature_request.yaml delete mode 100644 .gitlab-ci.yml delete mode 100644 .gitlab/issue_templates/Bug Report.md delete mode 100644 .gitlab/issue_templates/Bug Report.md.license delete mode 100644 .gitlab/issue_templates/Feature Request.md delete mode 100644 .gitlab/issue_templates/Feature Request.md.license create mode 100644 .woodpecker/checks.yaml create mode 100644 .woodpecker/publish.yaml create mode 100644 .woodpecker/release.yaml diff --git a/.gitea/ISSUE_TEMPLATE/bug_report.yaml b/.gitea/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..f2098f7 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,99 @@ +# SPDX-FileCopyrightText: 2023 Johannes Loher +# +# SPDX-License-Identifier: MIT + +name: Bug Report +about: File a bug report +labels: ["bug", "to be confirmed"] +body: + - type: markdown + attributes: + value: | + Your issue may already have been reported! Please search on the [issue tracker](https://git.f3l.de/dungeonslayers/tickwerk/issues) before submitting a new one. + + Thanks for taking the time to fill out this bug report! In order to make it effective, please provide the following information. + - type: markdown + attributes: + value: | + ## Issue Description + - type: textarea + id: expected + attributes: + label: Expected Behavior + description: What is the behavior that you expected? + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: What is the current behavior, i.e., what happens actually? + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to Reproduce + description: What are the steps to reproduce the problem? + placeholder: | + 1. + 2. + 3. + 4. + validations: + required: true + - type: textarea + id: context + attributes: + label: Context + description: Please provide any additional context that might be helpful, e.g. log messages, screenshots, videos, or exports of problematic scenes or worlds. + validations: + required: false + - type: markdown + attributes: + value: | + ## Environment Details + - type: input + id: version + attributes: + label: Version + description: Which version(s) of Tickwerk are you seeing the problem on? + validations: + required: true + - type: input + id: foundry-version + attributes: + label: Foundry VTT Version + description: Which version(s) and build of Foundry VTT are you seeing the problem on? + validations: + required: true + - type: input + id: os + attributes: + label: Operating System + description: Which operating system are you using? (Windows, OS X, Linux (which distro)) + placeholder: Windows + validations: + required: true + - type: dropdown + id: browser + attributes: + label: Browser / App + description: Are you using a Browser or the native Electron application? (Select all that apply) + multiple: true + options: + - Native Electron App + - Chrome + - Firefox + - Microsoft Edge + - Safari + - Other + validations: + required: true + - type: input + id: modules + attributes: + label: Relevant Modules + description: Please list any other active modules (including their versions) that you think might be relevant. + validations: + required: false diff --git a/.gitea/ISSUE_TEMPLATE/config.yaml b/.gitea/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 0000000..f1387a8 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2023 Johannes Loher +# +# SPDX-License-Identifier: MIT + +blank_issues_enabled: false diff --git a/.gitea/ISSUE_TEMPLATE/feature_request.yaml b/.gitea/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..01e7827 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2023 Johannes Loher +# +# SPDX-License-Identifier: MIT + +name: Feature Request +description: Submit a feature request +labels: ["feature"] +body: + - type: markdown + attributes: + value: | + Your issue may already have been reported! Please search on the [issue tracker](https://git.f3l.de/dungeonslayers/tickwerk/issues) before submitting a new one. + + In order to submit an effective feature request, please provide the following information. + - type: textarea + id: description + attributes: + label: Description + description: Please describe the proposal in as much detail as you feel is necessary. + validations: + required: true + - type: textarea + id: context + attributes: + label: Context + description: Is there anything else you can add about the proposal? You might want to link to related issues here if you haven't already. + validations: + required: false diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index e7bfbbb..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,173 +0,0 @@ -# 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 - -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 - -image: node:lts - -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 - -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" - -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]+$/' diff --git a/.gitlab/issue_templates/Bug Report.md b/.gitlab/issue_templates/Bug Report.md deleted file mode 100644 index ce06032..0000000 --- a/.gitlab/issue_templates/Bug Report.md +++ /dev/null @@ -1,48 +0,0 @@ -Your issue may already have been reported! Please search on the issue tracker (https://git.f3l.de/dungeonslayers/tickwerk/-/issues) before submitting a new one. - -Thanks for taking the time to fill out this bug report! In order to make it effective, please provide the following information. - -# Issue Description - -## Expected Behavior - -(What is the behavior that you expected?) - -## Current Behavior - -(What is the current behavior, i.e., what happens actually?) - -## Steps to Reproduce - -(What are the steps to reproduce the problem?) - -1. ... -2. ... -3. ... - -## Context - -(Please provide any additional context that might be helpful, e.g. log messages, -screenshots, videos, or exports of problematic scenes or worlds.) - -# Environment Details - -## Version - -(Which version(s) of Tickwerk are you seeing the problem on?) - -## Foundry VTT Version - -(Which version(s) and build of Foundry VTT are you seeing the problem on?) - -## Operating System - -(Which operating system are you using? (Windows, OS X, Linux (which distro))) - -## Browser / App - -(Are you using a Browser or the native Electron application?) - -## Relevant Modules - -(Please list any active modules (including their versions) that you think might be relevant.) diff --git a/.gitlab/issue_templates/Bug Report.md.license b/.gitlab/issue_templates/Bug Report.md.license deleted file mode 100644 index caa655b..0000000 --- a/.gitlab/issue_templates/Bug Report.md.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2022 Johannes Loher - -SPDX-License-Identifier: MIT \ No newline at end of file diff --git a/.gitlab/issue_templates/Feature Request.md b/.gitlab/issue_templates/Feature Request.md deleted file mode 100644 index d5dac38..0000000 --- a/.gitlab/issue_templates/Feature Request.md +++ /dev/null @@ -1,11 +0,0 @@ -Your issue may already have been reported! Please search on the issue tracker (https://git.f3l.de/dungeonslayers/tickwerk/-/issues) before submitting a new one. - -In order to submit an effective feature request, please provide the following information. - -# Description - -(Please describe the proposal in as much detail as you feel is necessary.) - -# Context - -(Is there anything else you can add about the proposal? You might want to link to related issues here if you haven't already.) diff --git a/.gitlab/issue_templates/Feature Request.md.license b/.gitlab/issue_templates/Feature Request.md.license deleted file mode 100644 index caa655b..0000000 --- a/.gitlab/issue_templates/Feature Request.md.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2022 Johannes Loher - -SPDX-License-Identifier: MIT \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 9371697..52f9e65 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "type": "pwa-chrome", + "type": "chrome", "request": "launch", "runtimeExecutable": "/usr/bin/chromium", "name": "Launch Chrome against localhost", diff --git a/.vscode/settings.json b/.vscode/settings.json index d2cf83e..f2c05aa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,10 +5,4 @@ }, "eslint.nodePath": ".yarn/sdks", "prettier.prettierPath": ".yarn/sdks/prettier/index.js", - "importSorter.generalConfiguration.sortOnBeforeSave": true, - "importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.type": "newLineEachExpressionAfterCountLimitExceptIfOnlyOne", - "importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.count": 120, - "importSorter.importStringConfiguration.tabSize": 2, - "importSorter.importStringConfiguration.quoteMark": "single", - "importSorter.importStringConfiguration.trailingComma": "multiLine" } diff --git a/.woodpecker/checks.yaml b/.woodpecker/checks.yaml new file mode 100644 index 0000000..f823802 --- /dev/null +++ b/.woodpecker/checks.yaml @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: 2023 Johannes Loher +# +# SPDX-License-Identifier: MIT + +$schema: https://raw.githubusercontent.com/woodpecker-ci/woodpecker/master/pipeline/schema/schema.json + +variables: + - &node_image node:lts + +when: + - event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + - event: pull_request + - event: tag + - event: manual + +steps: + install: + image: *node_image + commands: + - yarn install --immutable + lint: + group: check + image: *node_image + commands: + - yarn lint + reuse: + group: check + image: fsfe/reuse:latest + commands: + - reuse lint + commitlint: + group: check + image: *node_image + commands: + - git fetch + - yarn run commitlint --from origin/${CI_COMMIT_TARGET_BRANCH} + when: + event: pull_request + build: + group: build + image: *node_image + commands: + - export APPDATA=$(pwd) + - yarn build diff --git a/.woodpecker/publish.yaml b/.woodpecker/publish.yaml new file mode 100644 index 0000000..b6aaa21 --- /dev/null +++ b/.woodpecker/publish.yaml @@ -0,0 +1,92 @@ +# SPDX-FileCopyrightText: 2023 Johannes Loher +# +# SPDX-License-Identifier: MIT + +$schema: https://raw.githubusercontent.com/woodpecker-ci/woodpecker/master/pipeline/schema/schema.json + +variables: + - &node_image node:lts + +when: + event: tag + evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+(-[0-9]+)?$" + +depends_on: + - checks + +steps: + install: + image: *node_image + commands: + - yarn install --immutable + build: + image: *node_image + environment: + NODE_ENV: production + commands: + - export APPDATA=$(pwd) + - yarn build + package: + group: prepare-release + image: alpine:latest + commands: + - apk update + - apk add zip curl + - mv dist ${CI_REPO_NAME} + - zip -r ${CI_REPO_NAME}.zip ${CI_REPO_NAME}/* + changelog: + group: prepare-release + image: *node_image + commands: + - yarn changelog + choose-latest-channel: + group: prepare-release + image: alpine:latest + commands: + - echo latest > .RELEASE_CHANNEL + when: + evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$" + choose-beta-channel: + group: prepare-release + image: alpine:latest + commands: + - echo beta > .RELEASE_CHANNEL + when: + evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+-[0-9]+$" + release: + image: woodpeckerci/plugin-gitea-release + settings: + base_url: ${CI_FORGE_URL} + title: ${CI_COMMIT_TAG} + note: CHANGELOG.md + files: + - ${CI_REPO_NAME}.zip + - ${CI_REPO_NAME}/module.json + api_key: + from_secret: forge_token + publish-manifest: + group: publish + image: alpine:latest + commands: + - apk update + - apk add curl + - export RELEASE_CHANNEL=$(cat .RELEASE_CHANNEL) + - 'curl --header "Authorization: token $${FORGE_TOKEN}" -X "DELETE" "${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/${CI_REPO_NAME}/$${RELEASE_CHANNEL}/module.json"' + - 'curl --fail --header "Authorization: token $${FORGE_TOKEN}" --upload-file ${CI_REPO_NAME}/module.json "${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/${CI_REPO_NAME}/$${RELEASE_CHANNEL}/module.json"' + secrets: + - forge_token + publish-to-foundry-admin: + group: publish + image: johannesloher/foundry-publish + environment: + FVTT_DELETE_OBSOLETE_VERSIONS: 'true' + commands: + - export FVTT_MANIFEST_PATH=${CI_REPO_NAME}/module.json + - export FVTT_MANIFEST_URL=${CI_REPO_URL}/releases/download/${CI_COMMIT_TAG}/module.json + - foundry-publish + secrets: + - fvtt_package_id + - fvtt_username + - fvtt_password + when: + evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$" diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml new file mode 100644 index 0000000..b260632 --- /dev/null +++ b/.woodpecker/release.yaml @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: 2023 Johannes Loher +# +# SPDX-License-Identifier: MIT + +$schema: https://raw.githubusercontent.com/woodpecker-ci/woodpecker/master/pipeline/schema/schema.json + +variables: + - &node_image node:lts + +when: + event: manual + branch: ${CI_REPO_DEFAULT_BRANCH} + +depends_on: + - checks + +steps: + install: + image: *node_image + commands: + - yarn install --immutable + release: + image: *node_image + commands: + - apt-get update + - apt-get install --yes jq + - export REPOSITORY_URL=$(echo "${CI_REPO_CLONE_URL}" | sed -e "s|://|://$${FORGE_TOKEN_NAME}:$${FORGE_TOKEN}@|g") + - git remote set-url origin $${REPOSITORY_URL} + - git config user.name woodpecker[bot] + - git config user.email woodpecker[bot]@${CI_SYSTEM_HOST} + - yarn bump-version --release=${RELEASE_TYPE} + - export RELEASE_VERSION=$(jq -r '.version' < package.json) + - git --no-pager diff + - git add package.json module.json + - 'git commit -m "chore(release): $${RELEASE_VERSION}"' + - git tag -f $${RELEASE_VERSION} + - git push origin ${CI_COMMIT_BRANCH} + - git push origin $${RELEASE_VERSION} + secrets: + - forge_token_name + - forge_token diff --git a/README.md b/README.md index 447be18..bf24392 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,12 @@ SPDX-License-Identifier: MIT # Tickwerk +[![status-badge](https://ci.f3l.de/api/badges/10/status.svg)](https://ci.f3l.de/repos/10) +[![REUSE status](https://api.reuse.software/badge/git.f3l.de/dungeonslayers/tickwerk)](https://api.reuse.software/info/git.f3l.de/dungeonslayers/tickwerk) +[![Forge installs](https://img.shields.io/badge/dynamic/json?label=Forge%20Installs&query=package.installs&suffix=%25&url=https%3A%2F%2Fforge-vtt.com%2Fapi%2Fbazaar%2Fpackage%2Ftickwerk&colorB=4aa94a)](https://forge-vtt.com/bazaar#package=tickwerk) +[![Supported foundry versions](https://img.shields.io/endpoint?url=https://foundryshields.com/version?url=https%3A%2F%2Fgit.f3l.de%2Fapi%2Fpackages%2Fdungeonslayers%2Fgeneric%2Ftickwerk%2Flatest%module.json)](https://git.f3l.de/dungeonslayers/tickwerk) +[![Ko-fi](https://img.shields.io/badge/Ko--fi-ghostfvtt-00B9FE?logo=kofi)](https://ko-fi.com/ghostfvtt) + A tick based combat system for [Foundry Virtual Tabletop]. This module adjusts the combat to use ticks instead of rounds for tracking time. @@ -19,7 +25,7 @@ To install and use the Tickwerk module for Foundry Virtual Tabletop, find it in the list in the **Install Module** dialog on the Setup menu of the application. Alternatively, paste the following Manifest URL in that dialog: -https://git.f3l.de/api/v4/projects/dungeonslayers%2Ftickwerk/packages/generic/tickwerk/latest/module.json +https://git.f3l.de/api/packages/dungeonslayers/generic/tickwerk/latest/module.json ## Development diff --git a/package.json b/package.json index 2e8e1de..30d672b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "https://git.f3l.de/dungeonslayers/tickwerk" }, "bugs": { - "url": "https://git.f3l.de/dungeonslayers/tickwerk/-/issues" + "url": "https://git.f3l.de/dungeonslayers/tickwerk/issues" }, "contributors": [ { diff --git a/tools/bump-version.js b/tools/bump-version.js index 168b8ae..b555f56 100644 --- a/tools/bump-version.js +++ b/tools/bump-version.js @@ -7,15 +7,21 @@ import semver from 'semver'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; -const repository = 'dungeonslayers/tickwerk'; -const gitlabURL = 'https://git.f3l.de'; +const packageType = 'module'; +const repositoryOwner = process.env.CI_REPO_OWNER; +const repositoryName = process.env.CI_REPO_NAME; +const repositoryURL = process.env.CI_REPO_LINK; +const forgeURL = process.env.CI_FORGE_URL; -const getLicenseURL = (version) => `${gitlabURL}/${repository}/-/raw/${version}/LICENSE.md`; -const getReadmeURL = (version) => `${gitlabURL}/${repository}/-/raw/${version}/README.md`; -const getChangelogURL = (version) => `${gitlabURL}/${repository}/-/releases/${version}`; -const getDownloadURL = (version) => `${gitlabURL}/${repository}/-/releases/${version}/downloads/module.zip`; +const getManifestUrl = (channel) => + `${forgeURL}/api/packages/${repositoryOwner}/generic/${repositoryName}/${channel}/${packageType}.json`; +const getDownloadURL = (version) => `${repositoryURL}/releases/download/${version}/${repositoryName}.zip`; +const bugsURL = `${repositoryURL}/issues`; +const getChangelogURL = (version) => `${repositoryURL}/releases/tag/${version}`; +const getReadmeURL = (version) => `${repositoryURL}/raw/tag/${version}/README.md`; +const getLicenseURL = (version) => `${repositoryURL}/raw/tag/${version}/LICENSE.md`; -const manifestPath = './module.json'; +const manifestPath = `${packageType}.json`; /** * Get the contents of the manifest file as object. @@ -41,6 +47,15 @@ function getTargetVersion(currentVersion, release) { } } +/** + * Get the channel for a given version. + * @param {string} version The version for which to get the channel + * @returns {"latest" | "beta"} The channel for the version + */ +function getChannel(version) { + return version.includes('-') ? 'beta' : 'latest'; +} + /** * Update version and download URL. * @param {semver.ReleaseType | string} release Either a semver release type or a valid semver version @@ -66,13 +81,16 @@ function bumpVersion(release) { console.log(`Bumping version number to '${targetVersion}'`); packageJson.version = targetVersion; - fs.writeJSONSync('package.json', packageJson, { spaces: 2 }); - manifest.license = getLicenseURL(targetVersion); - manifest.readme = getReadmeURL(targetVersion); - manifest.changelog = getChangelogURL(targetVersion); + fs.writeJSONSync('package.json', packageJson, { spaces: 4 }); manifest.version = targetVersion; + manifest.url = repositoryURL; + manifest.manifest = getManifestUrl(getChannel(targetVersion)); manifest.download = getDownloadURL(targetVersion); - fs.writeJSONSync(manifestPath, manifest, { spaces: 2 }); + manifest.bugs = bugsURL; + manifest.changelog = getChangelogURL(targetVersion); + manifest.readme = getReadmeURL(targetVersion); + manifest.license = getLicenseURL(targetVersion); + fs.writeJSONSync(manifestPath, manifest, { spaces: 4 }); } const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', {