mirror of
https://github.com/bitwarden/server.git
synced 2025-06-19 10:28:09 -05:00
build(ci): remove the need to cherry pick version bumps to rc (#5977)
This commit is contained in:
parent
05d74754d2
commit
91b4ef756b
125
.github/workflows/repository-management.yml
vendored
125
.github/workflows/repository-management.yml
vendored
@ -22,6 +22,8 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
setup:
|
setup:
|
||||||
name: Setup
|
name: Setup
|
||||||
@ -44,49 +46,11 @@ jobs:
|
|||||||
|
|
||||||
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
|
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
|
||||||
cut_branch:
|
|
||||||
name: Cut branch
|
|
||||||
if: ${{ needs.setup.outputs.branch != 'none' }}
|
|
||||||
needs: setup
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- name: Generate GH App token
|
|
||||||
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
|
|
||||||
id: app-token
|
|
||||||
with:
|
|
||||||
app-id: ${{ secrets.BW_GHAPP_ID }}
|
|
||||||
private-key: ${{ secrets.BW_GHAPP_KEY }}
|
|
||||||
|
|
||||||
- name: Check out target ref
|
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
||||||
with:
|
|
||||||
ref: ${{ inputs.target_ref }}
|
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
|
||||||
|
|
||||||
- name: Check if ${{ needs.setup.outputs.branch }} branch exists
|
|
||||||
env:
|
|
||||||
BRANCH_NAME: ${{ needs.setup.outputs.branch }}
|
|
||||||
run: |
|
|
||||||
if [[ $(git ls-remote --heads origin $BRANCH_NAME) ]]; then
|
|
||||||
echo "$BRANCH_NAME already exists! Please delete $BRANCH_NAME before running again." >> $GITHUB_STEP_SUMMARY
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Cut branch
|
|
||||||
env:
|
|
||||||
BRANCH_NAME: ${{ needs.setup.outputs.branch }}
|
|
||||||
run: |
|
|
||||||
git switch --quiet --create $BRANCH_NAME
|
|
||||||
git push --quiet --set-upstream origin $BRANCH_NAME
|
|
||||||
|
|
||||||
|
|
||||||
bump_version:
|
bump_version:
|
||||||
name: Bump Version
|
name: Bump Version
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs:
|
needs:
|
||||||
- cut_branch
|
|
||||||
- setup
|
- setup
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.set-final-version-output.outputs.version }}
|
version: ${{ steps.set-final-version-output.outputs.version }}
|
||||||
@ -187,14 +151,13 @@ jobs:
|
|||||||
- name: Push changes
|
- name: Push changes
|
||||||
run: git push
|
run: git push
|
||||||
|
|
||||||
|
cut_branch:
|
||||||
cherry_pick:
|
name: Cut branch
|
||||||
name: Cherry-Pick Commit(s)
|
|
||||||
if: ${{ needs.setup.outputs.branch != 'none' }}
|
if: ${{ needs.setup.outputs.branch != 'none' }}
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
needs:
|
needs:
|
||||||
- bump_version
|
|
||||||
- setup
|
- setup
|
||||||
|
- bump_version
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Generate GH App token
|
- name: Generate GH App token
|
||||||
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
|
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
|
||||||
@ -203,78 +166,30 @@ jobs:
|
|||||||
app-id: ${{ secrets.BW_GHAPP_ID }}
|
app-id: ${{ secrets.BW_GHAPP_ID }}
|
||||||
private-key: ${{ secrets.BW_GHAPP_KEY }}
|
private-key: ${{ secrets.BW_GHAPP_KEY }}
|
||||||
|
|
||||||
- name: Check out main branch
|
- name: Check out target ref
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
ref: ${{ inputs.target_ref }}
|
||||||
ref: main
|
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
|
|
||||||
- name: Configure Git
|
- name: Check if ${{ needs.setup.outputs.branch }} branch exists
|
||||||
run: |
|
|
||||||
git config --local user.email "actions@github.com"
|
|
||||||
git config --local user.name "Github Actions"
|
|
||||||
|
|
||||||
- name: Install xmllint
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libxml2-utils
|
|
||||||
|
|
||||||
- name: Perform cherry-pick(s)
|
|
||||||
env:
|
env:
|
||||||
CUT_BRANCH: ${{ needs.setup.outputs.branch }}
|
BRANCH_NAME: ${{ needs.setup.outputs.branch }}
|
||||||
run: |
|
run: |
|
||||||
# Function for cherry-picking
|
if [[ $(git ls-remote --heads origin $BRANCH_NAME) ]]; then
|
||||||
cherry_pick () {
|
echo "$BRANCH_NAME already exists! Please delete $BRANCH_NAME before running again." >> $GITHUB_STEP_SUMMARY
|
||||||
local source_branch=$1
|
exit 1
|
||||||
local destination_branch=$2
|
|
||||||
|
|
||||||
# Get project commit/version from source branch
|
|
||||||
git switch $source_branch
|
|
||||||
SOURCE_COMMIT=$(git log --reverse --pretty=format:"%H" --max-count=1 Directory.Build.props)
|
|
||||||
SOURCE_VERSION=$(xmllint -xpath "/Project/PropertyGroup/Version/text()" Directory.Build.props)
|
|
||||||
|
|
||||||
# Get project commit/version from destination branch
|
|
||||||
git switch $destination_branch
|
|
||||||
DESTINATION_VERSION=$(xmllint -xpath "/Project/PropertyGroup/Version/text()" Directory.Build.props)
|
|
||||||
|
|
||||||
if [[ "$DESTINATION_VERSION" != "$SOURCE_VERSION" ]]; then
|
|
||||||
git cherry-pick --strategy-option=theirs -x $SOURCE_COMMIT
|
|
||||||
git push -u origin $destination_branch
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# If we are cutting 'hotfix-rc':
|
|
||||||
if [[ "$CUT_BRANCH" == "hotfix-rc" ]]; then
|
|
||||||
|
|
||||||
# If the 'rc' branch exists:
|
|
||||||
if [[ $(git ls-remote --heads origin rc) ]]; then
|
|
||||||
|
|
||||||
# Chery-pick from 'rc' into 'hotfix-rc'
|
|
||||||
cherry_pick rc hotfix-rc
|
|
||||||
|
|
||||||
# Cherry-pick from 'main' into 'rc'
|
|
||||||
cherry_pick main rc
|
|
||||||
|
|
||||||
# If the 'rc' branch does not exist:
|
|
||||||
else
|
|
||||||
|
|
||||||
# Cherry-pick from 'main' into 'hotfix-rc'
|
|
||||||
cherry_pick main hotfix-rc
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If we are cutting 'rc':
|
|
||||||
elif [[ "$CUT_BRANCH" == "rc" ]]; then
|
|
||||||
|
|
||||||
# Cherry-pick from 'main' into 'rc'
|
|
||||||
cherry_pick main rc
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Cut branch
|
||||||
|
env:
|
||||||
|
BRANCH_NAME: ${{ needs.setup.outputs.branch }}
|
||||||
|
run: |
|
||||||
|
git switch --quiet --create $BRANCH_NAME
|
||||||
|
git push --quiet --set-upstream origin $BRANCH_NAME
|
||||||
|
|
||||||
move_future_db_scripts:
|
move_future_db_scripts:
|
||||||
name: Move finalization database scripts
|
name: Move finalization database scripts
|
||||||
needs: cherry_pick
|
needs: cut_branch
|
||||||
uses: ./.github/workflows/_move_finalization_db_scripts.yml
|
uses: ./.github/workflows/_move_finalization_db_scripts.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user