|
| 1 | +import { exec } from '../../util/shell'; |
| 2 | +import { Werft } from "../../util/werft"; |
| 3 | +import { JobConfig } from "./job-config"; |
| 4 | + |
| 5 | +const phases = { |
| 6 | + PUBLISH_KOTS_UNSTABLE: 'publish kots unstable', |
| 7 | +}; |
| 8 | + |
| 9 | +const REPLICATED_SECRET = 'replicated'; |
| 10 | +const REPLICATED_CHANNEL = 'Unstable'; |
| 11 | +const REPLICATED_YAML_DIR = './install/kots/manifests'; |
| 12 | +const INSTALLER_JOB_IMAGE = 'spec.template.spec.containers[0].image'; |
| 13 | + |
| 14 | +export async function publishKotsUnstable(werft: Werft, config: JobConfig) { |
| 15 | + if (config.mainBuild) { |
| 16 | + werft.phase(phases.PUBLISH_KOTS_UNSTABLE, 'Publish unstable release to KOTS'); |
| 17 | + |
| 18 | + const imageAndTag = exec(`yq r ${REPLICATED_YAML_DIR}/gitpod-installer-job.yaml ${INSTALLER_JOB_IMAGE}`); |
| 19 | + const [image] = imageAndTag.split(':'); |
| 20 | + |
| 21 | + // Set the tag to the current version |
| 22 | + exec(`yq w -i ${REPLICATED_YAML_DIR}/gitpod-installer-job.yaml ${INSTALLER_JOB_IMAGE} ${image}:${config.version}`); |
| 23 | + |
| 24 | + const app = exec(`kubectl get secret ${REPLICATED_SECRET} --namespace werft -o jsonpath='{.data.app}' | base64 -d`); |
| 25 | + const token = exec(`kubectl get secret ${REPLICATED_SECRET} --namespace werft -o jsonpath='{.data.token}' | base64 -d`); |
| 26 | + |
| 27 | + exec(`replicated release create \ |
| 28 | + --lint \ |
| 29 | + --ensure-channel \ |
| 30 | + --app ${app} \ |
| 31 | + --token ${token} \ |
| 32 | + --yaml-dir ${REPLICATED_YAML_DIR} \ |
| 33 | + --version ${config.version} \ |
| 34 | + --release-notes "# ${config.version}\n\nSee [Werft job](https://werft.gitpod-dev.com/job/gitpod-build-${config.version}/logs) for notes" \ |
| 35 | + --promote ${REPLICATED_CHANNEL}`); |
| 36 | + |
| 37 | + werft.done(phases.PUBLISH_KOTS_UNSTABLE); |
| 38 | + } |
| 39 | +} |
0 commit comments