mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:31:48 +00:00
dev: add helm support to release cli (#31364)
This commit is contained in:
parent
f9ef00ff4b
commit
52c46a1e65
17
dev/release/src/chart.ts
Normal file
17
dev/release/src/chart.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { readFileSync } from 'fs'
|
||||
|
||||
import { load as loadYAML } from 'js-yaml'
|
||||
|
||||
export interface Metadata {
|
||||
apiVersion: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
version: string
|
||||
appVersion: string
|
||||
}
|
||||
|
||||
export function parseChartMetadata(chartYamlPath: string): Metadata {
|
||||
const chartYamlContents = readFileSync(chartYamlPath, 'utf8').toString()
|
||||
return loadYAML(chartYamlContents) as Metadata
|
||||
}
|
||||
@ -3,9 +3,12 @@ import * as path from 'path'
|
||||
|
||||
import commandExists from 'command-exists'
|
||||
import { addMinutes } from 'date-fns'
|
||||
import * as execa from 'execa'
|
||||
import * as semver from 'semver'
|
||||
|
||||
import * as batchChanges from './batchChanges'
|
||||
import * as changelog from './changelog'
|
||||
import * as chart from './chart'
|
||||
import { Config, releaseVersions } from './config'
|
||||
import {
|
||||
getAuthenticatedGitHubClient,
|
||||
@ -371,7 +374,7 @@ cc @${config.captainGitHubUsername}
|
||||
|
||||
// Render changes
|
||||
const createdChanges = await createChangesets({
|
||||
requiredCommands: ['comby', sed, 'find', 'go', 'src'],
|
||||
requiredCommands: ['comby', sed, 'find', 'go', 'src', 'sg'],
|
||||
changes: [
|
||||
{
|
||||
owner: 'sourcegraph',
|
||||
@ -497,6 +500,38 @@ cc @${config.captainGitHubUsername}
|
||||
],
|
||||
...prBodyAndDraftState([]),
|
||||
},
|
||||
{
|
||||
owner: 'sourcegraph',
|
||||
repo: 'deploy-sourcegraph-helm',
|
||||
base: 'main',
|
||||
head: `publish-${release.version}`,
|
||||
commitMessage: defaultPRMessage,
|
||||
title: defaultPRMessage,
|
||||
edits: [
|
||||
`sg ops update-images -kind helm -pin-tag ${release.version} charts/sourcegraph/.`,
|
||||
`${sed} -i 's/appVersion:.*/appVersion: "${release.version}"/g' charts/sourcegraph/Chart.yaml`,
|
||||
(directory: string) => {
|
||||
const chartYamlPath = path.join(directory, 'charts/sourcegraph/Chart.yaml')
|
||||
const metadata = chart.parseChartMetadata(chartYamlPath)
|
||||
const parsedPreviousVersion = semver.parse(metadata.version)
|
||||
if (!parsedPreviousVersion) {
|
||||
throw new Error('`version` field in Chart.yaml is not valid semver')
|
||||
}
|
||||
const nextVersion = notPatchRelease
|
||||
? parsedPreviousVersion.inc('minor')
|
||||
: parsedPreviousVersion.inc('patch')
|
||||
execa.sync(
|
||||
'bash',
|
||||
[
|
||||
'-c',
|
||||
`${sed} -i 's/version:.*/version: ${nextVersion.version}/g' charts/sourcegraph/Chart.yaml`,
|
||||
],
|
||||
{ stdio: 'inherit', cwd: directory }
|
||||
)
|
||||
},
|
||||
],
|
||||
...prBodyAndDraftState([]),
|
||||
},
|
||||
],
|
||||
dryRun: dryRun.changesets,
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user