-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When a build is run on the main branch, it publishes the latest release to the unstable channel in KOTS.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { exec } from '../../util/shell'; | ||
import { Werft } from "../../util/werft"; | ||
import { JobConfig } from "./job-config"; | ||
|
||
const phases = { | ||
PUBLISH_KOTS_UNSTABLE: 'publish kots unstable', | ||
}; | ||
|
||
const REPLICATED_SECRET = 'replicated'; | ||
const REPLICATED_CHANNEL = 'Unstable'; | ||
const REPLICATED_YAML_DIR = './install/kots/manifests'; | ||
const INSTALLER_JOB_IMAGE = 'spec.template.spec.containers[0].image'; | ||
|
||
export async function publishKotsUnstable(werft: Werft, config: JobConfig) { | ||
if (config.mainBuild) { | ||
werft.phase(phases.PUBLISH_KOTS_UNSTABLE, 'Publish unstable release to KOTS'); | ||
|
||
const imageAndTag = exec(`yq r ${REPLICATED_YAML_DIR}/gitpod-installer-job.yaml ${INSTALLER_JOB_IMAGE}`); | ||
const [image] = imageAndTag.split(':'); | ||
|
||
// Set the tag to the current version | ||
exec(`yq w -i ${REPLICATED_YAML_DIR}/gitpod-installer-job.yaml ${INSTALLER_JOB_IMAGE} ${image}:${config.version}`); | ||
|
||
const app = exec(`kubectl get secret ${REPLICATED_SECRET} --namespace werft -o jsonpath='{.data.app}' | base64 -d`); | ||
const token = exec(`kubectl get secret ${REPLICATED_SECRET} --namespace werft -o jsonpath='{.data.token}' | base64 -d`); | ||
|
||
exec(`replicated release create \ | ||
--lint \ | ||
--ensure-channel \ | ||
--app ${app} \ | ||
--token ${token} \ | ||
--yaml-dir ${REPLICATED_YAML_DIR} \ | ||
--version ${config.version} \ | ||
--release-notes "# ${config.version}\n\nSee [Werft job](https://werft.gitpod-dev.com/job/gitpod-build-${config.version}/logs) for notes" \ | ||
--promote ${REPLICATED_CHANNEL}`); | ||
|
||
werft.done(phases.PUBLISH_KOTS_UNSTABLE); | ||
} | ||
} |