Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions scripts/create-clog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
#
# create-clog.sh [--version=<version>] [--release-date=<release-date>]
#
# Dependencies: getopt sed
#
# Description: Uses template_changelog.md to create a new changelog.
#
# Examples:
# ./scripts/create-clog.sh --version="1.18.0" --release-date="05/18/2021"


set -eou pipefail

VERSION_DELIM="<% X.Y.Z %>"
RELEASE_DATE_DELIM="<% MM/DD/YYYY %>"
VERSION=""
RELEASE_DATE=""

# usage prints information for how to use this program. Exits with status code
# 1.
function usage () {
echo "Usage: create-clog [--version=<version>] [--release-date=<release-date>]"
echo "Create a changelog from a template"
echo "Arguments:"
echo " <version>: A version string 'x.y.z'"
echo " <release-date>: A date string 'mm/dd/yyyy'"
exit 1
}

# init parses arguments and initializes all variables.
function init () {
options=$(getopt \
--name="$(basename "$0")" \
--longoptions=" \
help, \
release-date:, \
version:" \
--options="h" \
-- "$@")
[ $? -eq 0 ] || {
usage
}

eval set -- "$options"

while true; do
case "${1:-}" in
-h|--help)
usage
;;
--version)
shift;
VERSION="$1"
;;
--release-date)
shift;
RELEASE_DATE="$1"
;;
--)
shift
break
;;
esac
shift
done

if [ -z "$VERSION" ]; then
echo "version argument is empty."
echo "Expected a version string like 'x.y.z'"
usage
fi

if [ -z "$RELEASE_DATE" ]; then
echo "release-date argument is empty."
echo "Expected a date string like 'mm/dd/yyyy'"
usage
fi
}

# create_from_template creates a new changelog file from template_changelog.md
# using VERSION and RELEASE_DATE.
function create_from_template () {
echo "Creating template using version: $VERSION and release date: $RELEASE_DATE"
pushd "$(git rev-parse --show-toplevel)" > /dev/null
clogPath="./changelog/$VERSION.md"
cp ./scripts/template_changelog.md "$clogPath"
sed -i "s|$VERSION_DELIM|$VERSION|g" "$clogPath"
sed -i "s|$RELEASE_DATE_DELIM|$RELEASE_DATE|g" "$clogPath"
popd > /dev/null
}

# main program
init "$@"
create_from_template
echo "Done"
20 changes: 20 additions & 0 deletions scripts/template_changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: "<% X.Y.Z %>"
description: "Released on <% MM/DD/YYYY %>"
---

### Breaking Changes ❗
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the cutesy emojis btw

@khorne3 mentioned we should use sentence case for lower-level headings, so I think this would be "Breaking changes" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do that, we should update all clogs. Happy for us to do that, though as a different changeset. I'm super glad we're increasing our consistency and standardizing these decisions!!!!! ❤️

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, and it pains me a bit to say this, because I love the emojis, but... the emojis result in slightly worse fragments: https://coder.com/docs/changelog/1.17.0#breaking-changes- (note the trailing hyphen)

I dunno if there's some way to customize this in the JavaScript we're using to transform the Markdown, though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth investigating - CH story would be useful as that's the responsibility of m, not anything in cdr/docs AFAICT


There are no breaking changes in <% X.Y.Z %>.

### Features ✨

There are no new features in <% X.Y.Z %>.

### Bug Fixes 🐛

There are no bug fixes in <% X.Y.Z %>.

### Security Updates 🔐

There are no security updates in <% X.Y.Z %>.