From fb5b3766cf9245be594e25dcdef42da1ccfda238 Mon Sep 17 00:00:00 2001 From: Oriol Date: Thu, 11 Apr 2024 10:31:29 +0200 Subject: [PATCH 1/5] chore: Adds workflow that generates changelog after PR is merged (#2128) * generate changelog after merge workflow * shell check * add make tools to install changelog-build * update docs * Update .github/workflows/generate-changelog.yml Co-authored-by: Agustin Bettati * trigger only on PR being merged on master branch * Update contributing/changelog-process.md Co-authored-by: Agustin Bettati * add section to index * add paths filter on action * Update contributing/changelog-process.md Co-authored-by: Marco Suma * Update .github/workflows/generate-changelog.yml Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * change GH action name in doc * change email to mongodb domain --------- Co-authored-by: Agustin Bettati Co-authored-by: Marco Suma Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> --- .github/workflows/generate-changelog.yml | 33 ++++++++++++++++++++++++ contributing/changelog-process.md | 6 +++++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/generate-changelog.yml diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml new file mode 100644 index 0000000000..a670334afb --- /dev/null +++ b/.github/workflows/generate-changelog.yml @@ -0,0 +1,33 @@ +name: Generate Changelog +on: + pull_request: + types: [closed] + branches: [master] + paths: + - .changelog/** + workflow_dispatch: +jobs: + generate-changelog: + if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + with: + fetch-depth: 0 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 + with: + go-version-file: 'go.mod' + - run: make tools update-changelog-unreleased-section + - run: | + if [[ $(git status --porcelain) ]]; then + if ${{github.event_name == 'workflow_dispatch'}}; then + MSG="Update CHANGELOG.md (Manual Trigger)" + else + MSG="Update CHANGELOG.md for #${{ github.event.pull_request.number }}" + fi + git config --local user.email changelogbot@mongodb.com + git config --local user.name changelogbot + git add CHANGELOG.md + git commit -m "$MSG" + git push + fi diff --git a/contributing/changelog-process.md b/contributing/changelog-process.md index 6a7273b230..38ebc46db6 100644 --- a/contributing/changelog-process.md +++ b/contributing/changelog-process.md @@ -4,6 +4,7 @@ - [Changelog entry guidelines](#changelog-entry-guidelines) - [Script for creating changelog entry files](#script-for-creating-changelog-entry-files) - [PR Changelog check](#pr-changelog-check) +- [Unreleased section of CHANGELOG.md automatic update](#unreleased-section-of-CHANGELOG.md-automatic-update) HashiCorp’s open-source projects have always maintained user-friendly, readable CHANGELOG.md that allow users to tell at a glance whether a release should have any effect on them, and to gauge the risk of an upgrade. @@ -151,3 +152,8 @@ A PR check is included to validate the changelog entry file. If a PR doesn't need a changelog entry its check can be skipped: - Adding the label `skip-changelog-check` to the PR. - Check in PRs with title `chore`, `test`, `doc` or `ci` is automatically skipped. However a changelog can still be added if needed. + +## Unreleased section of CHANGELOG.md automatic update + +After a PR is merged to master with a new entry in `.changelog` directory, [Generate Changelog workflow](https://github.com/mongodb/terraform-provider-mongodbatlas/actions/workflows/generate-changelog.yml) will be triggered and it will update the `CHANGELOG.md` file with the new entry. +This workflow can also be triggered manually and it will update the `CHANGELOG.md` file with all entries in `.changelog` directory that are not present in the `CHANGELOG.md` file. From 5da7cb39195fdf29ca25743a729161f17c07e044 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:56:47 +0200 Subject: [PATCH 2/5] doc: Updates Terraform Compatibility Matrix documentation (#2137) * doc: Updates Terraform Compatibility Matrix documentation * Trigger Build --------- Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> Co-authored-by: Oriol Arbusi --- website/docs/index.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index bd535a4835..06a8b98d54 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -185,6 +185,7 @@ For more information on configuring and managing programmatic API Keys see the [ | HashiCorp Terraform Release | HashiCorp Terraform Release Date | HashiCorp Terraform Full Support End Date | MongoDB Atlas Support End Date | |:-------:|:------------:|:------------:|:------------:| +| 1.8.x | 2024-04-10 | 2026-04-30 | 2026-04-30 | | 1.7.x | 2024-01-17 | 2026-01-31 | 2026-01-31 | | 1.6.x | 2023-10-04 | 2025-10-31 | 2025-10-31 | | 1.5.x | 2023-06-12 | 2025-06-30 | 2025-06-30 | From 66c44e62c9afe04ffe8be0dbccaec682bab830e6 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:32:03 +0200 Subject: [PATCH 3/5] update to TF 1.8.0 (#2138) --- .github/workflows/test-suite.yml | 4 ++-- .tool-versions | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 5a3a3d56b5..00fa2af636 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -6,7 +6,7 @@ on: inputs: terraform_matrix: description: 'Terraform version matrix (JSON array)' - default: '["1.7.x", "1.6.x", "1.5.x", "1.4.x", "1.3.x", "1.2.x"]' + default: '["1.8.x", "1.7.x", "1.6.x", "1.5.x", "1.4.x", "1.3.x", "1.2.x"]' provider_matrix: description: 'Previous MongoDB Atlas Provider version matrix for migration tests (JSON array)' default: '[""]' # "" for latest version @@ -34,7 +34,7 @@ concurrency: jobs: versions: env: - schedule_terraform_matrix: '["1.7.x"]' + schedule_terraform_matrix: '["1.8.x"]' schedule_provider_matrix: '[""]' # "" for latest version runs-on: ubuntu-latest outputs: diff --git a/.tool-versions b/.tool-versions index b7c7abb163..302450218d 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ golang 1.22.2 -terraform 1.7.5 +terraform 1.8.0 From 009f232187074f9812d651cfe702ff426f42b889 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Fri, 12 Apr 2024 09:35:59 +0200 Subject: [PATCH 4/5] chore: Adds new step in release process for updating header of changelog (#2134) * chore: define new job in release process for updating header of changelog * fixes after doing testing in forked repository * linter fix * support handling pre-release --- .github/workflows/release.yml | 43 +++++++++++++++++-- .../update-changelog-header-for-release.sh | 30 +++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) create mode 100755 scripts/update-changelog-header-for-release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5605d76fa5..1a10bdf8e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,9 +22,10 @@ jobs: run: | echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$' - # QA acceptance tests are skipped when explicit input parameter is used 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 @@ -32,21 +33,55 @@ jobs: atlas_cloud_env: "qa" ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || github.ref }} - release: + update-changelog-header: runs-on: ubuntu-latest needs: [ validate-version-input, run-qa-acceptance-tests ] - if: ${{ always() && needs.validate-version-input.result == 'success' && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') }} + # Skipped if use_existing_tag is defined, is a pre-release, or previous jobs failed. + 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') + steps: + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + with: + fetch-depth: 0 + - run: ./scripts/update-changelog-header-for-release.sh ${{inputs.version_number}} + - run: | + if [[ $(git status --porcelain) ]]; then + MSG="Update CHANGELOG.md header for ${{inputs.version_number}} release" + git config --local user.email changelogbot@mongodb.com + git config --local user.name changelogbot + git add CHANGELOG.md + git commit -m "$MSG" + git push + fi + + release: + runs-on: ubuntu-latest + needs: [ validate-version-input, run-qa-acceptance-tests, update-changelog-header ] + # Release is skipped if there are failures in previous steps + if: >- + always() + && needs.validate-version-input.result == 'success' + && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') + && (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success') steps: - name: Checkout uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 with: - ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || github.ref }} + 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" - name: Create release tag uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 with: tag: ${{ inputs.version_number }} + 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' }} diff --git a/scripts/update-changelog-header-for-release.sh b/scripts/update-changelog-header-for-release.sh new file mode 100755 index 0000000000..17ec6442b3 --- /dev/null +++ b/scripts/update-changelog-header-for-release.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${1?"Tag of new release must be provided"}" + +CHANGELOG_FILE_NAME=CHANGELOG.md +RELEASE_TAG=$1 +RELEASE_NUMBER=$(echo "${RELEASE_TAG}" | tr -d v) + +# exit out if changelog already has the header updated with version number being released. +if grep -q "## $RELEASE_NUMBER (" "$CHANGELOG_FILE_NAME"; then + echo "CHANGELOG already has a header defined for $RELEASE_NUMBER, no changes made to changelog." + exit 0 +fi + +# Prepare the new version header +TODAYS_DATE=$(date "+%B %d, %Y") # Format the date as "Month day, Year" +NEW_RELEASE_HEADER="## $RELEASE_NUMBER ($TODAYS_DATE)" + + + +CHANGELOG_TMP_FILE_NAME="CHANGELOG.tmp" +rm -f $CHANGELOG_TMP_FILE_NAME + +# Insert the new version header after the "(Unreleased)" line +sed "/(Unreleased)/a \\ +\\ +$NEW_RELEASE_HEADER" $CHANGELOG_FILE_NAME > $CHANGELOG_TMP_FILE_NAME && mv $CHANGELOG_TMP_FILE_NAME $CHANGELOG_FILE_NAME + +echo "Changelog updated successfully defining header for new $RELEASE_TAG release." From 46e5dcbdbf769cb5d5368313a008f39fd0ca64a5 Mon Sep 17 00:00:00 2001 From: Oriol Date: Fri, 12 Apr 2024 09:41:33 +0200 Subject: [PATCH 5/5] chore: Sends Slack notification when changelog update fails (#2140) --- .github/workflows/generate-changelog.yml | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml index a670334afb..164d3b7eba 100644 --- a/.github/workflows/generate-changelog.yml +++ b/.github/workflows/generate-changelog.yml @@ -31,3 +31,43 @@ jobs: git commit -m "$MSG" git push fi + + slack-notification: + needs: [generate-changelog] + if: ${{ !cancelled() && needs.generate-changelog.result == 'failure' }} + runs-on: ubuntu-latest + steps: + - name: Send Slack message + id: slack + uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 + with: + payload: | + { + "text": "Automatic Changelog update failed", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Automatic Changelog update failed* ${{ secrets.SLACK_ONCALL_TAG }}" + } + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": ":github: Failed action" + }, + "url": "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}" + } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK +