From 5bc5dba532979031b4e549bdfaff21490efc6dbd Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Mon, 15 Apr 2024 17:28:52 +0200 Subject: [PATCH] initial structure --- .github/workflows/release.yml | 103 ++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 37 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ef84947da..c1300f12bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,32 +15,33 @@ on: jobs: + setup: + runs-on: ubuntu-latest + outputs: + creates_new_tag: ${{ steps.condition_check.outputs.creates_new_tag }} + is_official_release: ${{ steps.condition_check.outputs.is_official_release }} + runs_tests: ${{ steps.condition_check.outputs.runs_tests }} + steps: + - id: condition_check + run: | + echo "creates_new_tag=$(if [ '${{ inputs.use_existing_tag }}' = 'true' ]; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_ENV + echo "is_official_release=$(if echo '${{ inputs.version_number }}' | grep -q 'pre'; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_ENV + echo "runs_tests=$(if [ '${{ inputs.skip_tests }}' = 'true' ]; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_ENV + validate-version-input: runs-on: ubuntu-latest steps: - name: Validation of version format run: | - echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$' + echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$' - run-qa-acceptance-tests: - needs: [ validate-version-input ] - # QA acceptance tests are skipped when explicit input parameter is used - # As this job may be skipped following jobs require using 'always()' to make sure they are still run - if: needs.validate-version-input.result == 'success' && inputs.skip_tests != 'true' - secrets: inherit - uses: ./.github/workflows/acceptance-tests.yml - with: - atlas_cloud_env: "qa" - ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || github.ref }} - update-examples-reference-in-docs: - needs: [ validate-version-input, run-qa-acceptance-tests ] + needs: [ setup, validate-version-input ] if: >- always() - && inputs.use_existing_tag != 'true' - && !contains(inputs.version_number, 'pre') - && needs.validate-version-input.result == 'success' - && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') + && needs.setup.outputs.creates_new_tag + && needs.setup.outputs.is_official_release + && needs.validate-version-input.result == 'success' uses: ./.github/workflows/run-script-and-commit.yml with: script_call: './scripts/update-examples-reference-in-docs.sh ${{inputs.version_number}}' @@ -50,13 +51,12 @@ jobs: user_name: 'releasebot' update-changelog-header: - needs: [ validate-version-input, run-qa-acceptance-tests, update-examples-reference-in-docs ] + needs: [ setup, validate-version-input, update-examples-reference-in-docs ] if: >- always() - && inputs.use_existing_tag != 'true' - && !contains(inputs.version_number, 'pre') - && needs.validate-version-input.result == 'success' - && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') + && needs.setup.outputs.creates_new_tag + && needs.setup.outputs.is_official_release + && needs.validate-version-input.result == 'success' uses: ./.github/workflows/run-script-and-commit.yml with: script_call: './scripts/update-changelog-header-for-release.sh ${{inputs.version_number}}' @@ -64,24 +64,19 @@ jobs: commit_message: 'Update CHANGELOG.md header for ${{ github.event.inputs.version_number }} release' user_email: 'releasebot@mongodb.com' user_name: 'releasebot' - - release: + + create-tag: runs-on: ubuntu-latest - needs: [ validate-version-input, run-qa-acceptance-tests, update-examples-reference-in-docs, update-changelog-header ] - # Release is skipped if there are failures in previous steps - if: >- + needs: [ setup, validate-version-input, update-examples-reference-in-docs, update-changelog-header ] + if: >- always() - && needs.validate-version-input.result == 'success' - && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') + && needs.setup.outputs.creates_new_tag + && needs.validate-version-input.result == 'success' && (needs.update-examples-reference-in-docs.result == 'skipped' || needs.update-examples-reference-in-docs.result == 'success') && (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success') - steps: + steps: - name: Checkout uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - with: - ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || 'master' }} - - name: Unshallow - run: git fetch --prune --unshallow - name: Get the latest commit SHA id: get-sha run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" @@ -92,7 +87,38 @@ jobs: commit_sha: ${{ steps.get-sha.outputs.sha }} gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} gpg_passphrase: ${{ secrets.PASSPHRASE }} - tag_exists_error: ${{ inputs.use_existing_tag != 'true' }} + + run-qa-acceptance-tests: + needs: [ setup, validate-version-input, update-examples-reference-in-docs, update-changelog-header, create-tag ] + if: >- + always() + && needs.setup.outputs.runs_tests + && needs.validate-version-input.result == 'success' + && (needs.update-examples-reference-in-docs.result == 'skipped' || needs.update-examples-reference-in-docs.result == 'success') + && (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success') + && (needs.create-tag.result == 'skipped' || needs.create-tag.result == 'success') + secrets: inherit + uses: ./.github/workflows/acceptance-tests.yml + with: + atlas_cloud_env: "qa" + ref: ${{ inputs.version_number }} + + release: + runs-on: ubuntu-latest + needs: [ validate-version-input, update-examples-reference-in-docs, update-changelog-header, create-tag, run-qa-acceptance-tests ] + # Release is skipped if there are failures in previous steps + if: >- + always() + && needs.validate-version-input.result == 'success' + && (needs.update-examples-reference-in-docs.result == 'skipped' || needs.update-examples-reference-in-docs.result == 'success') + && (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success') + && (needs.create-tag.result == 'skipped' || needs.create-tag.result == 'success') + && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') + steps: + - name: Checkout + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + with: + ref: ${{ inputs.version_number }} - name: Set up Go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: @@ -113,9 +139,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jira-release-version: - if: ${{ !contains(inputs.version_number, 'pre') }} - needs: [ release ] runs-on: ubuntu-latest + needs: [ setup, release ] + if: >- + always() + && needs.setup.outputs.is_official_release + && needs.release.result == 'success' steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491