Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Automate milestone + release-notes-preview chain on release-branch cut (#74034)

Nemanja Glumac8b8b9adc645d
diff --git a/.github/workflows/check-milestone.yml b/.github/workflows/check-milestone.yml
deleted file mode 100644
index c3b3a592e7b..00000000000
--- a/.github/workflows/check-milestone.yml
+++ /dev/null
@@ -1,87 +0,0 @@
-name: Automatically set milestone
-run-name: Set milestone for ${{ github.event.head_commit.message || inputs.version }}
-
-on:
- push:
- branches:
- - release-x.**
- workflow_dispatch:
- inputs:
- version:
- description: 'Major version number (e.g. 52, 78, 109)'
- type: number
- required: true
-
-jobs:
- set-milestone:
- name: Automatically set milestone
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 30
- env:
- isNewReleaseBranch: ${{ github.event_name == 'workflow_dispatch' }}
- permissions:
- pull-requests: write
- issues: write
- contents: read
- steps:
- - uses: actions/checkout@v4
- with:
- sparse-checkout: |
- release
- .github
- fetch-depth: ${{ env.isNewReleaseBranch == 'false' && 3 || 0 }} # we need the full history to get all the commit messages
- ref: master # we want the logic from master, even though we're triggering on a release branch
- - name: Prepare release scripts
- uses: ./.github/actions/prepare-release-scripts
- - uses: actions/github-script@v7
- if: ${{ env.isNewReleaseBranch == 'false' }}
- name: Set milestone for single commit
- with:
- script: | # js
- const { setMilestoneForCommits } = require('${{ github.workspace }}/release/dist/index.cjs');
- const owner = context.repo.owner;
- const repo = context.repo.repo;
-
- const branchName = `${{ github.ref }}`;
- const commitMessage = context?.payload?.head_commit?.message ?? '';
-
- await setMilestoneForCommits({
- github,
- owner,
- repo,
- branchName,
- commitMessages: [commitMessage],
- });
- - name: Get commit messages for release branch
- if: ${{ env.isNewReleaseBranch == 'true' }}
- run: |
- npm i -g tsx
- tsx release/src/release-branch-commits.ts ${{ inputs.version }} > commit-messages.json
- - uses: actions/github-script@v7
- if: ${{ env.isNewReleaseBranch == 'true' }}
- name: Set milestones for new release branch
- env:
- # this token has a higher rate limit than the default token, and
- # we will need it for this workflow to work
- GITHUB_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
- with:
- script: | # js
- const { setMilestoneForCommits } = require('${{ github.workspace }}/release/dist/index.cjs');
- const commitMessages = require('${{ github.workspace }}/commit-messages.json');
-
- const owner = context.repo.owner;
- const repo = context.repo.repo;
-
- const versionNumber = context.payload.inputs.version;
- const branchName = `release-x.${versionNumber}.x`;
-
- console.log(`Found ${commitMessages.length} new commits for ${branchName}`);
-
- await setMilestoneForCommits({
- github,
- owner,
- repo,
- branchName,
- commitMessages: commitMessages,
- ignoreExistingMilestones: true,
- });
diff --git a/.github/workflows/cut-release-branch.yml b/.github/workflows/cut-release-branch.yml
index 466e959be20..48564d6ec18 100644
--- a/.github/workflows/cut-release-branch.yml
+++ b/.github/workflows/cut-release-branch.yml
@@ -53,8 +53,12 @@ jobs:
core.setOutput('branch', branch);
core.setOutput('next', String(next));
+ core.setOutput('nextMilestone', String(next + 1));
core.setOutput('needsRequirementsUpdate', String(needsRequirementsUpdate));
+ # Pushing the new branch triggers set-milestone.yml, which does the
+ # full milestone backfill and then dispatches release-notes-preview
+ # to upload the markdown to #writing.
- name: Cut the branch
id: cut
run: |
@@ -76,6 +80,103 @@ jobs:
--body "${{ steps.preflight.outputs.next }}" \
--repo "${{ github.repository }}"
+ # Pre-create the milestone for the version AFTER this cut, so it's
+ # already open when next time's backfill needs somewhere to assign
+ # issues. The milestone for THIS cut (0.{next}) is expected to exist
+ # from the previous run of this workflow.
+ - name: Create 0.${{ steps.preflight.outputs.nextMilestone }} milestone
+ id: milestone
+ continue-on-error: true
+ uses: actions/github-script@v7
+ with:
+ github-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
+ script: | # js
+ const title = '0.${{ steps.preflight.outputs.nextMilestone }}';
+
+ try {
+ await github.rest.issues.createMilestone({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ title,
+ });
+ console.log(`Created milestone ${title}`);
+ } catch (err) {
+ if (err.status === 422) {
+ console.log(`Milestone ${title} already exists — skipping`);
+ return;
+ }
+ throw err;
+ }
+
+ # Same logic as the milestone above: Bug:v{next} should already exist
+ # from the previous run; we pre-create Bug:v{next+1} for next time.
+ - name: Create Bug:v${{ steps.preflight.outputs.nextMilestone }} label
+ id: label
+ continue-on-error: true
+ uses: actions/github-script@v7
+ with:
+ github-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
+ script: | # js
+ const nextMilestone = '${{ steps.preflight.outputs.nextMilestone }}';
+ const name = `Bug:v${nextMilestone}`;
+ const color = Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0');
+
+ try {
+ await github.rest.issues.createLabel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ name,
+ color,
+ description: `bugs or regressions introduced in v${nextMilestone}`,
+ });
+ console.log(`Created label ${name} (#${color})`);
+ } catch (err) {
+ if (err.status === 422) {
+ console.log(`Label ${name} already exists — skipping`);
+ return;
+ }
+ throw err;
+ }
+
+ # Log the cut on stats.metabase.com so the release timeline picks it up.
+ # timeline_id 14 = the major releases timeline.
+ - name: Create stats Timeline event
+ id: timeline
+ continue-on-error: true
+ env:
+ STATS_API_KEY: ${{ secrets.STATS_API_KEY }}
+ uses: actions/github-script@v7
+ with:
+ script: | # js
+ const next = '${{ steps.preflight.outputs.next }}';
+ const name = `x.${next}.0`;
+
+ const res = await fetch('https://stats.metabase.com/api/timeline-event', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'x-api-key': process.env.STATS_API_KEY,
+ },
+ body: JSON.stringify({
+ name,
+ description: 'Beta',
+ timestamp: new Date().toISOString(),
+ timeline_id: 14,
+ icon: 'star',
+ timezone: 'US/Pacific',
+ time_matters: false,
+ archived: false,
+ source: 'collections',
+ }),
+ });
+
+ if (!res.ok) {
+ const body = await res.text();
+ throw new Error(`Timeline event creation failed (${res.status}): ${body}`);
+ }
+
+ console.log(`Created timeline event ${name}`);
+
- name: Notify Slack
uses: actions/github-script@v7
env:
@@ -88,6 +189,9 @@ jobs:
const next = '${{ steps.preflight.outputs.next }}';
const sha = '${{ steps.cut.outputs.sha }}';
const bumpFailed = '${{ steps.bump.outcome }}' === 'failure';
+ const milestoneFailed = '${{ steps.milestone.outcome }}' === 'failure';
+ const labelFailed = '${{ steps.label.outcome }}' === 'failure';
+ const timelineFailed = '${{ steps.timeline.outcome }}' === 'failure';
const needsReqs = '${{ steps.preflight.outputs.needsRequirementsUpdate }}' === 'true';
const owner = context.repo.owner;
@@ -95,19 +199,80 @@ jobs:
const shaLink = `<https://github.com/${owner}/${repo}/commit/${sha}|${sha.slice(0, 7)}>`;
const team = mentionSlackTeam('releasemanagers');
+ const embedding = mentionSlackTeam('embedding-devs');
+ const embeddingChecklist = 'https://www.notion.so/metabase/Embedding-Checklist-What-to-do-after-cutting-a-new-release-branch-20269354c90180808329eab86e59f20d';
const notes = [
bumpFailed
? `:warning: Auto-bump of \`CURRENT_VERSION\` to *${next}* failed — please update it manually: <https://github.com/${owner}/${repo}/settings/variables/actions|Actions variables>`
: `\`CURRENT_VERSION\` bumped to *${next}*.`,
+ milestoneFailed
+ ? `:warning: Pre-creating milestone \`0.${{ steps.preflight.outputs.nextMilestone }}\` (for the next cut) failed — please create it manually: <https://github.com/${owner}/${repo}/milestones|Repository milestones>`
+ : null,
+ labelFailed
+ ? `:warning: Pre-creating label \`Bug:v${{ steps.preflight.outputs.nextMilestone }}\` (for the next cut) failed — please create it manually: <https://github.com/${owner}/${repo}/labels|Repository labels>`
+ : null,
+ timelineFailed
+ ? `:warning: Logging the cut to the <https://stats.metabase.com|stats> release timeline failed — please add an \`x.${next}.0\` event manually.`
+ : null,
needsReqs
? `:warning: Please add \`versionRequirements[${next}]\` to \`release/src/version-helpers.ts\` (java + node + platforms).`
: null,
].filter(Boolean).join('\n');
- const message = `:tree_evergreen: Cut new release branch *${branch}* at ${shaLink} ${team}\n${notes}`;
+ const message = [
+ `:evergreen_tree: A new release branch *${branch}* cut at ${shaLink} ${team}`,
+ notes,
+ `${embedding} please run the <${embeddingChecklist}|Embedding Checklist>.`,
+ ].filter(Boolean).join('\n');
await sendSlackMessage({
channelName: '${{ vars.SLACK_RELEASE_CHANNEL }}',
message,
}).catch(console.error);
+
+ # Heads-up to the broader eng audience about where backports go now.
+ - name: Notify the engineering team
+ uses: actions/github-script@v7
+ env:
+ SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
+ with:
+ script: | # js
+ const { sendSlackMessage, mentionSlackTeam } = require('${{ github.workspace }}/release/dist/index.cjs');
+
+ const next = Number('${{ steps.preflight.outputs.next }}');
+ const current = next - 1;
+ const eng = mentionSlackTeam('engineering');
+
+ const message = [
+ `:announcement-animated: ${eng} The v${next} release branch has been cut.`,
+ `- \`backport\`s will go to v${next} now`,
+ `- If you want to go back to v${current}, you'll need to add the double-backport tag`,
+ ].join('\n');
+
+ await sendSlackMessage({
+ channelName: 'team-engineering',
+ message,
+ }).catch(console.error);
+
+ # `failure()` fires when any previous step without continue-on-error
+ # fails — preflight, the cut itself, or the surrounding setup steps.
+ # The post-cut steps (bump, milestone, label, timeline) set
+ # continue-on-error and surface their own failures as warnings in
+ # the happy-path message above.
+ - name: Notify Slack on cut failure
+ if: failure()
+ uses: actions/github-script@v7
+ env:
+ SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
+ with:
+ script: | # js
+ const { sendSlackMessage, mentionSlackTeam } = require('${{ github.workspace }}/release/dist/index.cjs');
+
+ const team = mentionSlackTeam('releasemanagers');
+ const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
+
+ await sendSlackMessage({
+ channelName: '${{ vars.SLACK_RELEASE_CHANNEL }}',
+ message: `:rotating_light: Cutting next release branch failed — see <${runUrl}|run logs> ${team}`,
+ }).catch(console.error);
diff --git a/.github/workflows/release-notes-preview.yml b/.github/workflows/release-notes-preview.yml
index 5dcac45a5c5..16ced5ee1e0 100644
--- a/.github/workflows/release-notes-preview.yml
+++ b/.github/workflows/release-notes-preview.yml
@@ -8,6 +8,11 @@ on:
description: 'Metabase version (e.g. v0.46.3)'
type: string
required: true
+ slackChannel:
+ description: 'Optional Slack channel to upload the markdown to (e.g. writing). When unset, the markdown is only available as a workflow artifact.'
+ type: string
+ required: false
+ default: ''
jobs:
preview-release-notes:
@@ -60,3 +65,24 @@ jobs:
name: release-notes-preview-${{inputs.version}}.md
path: |
${{ github.workspace }}/release-notes-preview-*.md
+
+ - name: Post release notes preview to Slack
+ if: ${{ inputs.slackChannel != '' }}
+ uses: actions/github-script@v7
+ env:
+ SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
+ with:
+ script: | # js
+ const fs = require('fs');
+ const { uploadFileToSlack } = require('${{ github.workspace }}/release/dist/index.cjs');
+
+ const version = '${{ inputs.version }}';
+ const fileName = `release-notes-preview-${version}.md`;
+ const file = fs.readFileSync(`${{ github.workspace }}/${fileName}`);
+
+ await uploadFileToSlack({
+ channelName: '${{ inputs.slackChannel }}',
+ fileName,
+ file,
+ message: `:page_with_curl: Release notes preview for *${version}* — ready for editing.`,
+ });
diff --git a/.github/workflows/set-milestone.yml b/.github/workflows/set-milestone.yml
new file mode 100644
index 00000000000..8262baffe9a
--- /dev/null
+++ b/.github/workflows/set-milestone.yml
@@ -0,0 +1,131 @@
+name: Automatically set milestone
+run-name: Set milestone for ${{ github.event.head_commit.message || inputs.version }}
+
+on:
+ push:
+ branches:
+ - release-x.**
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Major version number (e.g. 52, 78, 109)'
+ type: number
+ required: true
+
+jobs:
+ set-milestone:
+ name: Automatically set milestone
+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
+ timeout-minutes: 30
+ permissions:
+ pull-requests: write
+ issues: write
+ contents: read
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ sparse-checkout: |
+ release
+ .github
+ # Single-commit path only needs 3 commits; both backfill paths need
+ # full history to compute the merge-base with master.
+ fetch-depth: ${{ (github.event_name == 'push' && github.event.created != true) && 3 || 0 }}
+ ref: master # we want the logic from master, even though we're triggering on a release branch
+
+ - name: Prepare release scripts
+ uses: ./.github/actions/prepare-release-scripts
+
+ # Resolve the major version we're operating on. For workflow_dispatch
+ # it comes straight from inputs.version; for a push it's parsed from
+ # the branch ref (refs/heads/release-x.{N}.x).
+ - name: Resolve version
+ id: version
+ run: |
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
+ MAJOR="${{ inputs.version }}"
+ else
+ REF="${{ github.ref_name }}"
+ MAJOR="${REF#release-x.}"
+ MAJOR="${MAJOR%.x}"
+ fi
+ echo "major=$MAJOR" >> "$GITHUB_OUTPUT"
+
+ # Backport push to an existing release branch: milestone the single
+ # commit that was just pushed.
+ #
+ # `github.event.created` is a documented top-level field on the push
+ # webhook payload (true iff the push created the ref). See:
+ # https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
+ - uses: actions/github-script@v7
+ if: ${{ github.event_name == 'push' && github.event.created != true }}
+ name: Set milestone for single commit
+ with:
+ script: | # js
+ const { setMilestoneForCommits } = require('${{ github.workspace }}/release/dist/index.cjs');
+ const owner = context.repo.owner;
+ const repo = context.repo.repo;
+
+ const branchName = `${{ github.ref }}`;
+ const commitMessage = context?.payload?.head_commit?.message ?? '';
+
+ await setMilestoneForCommits({
+ github,
+ owner,
+ repo,
+ branchName,
+ commitMessages: [commitMessage],
+ });
+
+ # Full backfill — assigns milestone 0.{major} to every PR/issue whose
+ # commit landed on master between the previous release branch forking
+ # point and this branch. Fires for:
+ # - Fresh-cut pushes (the canonical signal of a new release branch)
+ # - Manual workflow_dispatch (ad-hoc re-runs to pick up misses)
+ - name: Get commit messages for release branch
+ if: ${{ (github.event_name == 'push' && github.event.created == true) || github.event_name == 'workflow_dispatch' }}
+ run: |
+ npm i -g tsx
+ tsx release/src/release-branch-commits.ts ${{ steps.version.outputs.major }} > commit-messages.json
+
+ - uses: actions/github-script@v7
+ if: ${{ (github.event_name == 'push' && github.event.created == true) || github.event_name == 'workflow_dispatch' }}
+ name: Backfill milestones for release branch
+ env:
+ # this token has a higher rate limit than the default token, and
+ # we will need it for this workflow to work
+ GITHUB_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
+ with:
+ script: | # js
+ const { setMilestoneForCommits } = require('${{ github.workspace }}/release/dist/index.cjs');
+ const commitMessages = require('${{ github.workspace }}/commit-messages.json');
+
+ const owner = context.repo.owner;
+ const repo = context.repo.repo;
+
+ const versionNumber = '${{ steps.version.outputs.major }}';
+ const branchName = `release-x.${versionNumber}.x`;
+
+ console.log(`Found ${commitMessages.length} new commits for ${branchName}`);
+
+ await setMilestoneForCommits({
+ github,
+ owner,
+ repo,
+ branchName,
+ commitMessages: commitMessages,
+ ignoreExistingMilestones: true,
+ });
+
+ # Fresh-cut only: now that the milestone is populated, dispatch
+ # release-notes-preview to post the markdown to #writing.
+ # Manual workflow_dispatch backfills skip this — they're for catching
+ # missed commits, not for pinging writers again.
+ - name: Trigger release notes preview for the writing team
+ if: ${{ github.event_name == 'push' && github.event.created == true }}
+ env:
+ GH_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
+ run: |
+ gh workflow run release-notes-preview.yml \
+ -f version=v0.${{ steps.version.outputs.major }}.0 \
+ -f slackChannel=writing \
+ --repo "${{ github.repository }}"
diff --git a/release/github-slack-map.json b/release/github-slack-map.json
index 1b962b607fa..3cacf451d7d 100644
--- a/release/github-slack-map.json
+++ b/release/github-slack-map.json
@@ -118,5 +118,6 @@
"tech-writers": "S078147J78S",
"successengineers": "S05AAL8PUA1",
"growth": "S056LQCRQG5",
- "core-release": "S02UJK9DN59"
+ "core-release": "S02UJK9DN59",
+ "engineering": "S03BXTD2PCJ"
}
diff --git a/release/src/slack.ts b/release/src/slack.ts
index 60559727f7d..f168f1a624d 100644
--- a/release/src/slack.ts
+++ b/release/src/slack.ts
@@ -538,7 +538,7 @@ export async function sendFlakeStatusReport({
* 2) make an http POST request to that url with the file
* 3) make an api call to "complete" the upload and post it somewhere in slack
*/
-async function uploadFileToSlack({
+export async function uploadFileToSlack({
channelName,
thread_ts,
fileName,