mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-08 22:12:56 +00:00
## Problem When we release our components, we perform builds in the release PR, then test the components, then merge the PR, and then build everything *again*, run tests *again*, and only then start deployments. To speed things up, we want to perform builds and run tests in the PR, and start deployments using the existing artifacts from the release PR. To make that possible, we need to have both CI pipelines running on the same commit hash, which requires fast forwarding release. That only works, if we have a commit in the PR that has the current release branch state as an ancestor. ## Summary of changes - Changes to release PR creation: - Remove templates and automatic bodies for release PRs. The previous template wasn't used anymore, and the automatic body we created in the pipeline didn't contain any useful content anymore after the changees here. - Make it possible to select the source branch. For releases that aren't cut from `main`, like https://github.com/neondatabase/neon/pull/11051, we need a way to trigger the new flow from a different branch. - Determine `release-branch` automatically from the component name instead of passing that as well. - Changes to the merge queue job: - Rename `get-changed-files` to `meta` in preparation of additional data being fetched as part of that job - Fail the merge queue if we're trying to merge into a branch other than main - this is to prevent non-fast-forward merges. - Label PRs to branches other than main as `fast-forward`, to trigger the fast-forward job - Add a fast-forward job that can be triggered with the `fast-forward` label that performs a fast-forward merge. This only happens if the PR has `mergeable_state == clean`, so CI having passed. - Build and Test on releases now skips building images, skips testing images and skips triggering e2e tests. We add new tags to the images from the release PR to tag them as release images, and we push them to the prod registries.
91 lines
3.0 KiB
YAML
91 lines
3.0 KiB
YAML
name: Create Release PR
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
component-name:
|
|
description: 'Component name'
|
|
required: true
|
|
type: string
|
|
source-branch:
|
|
description: 'Source branch'
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
ci-access-token:
|
|
description: 'CI access token'
|
|
required: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash -euo pipefail {0}
|
|
|
|
jobs:
|
|
create-release-branch:
|
|
runs-on: ubuntu-22.04
|
|
|
|
permissions:
|
|
contents: write # for `git push`
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.source-branch }}
|
|
|
|
- name: Set variables
|
|
id: vars
|
|
env:
|
|
COMPONENT_NAME: ${{ inputs.component-name }}
|
|
RELEASE_BRANCH: >-
|
|
${{
|
|
false
|
|
|| inputs.component-name == 'Storage' && 'release'
|
|
|| inputs.component-name == 'Proxy' && 'release-proxy'
|
|
|| inputs.component-name == 'Compute' && 'release-compute'
|
|
}}
|
|
run: |
|
|
today=$(date +'%Y-%m-%d')
|
|
echo "title=${COMPONENT_NAME} release ${today}" | tee -a ${GITHUB_OUTPUT}
|
|
echo "rc-branch=rc/${RELEASE_BRANCH}/${today}" | tee -a ${GITHUB_OUTPUT}
|
|
echo "release-branch=${RELEASE_BRANCH}" | tee -a ${GITHUB_OUTPUT}
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
- name: Create RC branch
|
|
env:
|
|
RELEASE_BRANCH: ${{ steps.vars.outputs.release-branch }}
|
|
RC_BRANCH: ${{ steps.vars.outputs.rc-branch }}
|
|
TITLE: ${{ steps.vars.outputs.title }}
|
|
run: |
|
|
git switch -c "${RC_BRANCH}"
|
|
|
|
# Manually create a merge commit on the current branch, keeping the
|
|
# tree and setting the parents to the current HEAD and the HEAD of the
|
|
# release branch. This commit is what we'll fast-forward the release
|
|
# branch to when merging the release branch.
|
|
# For details on why, look at
|
|
# https://docs.neon.build/overview/repositories/neon.html#background-on-commit-history-of-release-prs
|
|
current_tree=$(git rev-parse 'HEAD^{tree}')
|
|
release_head=$(git rev-parse "${RELEASE_BRANCH}")
|
|
current_head=$(git rev-parse HEAD)
|
|
merge_commit=$(git commit-tree -p "${current_head}" -p "${release_head}" -m "${TITLE}" "${current_tree}")
|
|
|
|
# Fast-forward the current branch to the newly created merge_commit
|
|
git merge --ff-only ${merge_commit}
|
|
|
|
git push origin "${RC_BRANCH}"
|
|
|
|
- name: Create a PR into ${{ steps.vars.outputs.release-branch }}
|
|
env:
|
|
GH_TOKEN: ${{ secrets.ci-access-token }}
|
|
RC_BRANCH: ${{ steps.vars.outputs.rc-branch }}
|
|
RELEASE_BRANCH: ${{ steps.vars.outputs.release-branch }}
|
|
TITLE: ${{ steps.vars.outputs.title }}
|
|
run: |
|
|
gh pr create --title "${TITLE}" \
|
|
--head "${RC_BRANCH}" \
|
|
--base "${RELEASE_BRANCH}"
|