From 6c078fe34328b05aefe74e4d5b7164c2e122eb01 Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Fri, 15 Dec 2023 07:30:15 -0500 Subject: [PATCH] Update version bump workflow (#2905) --- .github/workflows/_cut_rc.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/version-bump.yml | 21 +++++++++++++-------- 2 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/_cut_rc.yml diff --git a/.github/workflows/_cut_rc.yml b/.github/workflows/_cut_rc.yml new file mode 100644 index 000000000..d869a3dc0 --- /dev/null +++ b/.github/workflows/_cut_rc.yml @@ -0,0 +1,29 @@ +--- +name: Cut RC Branch + +on: + workflow_call: + +jobs: + cut-rc: + name: Cut RC branch + runs-on: ubuntu-22.04 + steps: + - name: Checkout Branch + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: main + + - name: Check if RC branch exists + run: | + remote_rc_branch_check=$(git ls-remote --heads origin rc | wc -l) + if [[ "${remote_rc_branch_check}" -gt 0 ]]; then + echo "Remote RC branch exists." + echo "Please delete current RC branch before running again." + exit 1 + fi + + - name: Cut RC branch + run: | + git switch --quiet --create rc + git push --quiet --set-upstream origin rc diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 8d04c8c5e..cda7c841f 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -3,17 +3,15 @@ name: Version Bump run-name: Version Bump - v${{ inputs.version_number }} on: - workflow_call: - inputs: - version_number: - description: "New version (example: '2024.1.0')" - required: true - type: string workflow_dispatch: inputs: version_number: description: "New version (example: '2024.1.0')" required: true + cut_rc_branch: + description: "Cut RC branch?" + default: true + type: boolean jobs: bump_version: @@ -37,9 +35,8 @@ jobs: - name: Checkout Branch uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: - repository: bitwarden/mobile ref: main - token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} + repository: bitwarden/mobile - name: Import GPG key uses: crazy-max/ghaction-import-gpg@d6f3f49f3345e29369fe57596a3ca8f94c4d2ca7 # v5.4.0 @@ -142,6 +139,7 @@ jobs: if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} id: create-pr env: + GH_TOKEN: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} PR_BRANCH: ${{ steps.create-branch.outputs.name }} TITLE: "Bump version to ${{ inputs.version_number }}" run: | @@ -173,3 +171,10 @@ jobs: GH_TOKEN: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} PR_NUMBER: ${{ steps.create-pr.outputs.pr_number }} run: gh pr merge $PR_NUMBER --squash --auto --delete-branch + + cut_rc: + name: Cut RC Branch + if: ${{ inputs.cut_rc_branch == true }} + needs: bump_version + uses: ./.github/workflows/_cut_rc.yml + secrets: inherit