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.
pull/36348/head
Daniel Schmidt 1 year ago
parent a5bfa39b9a
commit 3e714f6139

@ -21,12 +21,18 @@ 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.
maintenancerelease
EOF
}
@ -128,11 +134,13 @@ function generate {
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
@ -141,22 +149,42 @@ 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 maintenancerelease {
# 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 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}"
;;
maintenancerelease)
maintenancerelease "${@:2}"
;;
*)
usage
exit 1

Loading…
Cancel
Save