diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml new file mode 100644 index 0000000000..164d3b7eba --- /dev/null +++ b/.github/workflows/generate-changelog.yml @@ -0,0 +1,73 @@ +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 + + 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 + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc6678c8af..3476295115 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/.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 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. 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." 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 |