forked from hawkw/mycelium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): include deprecations in changelog (hawkw#235)
* chore(release): include "Deprecated" in changelog * chore: factor out changelog updating script * chore: add a header to the changelog
- Loading branch information
Showing
7 changed files
with
209 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
external-sources=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bash | ||
# utility functions used in other shell scripts. | ||
# | ||
# currently, this includes: | ||
# - cargo-style stderr logging (`err`, `note`, and `status` functions) | ||
# - confirmation prompts (`confirm` function) | ||
set -euo pipefail | ||
|
||
# Log an error to stderr | ||
# | ||
# Args: | ||
# $1: message to log | ||
err() { | ||
echo -e "\e[31m\e[1merror:\e[0m" "$@" 1>&2; | ||
} | ||
|
||
# Log a note to stderr | ||
# | ||
# Args: | ||
# $1: message to log | ||
note() { | ||
echo -e "\e[31m\e[1mnote:\e[0m" "$@" 1>&2; | ||
} | ||
|
||
# Log a cargo-style status message to stderr | ||
# | ||
# Args: | ||
# $1: a "tag" for the log message (should be 12 characters or less in | ||
# length) | ||
# $2: message to log | ||
status() { | ||
local width=12 | ||
local tag="$1" | ||
local msg="$2" | ||
printf "\e[32m\e[1m%${width}s\e[0m %s\n" "$tag" "$msg" | ||
} | ||
|
||
# Prompt the user to confirm an action | ||
# | ||
# Args: | ||
# $1: message to display to the user along with the `[y/N]` prompt | ||
# | ||
# Returns: | ||
# 0 if the user confirmed, 1 otherwise | ||
confirm() { | ||
while read -r -p "$1 [Y/n] " input | ||
do | ||
case "$input" in | ||
[yY][eE][sS]|[yY]) | ||
return 0 | ||
;; | ||
[nN][oO]|[nN]) | ||
return 1 | ||
;; | ||
*) | ||
err "invalid input $input" | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
# Returns the path to a Mycelium crate. | ||
# | ||
# Args: | ||
# $1: crate name | ||
# | ||
# Returns: | ||
# 0 if the crate exists, 0 if it does not exist. | ||
crate_path() { | ||
local crate="$1" | ||
local mycoprefix='mycelium-'; | ||
if [[ -d $crate ]]; then | ||
echo "$crate" | ||
elif [[ -d "${crate#"$mycoprefix"}" ]]; then | ||
echo "${crate#"$mycoprefix"}" | ||
else | ||
err "unknown crate $crate" | ||
return 1; | ||
fi | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env bash | ||
usage="Updates the changelog for a Mycelium crate. | ||
USAGE: | ||
$(basename "$0") [FLAGS] <CRATE_PATH> <TAG> | ||
FLAGS: | ||
-h, --help Show this help text and exit. | ||
-v, --verbose Enable verbose output." | ||
|
||
set -euo pipefail | ||
|
||
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd ) | ||
rootdir=$( cd "$bindir"/.. && pwd ) | ||
|
||
# shellcheck source=_util.sh | ||
. "$bindir"/_util.sh | ||
|
||
cd "$rootdir" | ||
|
||
verbose='' | ||
|
||
for arg in "$@" | ||
do | ||
case "$arg" in | ||
-h|--help) | ||
echo "$usage" | ||
exit 0 | ||
;; | ||
-v|--verbose) | ||
verbose="--verbose" | ||
;; | ||
-*) | ||
err "unknown flag $arg" | ||
echo "$usage" | ||
exit 1 | ||
;; | ||
*) # crate or version | ||
if [[ -z "${path+path}" ]]; then | ||
path="$arg" | ||
elif [[ -z "${tag+tag}" ]]; then | ||
tag="$arg" | ||
else | ||
err "unknown positional argument \"$arg\"" | ||
echo "$usage" | ||
exit 1 | ||
fi | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z "${path+path}" ]]; then | ||
err "no version specified!" | ||
errexit=1 | ||
fi | ||
|
||
if [[ -z "${tag+tag}" ]]; then | ||
err "no tag specified!" | ||
errexit=1 | ||
fi | ||
|
||
if [[ "${errexit+errexit}" ]]; then | ||
echo "$usage" | ||
exit 1 | ||
fi | ||
|
||
if ! [[ -x "$(command -v git-cliff)" ]]; then | ||
err "missing git-cliff executable" | ||
if confirm " install it?"; then | ||
cargo install git-cliff | ||
else | ||
echo "okay, exiting" | ||
exit 0 | ||
fi | ||
fi | ||
|
||
changelog_path="${path}/CHANGELOG.md" | ||
|
||
status "Updating" "$changelog_path for tag $tag" | ||
|
||
git_cliff=( | ||
git-cliff | ||
--include-path "${path}/**" | ||
--output "$changelog_path" | ||
--config cliff.toml | ||
--tag "$tag" | ||
) | ||
if [[ "$verbose" ]]; then | ||
git_cliff+=("$verbose") | ||
fi | ||
|
||
"${git_cliff[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters