The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Consolidate release workflows (#74172)
Nemanja Glumac9524e65ce790
diff --git a/.github/workflows/build-for-release.yml b/.github/workflows/build-for-release.ymlindex 257054f8618..c5479024d4a 100644--- a/.github/workflows/build-for-release.yml+++ b/.github/workflows/build-for-release.yml@@ -1,4 +1,10 @@-name: Release 1 - Build Release Artifact+# Builds a fresh release JAR from scratch at a given commit.+#+# You should almost never have to use this. The normal release flow relies on a+# commit that has already been built and tested on its branch — see+# `tag-for-release.yml`, which tags that existing JAR. Building from scratch+# here is only for exceptional cases.+name: Release 0 - Build Release Artifactrun-name: Build ${{ inputs.version }}on:@@ -45,24 +51,17 @@ jobs:}).catch(console.error);trigger-milestone-check:- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}- timeout-minutes: 5- needs: start-message- steps:- - name: trigger pre-release milestone check- uses: actions/github-script@v7- with:- script: | # js- await github.rest.actions.createWorkflowDispatch({- owner: context.repo.owner,- repo: context.repo.repo,- workflow_id: 'release-milestone-check.yml',- ref: '${{ github.ref }}',- inputs: {- commit: '${{ inputs.commit }}',- version: '${{ inputs.version }}',- }- });+ # Posts a Slack FYI about issues that still need review for this release.+ # Informational only — nothing depends on it, so it never blocks the release.+ needs: [check-version, check-commit]+ permissions:+ contents: read+ issues: read+ uses: ./.github/workflows/release-milestone-check.yml+ secrets: inherit+ with:+ version: ${{ inputs.version }}+ commit: ${{ inputs.commit }}check-version:runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}diff --git a/.github/workflows/release-auto.yml b/.github/workflows/release-auto.ymlnew file mode 100644index 00000000000..eef5f945f20--- /dev/null+++ b/.github/workflows/release-auto.yml@@ -0,0 +1,141 @@+name: Trigger Release End-to-End+run-name: Auto ${{ inputs.kind }} release for v${{ inputs.version }}++on:+ workflow_dispatch:+ inputs:+ version:+ description: "Major Metabase version (e.g. 45, 52, 68)"+ type: number+ required: true+ kind:+ description: "Release kind"+ type: choice+ required: true+ options:+ - patch+ - minor+ override_sha:+ description: DANGEROUSLY allow releasing from this commit sha, regardless of the state of CI (can be empty)+ type: string+ required: false+ default: ""++# This workflow only runs on dispatch. Given a major version and a kind, it+# infers the next patch or minor to cut and kicks off that release. Cron+# scheduling lives in the schedule-* trigger workflows, which decide what to+# release and when.+jobs:+ prepare:+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}+ timeout-minutes: 5+ outputs:+ version: ${{ steps.compute.outputs.version }}+ commit: ${{ steps.compute.outputs.commit }}+ should_release: ${{ steps.compute.outputs.should_release }}+ steps:+ - uses: actions/checkout@v4+ with:+ sparse-checkout: |+ release+ .github+ - name: Prepare release scripts+ uses: ./.github/actions/prepare-release-scripts+ - name: Compute next version and green commit+ id: compute+ uses: actions/github-script@v7+ env:+ SLACK_RELEASE_CHANNEL: ${{ vars.SLACK_RELEASE_CHANNEL }}+ SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}+ with:+ script: | # js+ const {+ getLatestGreenCommit,+ getNextVersion,+ hasCommitBeenReleased,+ sendAutoReleaseFailureMessage,+ } = require('${{ github.workspace }}/release/dist/index.cjs');++ const majorVersion = Number('${{ inputs.version }}');+ const kind = '${{ inputs.kind }}';++ if (Number.isNaN(majorVersion)) {+ throw new Error(`Invalid version number: ${{ inputs.version }}`);+ }+ if (kind !== 'patch' && kind !== 'minor') {+ throw new Error(`Invalid kind: ${kind}`);+ }++ const overrideSha = String('${{ inputs.override_sha }}').trim();+ const isValidOverride = overrideSha.length === 40;++ if (!isValidOverride && overrideSha.length > 0) {+ throw new Error(`Invalid override SHA provided: ${overrideSha}`);+ }++ const nextVersion = await getNextVersion({+ github,+ owner: context.repo.owner,+ repo: context.repo.repo,+ majorVersion,+ kind,+ });++ const releaseCommit = (isValidOverride ? overrideSha : null) || await getLatestGreenCommit({+ github,+ owner: context.repo.owner,+ repo: context.repo.repo,+ branch: `release-x.${majorVersion}.x`,+ });++ const hasBeenReleased = releaseCommit ? await hasCommitBeenReleased({+ github,+ owner: context.repo.owner,+ repo: context.repo.repo,+ ref: releaseCommit,+ majorVersion,+ }) : false;++ console.log({ kind, majorVersion, nextVersion, releaseCommit, hasBeenReleased });++ if (nextVersion && releaseCommit && !hasBeenReleased) {+ core.setOutput('version', nextVersion);+ core.setOutput('commit', releaseCommit);+ core.setOutput('should_release', 'true');+ return;+ }++ const reason = !nextVersion+ ? 'no-next-version'+ : !releaseCommit+ ? 'no-green-commit'+ : 'already-released';++ console.error(`Auto-${kind} skipped for v${majorVersion}: ${reason}`);++ await sendAutoReleaseFailureMessage({+ channelName: '${{ vars.SLACK_RELEASE_CHANNEL }}',+ kind,+ majorVersion,+ reason,+ runId: '${{ github.run_id }}',+ owner: context.repo.owner,+ repo: context.repo.repo,+ }).catch(console.error);++ core.setOutput('should_release', 'false');++ trigger-release:+ needs: prepare+ if: ${{ needs.prepare.outputs.should_release == 'true' }}+ permissions:+ id-token: write+ contents: write+ checks: write+ issues: write+ actions: read+ uses: ./.github/workflows/tag-for-release.yml+ secrets: inherit+ with:+ version: ${{ needs.prepare.outputs.version }}+ commit: ${{ needs.prepare.outputs.commit }}diff --git a/.github/workflows/release-milestone-check.yml b/.github/workflows/release-milestone-check.ymlindex 1ef10a55193..a91e638e52e 100644--- a/.github/workflows/release-milestone-check.yml+++ b/.github/workflows/release-milestone-check.yml@@ -2,6 +2,16 @@ name: Release Milestone Checkrun-name: Pre-release Milestone check for ${{ inputs.version }}on:+ workflow_call:+ inputs:+ version:+ description: "Metabase version (e.g. v0.46.3)"+ type: string+ required: true+ commit:+ description: "A full-length commit SHA-1 hash"+ type: string+ required: trueworkflow_dispatch:inputs:version:diff --git a/.github/workflows/release-minor.yml b/.github/workflows/release-minor.ymldeleted file mode 100644index 737aa2b6a05..00000000000--- a/.github/workflows/release-minor.yml+++ /dev/null@@ -1,129 +0,0 @@-name: Release 1c - Auto Minor-run-name: Minor Release ${{ inputs.version }}--on:- workflow_dispatch:- inputs:- version:- description: "Major Metabase version (e.g. 45, 52, 68)"- type: number- required: true- override_sha:- description: DANGEROUSLY allow releasing from this commit sha, regardless of the state of CI (can be empty)- type: string- required: false- default: ""- schedule:- - cron: "0 13 * * 2" # every Tuesday at 13:00 UTC (9am EST / 8am EDT)--jobs:- auto-minor-trigger:- # don't run this workflow on a cron for forks- if: ${{ github.event_name != 'schedule' || (github.repository == 'metabase/metabase' && vars.ENABLE_AUTO_MINOR == 'true') }}- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}- timeout-minutes: 5- steps:- - uses: actions/checkout@v4- with:- sparse-checkout: |- release- .github- - name: Prepare release scripts- uses: ./.github/actions/prepare-release-scripts- - name: Trigger auto-minor- uses: actions/github-script@v7- env:- SLACK_RELEASE_CHANNEL: ${{ vars.SLACK_RELEASE_CHANNEL }}- SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}- with:- script: | # js- const {- getLatestGreenCommit,- getNextMinorVersion,- hasCommitBeenReleased,- sendAutoMinorFailureMessage,- } = require('${{ github.workspace }}/release/dist/index.cjs');-- const currentRelease = Number('${{ vars.CURRENT_VERSION }}');- const lastRelease = currentRelease - 1;- const AUTO_RELEASE_VERSIONS = [lastRelease, currentRelease];-- async function releaseMinorFor(majorVersion, overrideSha) {- const nextMinor = await getNextMinorVersion({- github,- owner: context.repo.owner,- repo: context.repo.repo,- majorVersion,- });-- const releaseCommit = overrideSha || await getLatestGreenCommit({- github,- owner: context.repo.owner,- repo: context.repo.repo,- branch: `release-x.${majorVersion}.x`,- });-- const hasBeenReleased = await hasCommitBeenReleased({- github,- owner: context.repo.owner,- repo: context.repo.repo,- ref: releaseCommit,- majorVersion: Number(majorVersion),- });-- console.log(- { nextMinor, releaseCommit, hasBeenReleased }- );-- if (nextMinor && releaseCommit && !hasBeenReleased) {- await github.rest.actions.createWorkflowDispatch({- owner: context.repo.owner,- repo: context.repo.repo,- workflow_id: 'tag-for-release.yml',- ref: 'refs/heads/master',- inputs: {- commit: releaseCommit,- version: nextMinor,- }- }).catch(console.error);- return;- }-- const reason = !nextMinor- ? 'no-next-minor'- : !releaseCommit- ? 'no-green-commit'- : 'already-released';-- console.error(`Auto-minor skipped for v${majorVersion}: ${reason}`);-- await sendAutoMinorFailureMessage({- channelName: '${{ vars.SLACK_RELEASE_CHANNEL }}',- majorVersion,- reason,- runId: '${{ github.run_id }}',- owner: context.repo.owner,- repo: context.repo.repo,- }).catch(console.error);- }-- if (context.eventName === 'workflow_dispatch') {- const inputVersion = Number(context.payload.inputs.version);-- if (typeof inputVersion !== 'number') {- console.log('Invalid version number', inputVersion);- throw new Error(`Invalid version number: ${inputVersion}`);- }-- // only allow overriding the commit SHA for workflow_dispatch events with a provided sha- const overrideSha = String(context.payload?.inputs?.override_sha ?? '').trim();- const isValidOverride = overrideSha.length === 40;-- if (!isValidOverride && overrideSha.length > 0) {- throw new Error(`Invalid override SHA provided: ${overrideSha}`);- }-- await releaseMinorFor(inputVersion, isValidOverride ? overrideSha : undefined);- } else { // scheduled release of AUTO_RELEASE_VERSIONS- await Promise.all(AUTO_RELEASE_VERSIONS.map(version => releaseMinorFor(version)));- }diff --git a/.github/workflows/release-patch.yml b/.github/workflows/release-patch.ymldeleted file mode 100644index 8f1df106a10..00000000000--- a/.github/workflows/release-patch.yml+++ /dev/null@@ -1,133 +0,0 @@-name: Release 1b - Auto Patch-run-name: Patch Release ${{ inputs.version }}--on:- workflow_dispatch:- inputs:- version:- description: "Major Metabase version (e.g. 45, 52, 68)"- type: number- required: true- override_sha:- description: DANGEROUSLY allow releasing from this commit sha, regardless of the state of CI (can be empty)- type: string- required: false- default: ""- schedule:- - cron: "0 21 * * 1-5" # every weekday at 4 pm EST/5 pm EDT--jobs:- auto-patch-trigger:- # don't run this workflow on a cron for forks- if: ${{ github.event_name != 'schedule' || (github.repository == 'metabase/metabase' && vars.ENABLE_AUTO_PATCH == 'true') }}- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}- timeout-minutes: 5- steps:- - uses: actions/checkout@v4- with:- sparse-checkout: release- - name: Install bun- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2- with:- bun-version: "1.3.7"- token: ${{ secrets.GITHUB_TOKEN }}- - name: Prepare build scripts- run: bun install --cwd release --frozen-lockfile && bun run --cwd release build- - name: Trigger auto-patch- uses: actions/github-script@v7- env:- SLACK_RELEASE_CHANNEL: ${{ vars.SLACK_RELEASE_CHANNEL }}- SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}- with:- script: | # js- const {- getLatestGreenCommit,- getNextPatchVersion,- hasCommitBeenReleased,- sendAutoPatchFailureMessage,- } = require('${{ github.workspace }}/release/dist/index.cjs');-- const currentRelease = Number('${{ vars.CURRENT_VERSION }}');- const lastRelease = currentRelease - 1;- const AUTO_RELEASE_VERSIONS = [lastRelease, currentRelease];-- async function releasePatchFor(majorVersion, overrideSha) {- const nextPatch = await getNextPatchVersion({- github,- owner: context.repo.owner,- repo: context.repo.repo,- majorVersion,- });-- const releaseCommit = overrideSha || await getLatestGreenCommit({- github,- owner: context.repo.owner,- repo: context.repo.repo,- branch: `release-x.${majorVersion}.x`,- });-- const hasBeenReleased = await hasCommitBeenReleased({- github,- owner: context.repo.owner,- repo: context.repo.repo,- ref: releaseCommit,- majorVersion: Number(majorVersion),- });-- console.log(- { nextPatch, releaseCommit, hasBeenReleased }- );-- if (nextPatch && releaseCommit && !hasBeenReleased) {- await github.rest.actions.createWorkflowDispatch({- owner: context.repo.owner,- repo: context.repo.repo,- workflow_id: 'tag-for-release.yml',- ref: 'refs/heads/master',- inputs: {- commit: releaseCommit,- version: nextPatch,- auto: true,- }- }).catch(console.error);- return;- }-- const reason = !nextPatch- ? 'no-next-patch'- : !releaseCommit- ? 'no-green-commit'- : 'already-released';-- console.error(`Auto-patch skipped for v${majorVersion}: ${reason}`);-- await sendAutoPatchFailureMessage({- channelName: '${{ vars.SLACK_RELEASE_CHANNEL }}',- majorVersion,- reason,- runId: '${{ github.run_id }}',- owner: context.repo.owner,- repo: context.repo.repo,- }).catch(console.error);- }-- if (context.eventName === 'workflow_dispatch') {- const inputVersion = Number(context.payload.inputs.version);-- if (typeof inputVersion !== 'number') {- console.log('Invalid version number', inputVersion);- throw new Error(`Invalid version number: ${inputVersion}`);- }-- // only allow overriding the commit SHA for workflow_dispatch events with a provided sha- const overrideSha = String(context.payload?.inputs?.override_sha ?? '').trim();- const isValidOverride = overrideSha.length === 40;-- if (!isValidOverride && overrideSha.length > 0) {- throw new Error(`Invalid override SHA provided: ${overrideSha}`);- }-- await releasePatchFor(inputVersion, isValidOverride ? overrideSha : undefined);- } else { // scheduled release of AUTO_RELEASE_VERSIONS- await Promise.all(AUTO_RELEASE_VERSIONS.map(version => releasePatchFor(version)));- }diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex bab316b4da1..fc1bf84062a 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -11,10 +11,6 @@ on:commit:description: 'A full-length commit SHA-1 hash'required: true- auto:- description: 'auto-patch release DO NOT SET MANUALLY'- type: boolean- default: falseworkflow_call:inputs:version:@@ -25,10 +21,6 @@ on:description: 'A full-length commit SHA-1 hash'type: stringrequired: true- auto:- description: 'auto-patch release DO NOT SET MANUALLY'- type: boolean- default: falsepermissions:id-token: write@@ -44,6 +36,7 @@ jobs:outputs:ee: ${{ fromJson(steps.canonical_version.outputs.result).ee }}oss: ${{ fromJson(steps.canonical_version.outputs.result).oss }}+ kind: ${{ fromJson(steps.canonical_version.outputs.result).kind }}steps:- name: Fail early on the incorrect version formatif: ${{ !(startsWith(inputs.version,'v0.') || startsWith(inputs.version,'v1.')) }}@@ -64,7 +57,7 @@ jobs:id: canonical_versionwith:script: | # js- const { isValidVersionString, getCanonicalVersion, hasBeenReleased } = require('${{ github.workspace }}/release/dist/index.cjs');+ const { isValidVersionString, getCanonicalVersion, getVersionType, hasBeenReleased } = require('${{ github.workspace }}/release/dist/index.cjs');const version = '${{ inputs.version }}';@@ -75,6 +68,7 @@ jobs:const versions = {ee: getCanonicalVersion(version, 'ee'),oss: getCanonicalVersion(version, 'oss'),+ kind: getVersionType(version),};const released = await hasBeenReleased({@@ -358,8 +352,8 @@ jobs:dot-x-tag: ${{ startsWith(matrix.tag, 'v') }}trigger-cloud-issues:- if: ${{ !inputs.auto }}- needs: push-tags+ if: ${{ needs.check-version.outputs.kind == 'minor' || needs.check-version.outputs.kind == 'major' }}+ needs: [push-tags, check-version]runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}timeout-minutes: 10steps:@@ -433,8 +427,8 @@ jobs:});draft-release-notes:- if: ${{ !inputs.auto }}- needs: add-extra-tags+ if: ${{ needs.check-version.outputs.kind == 'minor' || needs.check-version.outputs.kind == 'major' }}+ needs: [add-extra-tags, check-version]runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}timeout-minutes: 15env:@@ -502,6 +496,7 @@ jobs:}).catch(console.warn);publish-version-info:+ if: ${{ needs.check-version.outputs.kind == 'minor' || needs.check-version.outputs.kind == 'major' }}runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}needs: [push-tags, check-version]timeout-minutes: 15@@ -512,11 +507,6 @@ jobs:AWS_S3_STATIC_BUCKET: ${{ vars.AWS_S3_STATIC_BUCKET }}AWS_REGION: ${{ vars.AWS_REGION }}steps:- - name: Finish early- if: ${{ inputs.auto }}- run: |- echo "skipping version info update for nightly patch"- exit 0- name: Configure AWS credentialsuses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4with:@@ -586,8 +576,6 @@ jobs:script: | # jsconst { sendPublishCompleteMessage } = require('${{ github.workspace }}/release/dist/index.cjs');- const isAutoRelease = '${{ inputs.auto }}' === 'true';-await sendPublishCompleteMessage({owner: context.repo.owner,repo: context.repo.repo,diff --git a/.github/workflows/schedule-minor.yml b/.github/workflows/schedule-minor.ymlnew file mode 100644index 00000000000..97106027db4--- /dev/null+++ b/.github/workflows/schedule-minor.yml@@ -0,0 +1,34 @@+name: Schedule Release - Auto Minor++on:+ schedule:+ - cron: "0 13 * * 2" # every Tuesday at 13:00 UTC (8 am EST / 9 am EDT)++permissions:+ actions: write++jobs:+ trigger-auto-minor:+ # Never run on a fork's inherited cron; honor the kill switch.+ if: ${{ github.repository == 'metabase/metabase' && vars.ENABLE_AUTO_MINOR == 'true' }}+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}+ timeout-minutes: 5+ steps:+ - name: Dispatch minor release for the current major+ uses: actions/github-script@v7+ with:+ script: | # js+ // Minor releases only go out for the current major; the+ // previous major gets patches only.+ const currentRelease = Number('${{ vars.CURRENT_VERSION }}');++ await github.rest.actions.createWorkflowDispatch({+ owner: context.repo.owner,+ repo: context.repo.repo,+ workflow_id: 'release-auto.yml',+ ref: 'refs/heads/master',+ inputs: {+ version: String(currentRelease),+ kind: 'minor',+ },+ }).catch(console.error);diff --git a/.github/workflows/schedule-patch.yml b/.github/workflows/schedule-patch.ymlnew file mode 100644index 00000000000..7d87a2bb4c6--- /dev/null+++ b/.github/workflows/schedule-patch.yml@@ -0,0 +1,37 @@+name: Schedule Release - Auto Patch++on:+ schedule:+ - cron: "0 21 * * 1-5" # every weekday at 21:00 UTC (4 pm EST / 5 pm EDT)++permissions:+ actions: write++jobs:+ trigger-auto-patch:+ # Never run on a fork's inherited cron; honor the kill switch.+ if: ${{ github.repository == 'metabase/metabase' && vars.ENABLE_AUTO_PATCH == 'true' }}+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}+ timeout-minutes: 5+ steps:+ - name: Dispatch patch release for the current and previous major+ uses: actions/github-script@v7+ with:+ script: | # js+ // Nightly patches cover the current supported major and the one+ // before it. release-auto.yml releases one major per dispatch.+ const currentRelease = Number('${{ vars.CURRENT_VERSION }}');+ const majors = [currentRelease - 1, currentRelease];++ await Promise.all(majors.map(version =>+ github.rest.actions.createWorkflowDispatch({+ owner: context.repo.owner,+ repo: context.repo.repo,+ workflow_id: 'release-auto.yml',+ ref: 'refs/heads/master',+ inputs: {+ version: String(version),+ kind: 'patch',+ },+ }).catch(console.error)+ ));diff --git a/.github/workflows/tag-for-release.yml b/.github/workflows/tag-for-release.ymlindex 335eaf1b775..2f3b69887ae 100644--- a/.github/workflows/tag-for-release.yml+++ b/.github/workflows/tag-for-release.yml@@ -1,4 +1,4 @@-name: Release 1a - Tag Release Artifact+name: Release 1 - Tag Release Artifactrun-name: Tag ${{ inputs.version }}on:@@ -11,10 +11,16 @@ on:commit:description: 'A full-length commit SHA-1 hash'required: true- auto:- description: 'auto-patch release DO NOT SET MANUALLY'- type: boolean- default: false+ workflow_call:+ inputs:+ version:+ description: 'Metabase version (e.g. v0.46.3)'+ type: string+ required: true+ commit:+ description: 'A full-length commit SHA-1 hash'+ type: string+ required: truepermissions:id-token: write@@ -152,6 +158,19 @@ jobs:with:version: ${{ inputs.version }}+ trigger-milestone-check:+ # Posts a Slack FYI about issues that still need review for this release.+ # Informational only — nothing depends on it, so it never blocks the release.+ needs: [check-version, check-commit]+ permissions:+ contents: read+ issues: read+ uses: ./.github/workflows/release-milestone-check.yml+ secrets: inherit+ with:+ version: ${{ inputs.version }}+ commit: ${{ inputs.commit }}+tag-uberjar-for-release:needs: [check-version, check-commit]runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}@@ -260,11 +279,9 @@ jobs:auto-publish-release:name: Auto-publish release ${{ inputs.version }}- if: ${{ inputs.auto }}needs: run-pre-release-testsuses: ./.github/workflows/release.ymlsecrets: inheritwith:version: ${{ inputs.version }}commit: ${{ inputs.commit }}- auto: ${{ inputs.auto }}diff --git a/release/src/slack.ts b/release/src/slack.tsindex f168f1a624d..fd509383f8c 100644--- a/release/src/slack.ts+++ b/release/src/slack.ts@@ -279,83 +279,54 @@ export function githubRunLink();}-export type AutoPatchSkipReason =- | "no-next-patch"+export type ReleaseKind = "patch" | "minor";++export type AutoReleaseSkipReason =+ | "no-next-version"| "no-green-commit"| "already-released";-type AutoPatchSkipArgs = {+type AutoReleaseSkipArgs = {+ kind: ReleaseKind;majorVersion: number;- reason: AutoPatchSkipReason;+ reason: AutoReleaseSkipReason;runId: string;owner: string;repo: string;};-export function buildAutoPatchSkipMessage({+export function buildAutoReleaseSkipMessage({+ kind,majorVersion,reason,runId,owner,repo,-}: AutoPatchSkipArgs): string {+}: AutoReleaseSkipArgs): string {const runLink = githubRunLink("workflow run", runId, owner, repo);+ const label = kind === "patch" ? "Auto-patch" : "Auto-minor";- const messageByReason: Record<AutoPatchSkipReason, string> = {- "no-green-commit": `:x: Auto-patch for *v${majorVersion}* skipped: no commit found suitable for the release. ${runLink}`,- "no-next-patch": `:x: Auto-patch for *v${majorVersion}* skipped: could not determine next patch version. ${runLink}`,- "already-released": `:information_source: Auto-patch for *v${majorVersion}* skipped: latest green commit has already been released — nothing new to patch. ${runLink}`,- };-- return messageByReason[reason];-}--export async function sendAutoPatchFailureMessage(- args: AutoPatchSkipArgs & { channelName: string },-) {- return sendSlackMessage({- channelName: args.channelName,- message: buildAutoPatchSkipMessage(args),- });-}--export type AutoMinorSkipReason =- | "no-next-minor"- | "no-green-commit"- | "already-released";--type AutoMinorSkipArgs = {- majorVersion: number;- reason: AutoMinorSkipReason;- runId: string;- owner: string;- repo: string;-};+ const noNextVersion = kind === "patch"+ ? `:x: ${label} for *v${majorVersion}* skipped: could not determine next patch version. ${runLink}`+ : `:information_source: ${label} for *v${majorVersion}* skipped: no gold release yet — cut it manually. ${runLink}`;-export function buildAutoMinorSkipMessage({- majorVersion,- reason,- runId,- owner,- repo,-}: AutoMinorSkipArgs): string {- const runLink = githubRunLink("workflow run", runId, owner, repo);+ const alreadyReleasedSuffix = kind === "patch" ? "nothing new to patch" : "nothing new to ship";- const messageByReason: Record<AutoMinorSkipReason, string> = {- "no-green-commit": `:x: Auto-minor for *v${majorVersion}* skipped: no commit found suitable for the release. ${runLink}`,- "no-next-minor": `:information_source: Auto-minor for *v${majorVersion}* skipped: no gold release yet — cut it manually. ${runLink}`,- "already-released": `:information_source: Auto-minor for *v${majorVersion}* skipped: latest green commit has already been released — nothing new to ship. ${runLink}`,+ const messageByReason: Record<AutoReleaseSkipReason, string> = {+ "no-green-commit": `:x: ${label} for *v${majorVersion}* skipped: no commit found suitable for the release. ${runLink}`,+ "no-next-version": noNextVersion,+ "already-released": `:information_source: ${label} for *v${majorVersion}* skipped: latest green commit has already been released — ${alreadyReleasedSuffix}. ${runLink}`,};return messageByReason[reason];}-export async function sendAutoMinorFailureMessage(- args: AutoMinorSkipArgs & { channelName: string },+export async function sendAutoReleaseFailureMessage(+ args: AutoReleaseSkipArgs & { channelName: string },) {return sendSlackMessage({channelName: args.channelName,- message: buildAutoMinorSkipMessage(args),+ message: buildAutoReleaseSkipMessage(args),});}diff --git a/release/src/slack.unit.spec.ts b/release/src/slack.unit.spec.tsindex d039998d724..a2a5d886870 100644--- a/release/src/slack.unit.spec.ts+++ b/release/src/slack.unit.spec.ts@@ -1,6 +1,6 @@-import { buildAutoMinorSkipMessage, buildAutoPatchSkipMessage } from "./slack";+import { buildAutoReleaseSkipMessage } from "./slack";-describe("buildAutoPatchSkipMessage", () => {+describe("buildAutoReleaseSkipMessage", () => {const baseArgs = {majorVersion: 54,runId: "12345",@@ -10,90 +10,79 @@ describe("buildAutoPatchSkipMessage", () => {const runLink = "<https://github.com/metabase/metabase/actions/runs/12345|workflow run>";- it("uses a failure emoji for no-green-commit", () => {- const message = buildAutoPatchSkipMessage({ ...baseArgs, reason: "no-green-commit" });+ describe("patch", () => {+ const patchArgs = { ...baseArgs, kind: "patch" as const };- expect(message).toContain(":x:");- expect(message).toContain("v54");- expect(message).toContain("no commit found suitable for the release");- expect(message).toContain(runLink);- });+ it("uses a failure emoji for no-green-commit", () => {+ const message = buildAutoReleaseSkipMessage({ ...patchArgs, reason: "no-green-commit" });- it("uses a failure emoji for no-next-patch", () => {- const message = buildAutoPatchSkipMessage({ ...baseArgs, reason: "no-next-patch" });+ expect(message).toContain(":x:");+ expect(message).toContain("Auto-patch");+ expect(message).toContain("v54");+ expect(message).toContain("no commit found suitable for the release");+ expect(message).toContain(runLink);+ });- expect(message).toContain(":x:");- expect(message).toContain("v54");- expect(message).toContain("next patch version");- expect(message).toContain(runLink);- });+ it("uses a failure emoji for no-next-version (patch can't fall back to manual)", () => {+ const message = buildAutoReleaseSkipMessage({ ...patchArgs, reason: "no-next-version" });- it("uses an info emoji (not a failure emoji) for already-released", () => {- const message = buildAutoPatchSkipMessage({ ...baseArgs, reason: "already-released" });+ expect(message).toContain(":x:");+ expect(message).toContain("Auto-patch");+ expect(message).toContain("next patch version");+ expect(message).toContain(runLink);+ });- expect(message).toContain(":information_source:");- expect(message).not.toContain(":x:");- expect(message).toContain("v54");- expect(message).toContain("nothing new to patch");- expect(message).toContain(runLink);- });+ it("uses an info emoji (not a failure emoji) for already-released", () => {+ const message = buildAutoReleaseSkipMessage({ ...patchArgs, reason: "already-released" });- it("uses the provided major version in the message", () => {- const message = buildAutoPatchSkipMessage({- ...baseArgs,- majorVersion: 53,- reason: "no-green-commit",+ expect(message).toContain(":information_source:");+ expect(message).not.toContain(":x:");+ expect(message).toContain("Auto-patch");+ expect(message).toContain("nothing new to patch");+ expect(message).toContain(runLink);});-- expect(message).toContain("v53");- expect(message).not.toContain("v54");});-});-describe("buildAutoMinorSkipMessage", () => {- const baseArgs = {- majorVersion: 54,- runId: "12345",- owner: "metabase",- repo: "metabase",- };-- const runLink = "<https://github.com/metabase/metabase/actions/runs/12345|workflow run>";+ describe("minor", () => {+ const minorArgs = { ...baseArgs, kind: "minor" as const };- it("uses a failure emoji for no-green-commit", () => {- const message = buildAutoMinorSkipMessage({ ...baseArgs, reason: "no-green-commit" });+ it("uses a failure emoji for no-green-commit", () => {+ const message = buildAutoReleaseSkipMessage({ ...minorArgs, reason: "no-green-commit" });- expect(message).toContain(":x:");- expect(message).toContain("v54");- expect(message).toContain("no commit found suitable for the release");- expect(message).toContain(runLink);- });+ expect(message).toContain(":x:");+ expect(message).toContain("Auto-minor");+ expect(message).toContain("v54");+ expect(message).toContain("no commit found suitable for the release");+ expect(message).toContain(runLink);+ });- it("uses an info emoji for no-next-minor (gold release happens manually)", () => {- const message = buildAutoMinorSkipMessage({ ...baseArgs, reason: "no-next-minor" });+ it("uses an info emoji for no-next-version (gold release happens manually)", () => {+ const message = buildAutoReleaseSkipMessage({ ...minorArgs, reason: "no-next-version" });- expect(message).toContain(":information_source:");- expect(message).not.toContain(":x:");- expect(message).toContain("v54");- expect(message).toContain("no gold release yet");- expect(message).toContain(runLink);- });+ expect(message).toContain(":information_source:");+ expect(message).not.toContain(":x:");+ expect(message).toContain("Auto-minor");+ expect(message).toContain("no gold release yet");+ expect(message).toContain(runLink);+ });- it("uses an info emoji (not a failure emoji) for already-released", () => {- const message = buildAutoMinorSkipMessage({ ...baseArgs, reason: "already-released" });+ it("uses an info emoji (not a failure emoji) for already-released", () => {+ const message = buildAutoReleaseSkipMessage({ ...minorArgs, reason: "already-released" });- expect(message).toContain(":information_source:");- expect(message).not.toContain(":x:");- expect(message).toContain("v54");- expect(message).toContain("nothing new to ship");- expect(message).toContain(runLink);+ expect(message).toContain(":information_source:");+ expect(message).not.toContain(":x:");+ expect(message).toContain("Auto-minor");+ expect(message).toContain("nothing new to ship");+ expect(message).toContain(runLink);+ });});it("uses the provided major version in the message", () => {- const message = buildAutoMinorSkipMessage({+ const message = buildAutoReleaseSkipMessage({...baseArgs,+ kind: "patch",majorVersion: 53,- reason: "no-next-minor",+ reason: "no-green-commit",});expect(message).toContain("v53");diff --git a/release/src/version-helpers.ts b/release/src/version-helpers.tsindex d46f5875fa0..f2154ab9c4e 100644--- a/release/src/version-helpers.ts+++ b/release/src/version-helpers.ts@@ -483,6 +483,18 @@ export const getNextMinorVersion = async ({return findNextMinorVersion(lastRelease);};+export const getNextVersion = async ({+ github,+ owner,+ repo,+ majorVersion,+ kind,+}: GithubProps & { majorVersion: number; kind: "patch" | "minor" }) => {+ return kind === "patch"+ ? getNextPatchVersion({ github, owner, repo, majorVersion })+ : getNextMinorVersion({ github, owner, repo, majorVersion });+};+type SdkVersionInfo = {version: string;preReleaseLabel: string;