Skip to content

Commit

Permalink
Backport changelog improvements (#36346)
Browse files Browse the repository at this point in the history
* only include experiments in dev and alpha releases

* setup script for maintenance branch

By changing the folder changie uses for the changelog we can
make sure that users can put the changelog entries into a specific
folder based on if the change will be backported. This way it will
only appear in the patch release of the maintenance branch and not
in the changelog of the current development branch.

* add backported comment to PR template

* remove old backported changes

* add usage comment

* rename to firstbeta

* fix typo

* run firstbeta script

* add missing changelog entry

* add backported changie entries to ignore list for copywrite letter
  • Loading branch information
DanielMSchmidt authored Jan 16, 2025
1 parent 24e181d commit af89f87
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 10 deletions.
Empty file added .changes/backported/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions .changes/backported/NEW FEATURES-20250116-120838.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: NEW FEATURES
body: S3 native state locking is now generally available. The `use_lockfile` argument enables users to adopt the S3-native mechanism for state locking. As part of this change, we've deprecated the DynamoDB-related arguments in favor of this new locking mechanism. While you can still use DynamoDB alongside S3-native state locking for migration purposes, we encourage migrating to the new state locking mechanism.
time: 2025-01-16T12:08:38.016829+01:00
custom:
Issue: "36338"
File renamed without changes.
3 changes: 3 additions & 0 deletions .changes/footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Previous Releases

For information on prior major and minor releases, refer to their changelogs:
2 changes: 1 addition & 1 deletion .changie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


changesDir: .changes
unreleasedDir: unreleased
unreleasedDir: backported
versionFooterPath: version_footer.tpl.md
changelogPath: CHANGELOG.md
versionExt: md
Expand Down
1 change: 1 addition & 0 deletions .copywrite.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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*/**"
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ label to enable the backport bot.
<!--
If your change is user-facing, add a short description in a changelog entry.
You can use `npx changie new` to create a new changelog entry or manually create a new file in the .changes/unreleasd directory.
You can use `npx changie new` to create a new changelog entry or manually create a new file in the .changes/unreleasd directory (or .changes/backported if it's a bug fix that should be backported).
-->

Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.11.0-beta1 (January 16, 2025)
## 1.11.0 (Unreleased)


NEW FEATURES:
Expand All @@ -7,7 +7,7 @@ NEW FEATURES:

* `terraform test`: The `-junit-xml` option for the terraform test command is now generally available. This option allows the command to create a test report in JUnit XML format. Feedback during the experimental phase helped map terraform test concepts to the JUnit XML format, and new additons may happen in future releases. ([#36324](https://github.com/hashicorp/terraform/issues/36324))

* S3 native state locking is now generally available. The `use_lockfile` argument enables users to adopt the S3-native mechanism for state locking. As part of this change, we've deprecated the DynamoDB-related arguments in favor of this new locking mechanism. While you can still use DynamoDB alongside S3-native state locking for migration purposes, we encourage migrating to the new state locking mechanism.
* S3 native state locking is now generally available. The `use_lockfile` argument enables users to adopt the S3-native mechanism for state locking. As part of this change, we've deprecated the DynamoDB-related arguments in favor of this new locking mechanism. While you can still use DynamoDB alongside S3-native state locking for migration purposes, we encourage migrating to the new state locking mechanism. ([#36338](https://github.com/hashicorp/terraform/issues/36338))


ENHANCEMENTS:
Expand Down
47 changes: 42 additions & 5 deletions scripts/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.0-beta1
1.11.0-dev

0 comments on commit af89f87

Please sign in to comment.