diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 95ecb6c9e..b848b9918 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -18,28 +18,14 @@ jobs: name: Bump Version runs-on: ubuntu-22.04 outputs: - version: ${{ steps.set-job-output.outputs.version }} + version: ${{ steps.set-final-version-output.outputs.version }} steps: - - name: Input validation + - name: Validate version input if: ${{ inputs.version_number_override != '' }} uses: bitwarden/gh-actions/version-check@main with: version: ${{ inputs.version_number_override }} - - name: Log in to Azure - CI subscription - uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 - 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, - github-pat-bitwarden-devops-bot-repo-scope" - - name: Check out branch uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: @@ -55,6 +41,20 @@ jobs: exit 1 fi + - name: Log in to Azure - CI subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + 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, + github-pat-bitwarden-devops-bot-repo-scope" + - name: Import GPG key uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0 with: @@ -63,6 +63,11 @@ jobs: git_user_signingkey: true git_commit_gpgsign: true + - name: Set up Git + run: | + git config --local user.email "106330231+bitwarden-devops-bot@users.noreply.github.com" + git config --local user.name "bitwarden-devops-bot" + - name: Create version branch id: create-branch run: | @@ -75,13 +80,18 @@ jobs: sudo apt-get update sudo apt-get install -y libxml2-utils + - name: Get current version + id: current-version + run: | + CURRENT_VERSION=$(xmllint -xpath "/Project/PropertyGroup/Version/text()" Directory.Build.props) + echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + - name: Verify input version if: ${{ inputs.version_number_override != '' }} env: + CURRENT_VERSION: ${{ steps.current-version.outputs.version }} NEW_VERSION: ${{ inputs.version_number_override }} run: | - CURRENT_VERSION=$(xmllint -xpath "/Project/PropertyGroup/Version/text()" Directory.Build.props) - # Error if version has not changed. if [[ "$NEW_VERSION" == "$CURRENT_VERSION" ]]; then echo "Version has not changed." @@ -97,6 +107,13 @@ jobs: exit 1 fi + - name: Calculate next release version + if: ${{ inputs.version_number_override == '' }} + id: calculate-next-version + uses: bitwarden/gh-actions/version-next@main + with: + version: ${{ steps.current-version.outputs.version }} + - name: Bump version props - Version Override if: ${{ inputs.version_number_override != '' }} id: bump-version-override @@ -111,21 +128,17 @@ jobs: uses: bitwarden/gh-actions/version-bump@main with: file_path: "Directory.Build.props" + version: ${{ steps.calculate-next-version.outputs.version }} - - name: Set Job output - id: set-job-output + - name: Set final version output + id: set-final-version-output run: | - if [[ "${{ steps.bump-version-override.outcome }}" == "success" ]]; then - echo "version=${{ steps.bump-version-override.outputs.version }}" >> $GITHUB_OUTPUT - elif [[ "${{ steps.bump-version-automatic.outcome }}" == "success" ]]; then - echo "version=${{ steps.bump-version-automatic.outputs.version }}" >> $GITHUB_OUTPUT + if [[ "${{ steps.bump-version-override.outcome }}" = "success" ]]; then + echo "version=${{ inputs.version_number_override }}" >> $GITHUB_OUTPUT + elif [[ "${{ steps.bump-version-automatic.outcome }}" = "success" ]]; then + echo "version=${{ steps.calculate-next-version.outputs.version }}" >> $GITHUB_OUTPUT fi - - name: Set up Git - run: | - git config --local user.email "106330231+bitwarden-devops-bot@users.noreply.github.com" - git config --local user.name "bitwarden-devops-bot" - - name: Check if version changed id: version-changed run: | @@ -138,7 +151,7 @@ jobs: - name: Commit files if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} - run: git commit -m "Bumped version to ${{ steps.set-job-output.outputs.version }}" -a + run: git commit -m "Bumped version to ${{ steps.set-final-version-output.outputs.version }}" -a - name: Push changes if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} @@ -152,7 +165,7 @@ jobs: 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 ${{ steps.set-job-output.outputs.version }}" + TITLE: "Bump version to ${{ steps.set-final-version-output.outputs.version }}" run: | PR_URL=$(gh pr create --title "$TITLE" \ --base "main" \ @@ -168,7 +181,7 @@ jobs: - [X] Other ## Objective - Automated version bump to ${{ steps.set-job-output.outputs.version }}") + Automated version bump to ${{ steps.set-final-version-output.outputs.version }}") echo "pr_number=${PR_URL##*/}" >> $GITHUB_OUTPUT - name: Approve PR