ci: add beta release channel #112

Merged
saluu merged 1 commit from beta-release-channel into main 2023-07-09 23:10:18 +02:00
2 changed files with 33 additions and 6 deletions

View file

@ -12,7 +12,7 @@ variables:
when: when:
event: tag 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: depends_on:
- checks - checks
@ -44,6 +44,20 @@ steps:
commands: commands:
- <<: *enable_pnpm - <<: *enable_pnpm
- pnpm changelog - 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: release:
image: woodpeckerci/plugin-gitea-release image: woodpeckerci/plugin-gitea-release
settings: settings:
@ -55,14 +69,15 @@ steps:
- ${CI_REPO_NAME}/system.json - ${CI_REPO_NAME}/system.json
api_key: api_key:
from_secret: forge_token from_secret: forge_token
publish-latest-manifest: publish-manifest:
group: publish group: publish
image: alpine:latest image: alpine:latest
commands: commands:
- apk update - apk update
- apk add curl - 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"' - export RELEASE_CHANNEL=$(cat .RELEASE_CHANNEL)
- '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"' - '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: secrets:
- forge_token - forge_token
publish-to-foundry-admin: publish-to-foundry-admin:
@ -78,3 +93,5 @@ steps:
- fvtt_package_id - fvtt_package_id
- fvtt_username - fvtt_username
- fvtt_password - 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 repositoryURL = process.env.CI_REPO_LINK;
const forgeURL = process.env.CI_FORGE_URL; 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 getDownloadURL = (version) => `${repositoryURL}/releases/download/${version}/${repositoryName}.zip`;
const bugsURL = `${repositoryURL}/issues`; const bugsURL = `${repositoryURL}/issues`;
const getChangelogURL = (version) => `${repositoryURL}/releases/tag/${version}`; 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. * Update version and download URL.
* @param {semver.ReleaseType | string} release Either a semver release type or a valid semver version * @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 }); fs.writeJSONSync("package.json", packageJson, { spaces: 4 });
manifest.version = targetVersion; manifest.version = targetVersion;
manifest.url = repositoryURL; manifest.url = repositoryURL;
manifest.manifest = manifestURL; manifest.manifest = getManifestUrl(getChannel(targetVersion));
manifest.download = getDownloadURL(targetVersion); manifest.download = getDownloadURL(targetVersion);
manifest.bugs = bugsURL; manifest.bugs = bugsURL;
manifest.changelog = getChangelogURL(targetVersion); manifest.changelog = getChangelogURL(targetVersion);