-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Version Bump workflow to push directly to main
- Loading branch information
Showing
1 changed file
with
10 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,67 +7,34 @@ on: | |
description: "New version override (leave blank for automatic calculation, example: '2024.1.0')" | ||
required: false | ||
type: string | ||
enable_slack_notification: | ||
description: "Enable Slack notifications for upcoming release?" | ||
default: false | ||
type: boolean | ||
|
||
jobs: | ||
bump_version: | ||
name: Bump Version | ||
runs-on: ubuntu-24.04 | ||
outputs: | ||
version: ${{ steps.set-final-version-output.outputs.version }} | ||
steps: | ||
- name: Validate version input | ||
if: ${{ inputs.version_number_override != '' }} | ||
uses: bitwarden/gh-actions/version-check@main | ||
with: | ||
version: ${{ inputs.version_number_override }} | ||
|
||
- name: Slack Notification Check | ||
run: | | ||
if [[ "${{ inputs.enable_slack_notification }}" == true ]]; then | ||
echo "Slack notifications enabled." | ||
else | ||
echo "Slack notifications disabled." | ||
fi | ||
- name: Generate GH App token | ||
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0 | ||
id: app-token | ||
with: | ||
app-id: ${{ secrets.BW_GHAPP_ID }} | ||
private-key: ${{ secrets.BW_GHAPP_KEY }} | ||
|
||
- name: Checkout Branch | ||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | ||
|
||
- name: Login to Azure - CI Subscription | ||
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 | ||
with: | ||
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} | ||
|
||
- name: Retrieve secrets | ||
id: retrieve-secrets | ||
uses: bitwarden/gh-actions/get-keyvault-secrets@main | ||
with: | ||
keyvault: "bitwarden-ci" | ||
secrets: "github-gpg-private-key, | ||
github-gpg-private-key-passphrase" | ||
|
||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 | ||
with: | ||
gpg_private_key: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key }} | ||
passphrase: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key-passphrase }} | ||
git_user_signingkey: true | ||
git_commit_gpgsign: true | ||
token: ${{ steps.app-token.outputs.token }} | ||
|
||
- name: Setup git | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "bitwarden-devops-bot" | ||
- name: Create Version Branch | ||
id: create-branch | ||
run: | | ||
NAME=version_bump_${{ github.ref_name }}_$(date +"%Y-%m-%d") | ||
git switch -c $NAME | ||
echo "name=$NAME" >> $GITHUB_OUTPUT | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
- name: Get current version | ||
id: current-version | ||
|
@@ -144,61 +111,4 @@ jobs: | |
|
||
- name: Push changes | ||
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} | ||
env: | ||
PR_BRANCH: ${{ steps.create-branch.outputs.name }} | ||
run: git push -u origin $PR_BRANCH | ||
|
||
- name: Generate GH App token | ||
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0 | ||
id: app-token | ||
with: | ||
app-id: ${{ secrets.BW_GHAPP_ID }} | ||
private-key: ${{ secrets.BW_GHAPP_KEY }} | ||
owner: ${{ github.repository_owner }} | ||
|
||
- name: Create Version PR | ||
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} | ||
id: create-pr | ||
env: | ||
GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
PR_BRANCH: ${{ steps.create-branch.outputs.name }} | ||
TITLE: "Bump version to ${{ steps.set-final-version-output.outputs.version }}" | ||
run: | | ||
PR_URL=$(gh pr create --title "$TITLE" \ | ||
--base "main" \ | ||
--head "$PR_BRANCH" \ | ||
--label "version update" \ | ||
--label "automated pr" \ | ||
--body " | ||
## Type of change | ||
- [ ] Bug fix | ||
- [ ] New feature development | ||
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) | ||
- [ ] Build/deploy pipeline (DevOps) | ||
- [X] Other | ||
## Objective | ||
Automated version bump to ${{ steps.set-final-version-output.outputs.version }}") | ||
echo "pr_number=${PR_URL##*/}" >> $GITHUB_OUTPUT | ||
- name: Approve PR | ||
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PR_NUMBER: ${{ steps.create-pr.outputs.pr_number }} | ||
run: gh pr review $PR_NUMBER --approve | ||
|
||
- name: Merge PR | ||
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} | ||
env: | ||
GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
PR_NUMBER: ${{ steps.create-pr.outputs.pr_number }} | ||
run: gh pr merge $PR_NUMBER --squash --auto --delete-branch | ||
|
||
- name: Report upcoming release version to Slack | ||
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' && inputs.enable_slack_notification == true }} | ||
uses: bitwarden/gh-actions/report-upcoming-release-version@main | ||
with: | ||
version: ${{ steps.set-final-version-output.outputs.version }} | ||
project: ${{ github.repository }} | ||
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} | ||
run: git push |