diff --git a/.changes/backported/.gitkeep b/.changes/backported/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/.changes/experiments.md b/.changes/footer-with-experiments.md similarity index 100% rename from .changes/experiments.md rename to .changes/footer-with-experiments.md diff --git a/.changes/footer.md b/.changes/footer.md new file mode 100644 index 000000000000..259cdc4e337c --- /dev/null +++ b/.changes/footer.md @@ -0,0 +1,3 @@ +## Previous Releases + +For information on prior major and minor releases, refer to their changelogs: diff --git a/.changie.yaml b/.changie.yaml index 098dc6fbae32..d121045a4c58 100644 --- a/.changie.yaml +++ b/.changie.yaml @@ -3,7 +3,7 @@ changesDir: .changes -unreleasedDir: unreleased +unreleasedDir: backported versionFooterPath: version_footer.tpl.md changelogPath: CHANGELOG.md versionExt: md diff --git a/.copywrite.hcl b/.copywrite.hcl index b369a36093d3..5b33c69c4c3e 100644 --- a/.copywrite.hcl +++ b/.copywrite.hcl @@ -14,6 +14,7 @@ project { "**/*_string.go", "**/mock*.go", ".changes/unreleased/**", + ".changes/backported/**", # these directories have their own copywrite config "docs/plugin-protocol/**", "internal/tfplugin*/**" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e0cb3127ed67..2b34c41e8f51 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -38,7 +38,7 @@ label to enable the backport bot. diff --git a/scripts/changelog.sh b/scripts/changelog.sh index 72cdfd0beeaa..8eb9a0576e6f 100755 --- a/scripts/changelog.sh +++ b/scripts/changelog.sh @@ -21,12 +21,19 @@ Commands: type. The release type should be one of "dev", "alpha", "rc", "release", or "patch". `dev`: will update the changelog with the latest unreleased changes. `alpha`: will generate a new section with an alpha version for today. + `beta`: will generate a new beta release. `rc`: will generate a new rc release. `release`: will make the initial minor release for this branch. `patch`: will generate a new patch release nextminor - Run this to get a new release branch for the next minor version. + This function expects the current branch to be main. Run it if you want to set main to the next + minor version. + + firstbeta + This function is expected to be run on the branch of the last minor release. It will make sure + that backports work properly + EOF } @@ -39,9 +46,12 @@ function generate { exit 1 fi + FOOTER_FILE='footer.md' + case "$RELEASE_TYPE" in dev) + FOOTER_FILE='footer-with-experiments.md' LATEST_VERSION=$(npx -y changie@$CHANGIE_VERSION latest -r --skip-prereleases) # Check if we already released this version already @@ -61,6 +71,7 @@ function generate { ;; alpha) + FOOTER_FILE='footer-with-experiments.md' PRERELEASE_VERSION=$(date +"alpha%Y%m%d") LATEST_VERSION=$(npx -y changie@$CHANGIE_VERSION latest -r --skip-prereleases) HUMAN_DATE=$(date +"%B %d, %Y") # Date in Janurary 1st, 2022 format @@ -119,16 +130,18 @@ function generate { echo "$COMPLETE_VERSION" > version/VERSION # Add footer to the changelog - cat ./.changes/experiments.md >> CHANGELOG.md + cat ./.changes/$FOOTER_FILE >> CHANGELOG.md echo "" >> CHANGELOG.md cat ./.changes/previous-releases.md >> CHANGELOG.md } +# This function expects the current branch to be main. Run it if you want to set main to the next +# minor version. function nextminor { + # Prepend the latest version to the previous releases LATEST_VERSION=$(npx -y changie@$CHANGIE_VERSION latest -r --skip-prereleases) LATEST_VERSION=${LATEST_VERSION%.*} # Remove the patch version CURRENT_FILE_CONTENT=$(cat ./.changes/previous-releases.md) - # Prepend the latest version to the previous releases echo "- [v$LATEST_VERSION](https://github.com/hashicorp/terraform/blob/v$LATEST_VERSION/CHANGELOG.md)" > ./.changes/previous-releases.md echo "$CURRENT_FILE_CONTENT" >> ./.changes/previous-releases.md @@ -137,22 +150,46 @@ function nextminor { rm ./.changes/*.*.*.md # Remove all unreleased changes rm ./.changes/unreleased/*.yaml + # Remove all backported changes + rm ./.changes/backported/*.yaml # Create a new empty version file for the next minor version touch ./.changes/$NEXT_VERSION.md generate "dev" } +# This function is expected to be run on the branch of the last minor release. It will make sure +# that backports work properly +function firstbeta { + # For the maintenance branch we don't want to base our changelog on the unreleased but the backported folder instead + awk '{sub(/unreleasedDir: unreleased/, "unreleasedDir: backported")}1' ./.changie.yaml > temp && mv temp ./.changie.yaml + + # If we have backported changes, we need to remove them now since they were backported into the + # last version + rm -f ./.changes/backported/*.yaml + + # If we have unreleased changes, they will be released in the next patch, therefore they need + # to go into the backported folder + if [ "$(ls -A ./.changes/unreleased/)" ]; then + mv ./.changes/unreleased/* ./.changes/backported/ + fi + + generate "dev" +} + function main { case "$1" in generate) generate "${@:2}" - ;; + nextminor) nextminor "${@:2}" - ;; + + firstbeta) + firstbeta "${@:2}" + ;; *) usage exit 1