mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-07 05:22:56 +00:00
## Problem We can't have more than one open release PR created on the same day (due to non-unique enough branch names). ## Summary of changes - Add time (hours and minutes) to RC PR branch names - Also make sure we use UTC for releases
104 lines
3.3 KiB
YAML
104 lines
3.3 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}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
create-release-branch:
|
|
runs-on: ubuntu-22.04
|
|
|
|
permissions:
|
|
contents: write # for `git push`
|
|
|
|
steps:
|
|
- name: Harden the runner (Audit all outbound calls)
|
|
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
ref: ${{ inputs.source-branch }}
|
|
fetch-depth: 0
|
|
|
|
- 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: |
|
|
now_date=$(date -u +'%Y-%m-%d')
|
|
now_time=$(date -u +'%H-%M-%Z')
|
|
{
|
|
echo "title=${COMPONENT_NAME} release ${now_date}"
|
|
echo "rc-branch=rc/${RELEASE_BRANCH}/${now_date}_${now_time}"
|
|
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 "origin/${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}" \
|
|
--body "" \
|
|
--head "${RC_BRANCH}" \
|
|
--base "${RELEASE_BRANCH}"
|