ci: add beta release channel
All checks were successful
ci/woodpecker/pr/checks Pipeline was successful
ci/woodpecker/push/checks Pipeline was successful
ci/woodpecker/manual/checks Pipeline was successful
ci/woodpecker/manual/release Pipeline was successful

This commit is contained in:
Johannes Loher 2023-07-09 23:05:17 +02:00
parent 4646491fd4
commit 2e17ba2085
Signed by: saluu
GPG key ID: 7CB0A9FB553DA045
2 changed files with 33 additions and 6 deletions

View file

@ -12,7 +12,7 @@ variables:
when:
event: tag
evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$"
evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+(-[0-9]+)?$"
depends_on:
- checks
@ -44,6 +44,20 @@ steps:
commands:
- <<: *enable_pnpm
- pnpm 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:
@ -55,14 +69,15 @@ steps:
- ${CI_REPO_NAME}/system.json
api_key:
from_secret: forge_token
publish-latest-manifest:
publish-manifest:
group: publish
image: alpine:latest
commands:
- apk update
- apk add curl
- 'curl --header "Authorization: token $${FORGE_TOKEN}" -X "DELETE" "${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/${CI_REPO_NAME}/latest/system.json"'
- 'curl --fail --header "Authorization: token $${FORGE_TOKEN}" --upload-file ${CI_REPO_NAME}/system.json "${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/${CI_REPO_NAME}/latest/system.json"'
- 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}/system.json"'
- 'curl --fail --header "Authorization: token $${FORGE_TOKEN}" --upload-file ${CI_REPO_NAME}/system.json "${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/${CI_REPO_NAME}/$${RELEASE_CHANNEL}/system.json"'
secrets:
- forge_token
publish-to-foundry-admin:
@ -78,3 +93,5 @@ steps:
- fvtt_package_id
- fvtt_username
- fvtt_password
when:
evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$"

View file

@ -13,7 +13,8 @@ const repositoryName = process.env.CI_REPO_NAME;
const repositoryURL = process.env.CI_REPO_LINK;
const forgeURL = process.env.CI_FORGE_URL;
const manifestURL = `${forgeURL}/api/packages/${repositoryOwner}/generic/${repositoryName}/latest/${packageType}.json`;
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}`;
@ -46,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
@ -74,7 +84,7 @@ function bumpVersion(release) {
fs.writeJSONSync("package.json", packageJson, { spaces: 4 });
manifest.version = targetVersion;
manifest.url = repositoryURL;
manifest.manifest = manifestURL;
manifest.manifest = getManifestUrl(getChannel(targetVersion));
manifest.download = getDownloadURL(targetVersion);
manifest.bugs = bugsURL;
manifest.changelog = getChangelogURL(targetVersion);