Skip to content

Commit

Permalink
Merge branch 'master' into CLOUDP-241948_jira_release_version
Browse files Browse the repository at this point in the history
* master:
  chore: Sends Slack notification when changelog update fails (#2140)
  chore: Adds new step in release process for updating header of changelog (#2134)
  update to TF 1.8.0 (#2138)
  doc: Updates Terraform Compatibility Matrix documentation (#2137)
  chore: Adds workflow that generates changelog after PR is merged (#2128)
  • Loading branch information
lantoli committed Apr 12, 2024
2 parents 98cc4fa + 46e5dcb commit 05934ed
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 7 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]
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

43 changes: 39 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,66 @@ 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
with:
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 [email protected]
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' }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang 1.22.2
terraform 1.7.5
terraform 1.8.0
6 changes: 6 additions & 0 deletions contributing/changelog-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
30 changes: 30 additions & 0 deletions scripts/update-changelog-header-for-release.sh
Original file line number Diff line number Diff line change
@@ -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."
1 change: 1 addition & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ For more information on configuring and managing programmatic API Keys see the [
<!-- MATRIX_PLACEHOLDER_START -->
| 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 |
Expand Down

0 comments on commit 05934ed

Please sign in to comment.