mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +01:00
changelog file is optional in bump script
This commit is contained in:
parent
ce3af777a0
commit
c34a18f64a
34
scripts/bump
34
scripts/bump
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
# developed on macOS and probably doesn't work on Linux yet due to minor
|
||||
# differences in flags on sed
|
||||
@ -21,12 +21,9 @@ README_FILE=$DIR/README.md
|
||||
|
||||
# determine changelog file name
|
||||
if [ -f "$DIR/CHANGES.md" ]; then
|
||||
CHANGELOG_FILE=$DIR/CHANGES.md
|
||||
CHANGELOG_FILE="$DIR/CHANGES.md"
|
||||
elif [ -f "$DIR/CHANGELOG.md" ]; then
|
||||
CHANGELOG_FILE=$DIR/CHANGELOG.md
|
||||
else
|
||||
echo "No changelog file found"
|
||||
exit 1
|
||||
CHANGELOG_FILE="$DIR/CHANGELOG.md"
|
||||
fi
|
||||
|
||||
# get current version
|
||||
@ -37,8 +34,9 @@ CHANGE_CHUNK_FILE="$(mktemp)"
|
||||
echo saving changelog to $CHANGE_CHUNK_FILE
|
||||
echo
|
||||
|
||||
# get changelog chunk and save to temp file
|
||||
cat "$CHANGELOG_FILE" |
|
||||
if [ -n "${CHANGELOG_FILE-}" ]; then
|
||||
# get changelog chunk and save to temp file
|
||||
cat "$CHANGELOG_FILE" |
|
||||
# skip up to unreleased heading
|
||||
sed '1,/Unreleased/ d' |
|
||||
# take up to previous version heading
|
||||
@ -46,6 +44,7 @@ cat "$CHANGELOG_FILE" |
|
||||
# drop last line
|
||||
sed '$d' \
|
||||
>"$CHANGE_CHUNK_FILE"
|
||||
fi
|
||||
|
||||
# if word count of changelog chunk is 0 then insert filler changelog chunk
|
||||
if [ "$(wc -w "$CHANGE_CHUNK_FILE" | awk '{ print $1 }')" = "0" ]; then
|
||||
@ -68,8 +67,7 @@ if [ "${NEW_VERSION:0:1}" = "v" ]; then
|
||||
NEW_VERSION="${NEW_VERSION:1}"
|
||||
fi
|
||||
|
||||
DATE="$(date -u +"%Y-%m-%d")"
|
||||
echo "updating from $CURRENT_VERSION => $NEW_VERSION ($DATE)"
|
||||
echo "updating from $CURRENT_VERSION => $NEW_VERSION"
|
||||
|
||||
# update package.version field
|
||||
sed -i.bak -E "s/^version ?= ?\"[^\"]+\"$/version = \"$NEW_VERSION\"/" "$CARGO_MANIFEST"
|
||||
@ -77,19 +75,21 @@ sed -i.bak -E "s/^version ?= ?\"[^\"]+\"$/version = \"$NEW_VERSION\"/" "$CARGO_M
|
||||
# update readme
|
||||
[ -f "$README_FILE" ] && sed -i.bak -E "s#$CURRENT_VERSION([/)])#$NEW_VERSION\1#g" "$README_FILE"
|
||||
|
||||
# update changelog file
|
||||
(
|
||||
if [ -n "${CHANGELOG_FILE-}" ]; then
|
||||
# update changelog file
|
||||
(
|
||||
sed '/Unreleased/ q' "$CHANGELOG_FILE" # up to unreleased heading
|
||||
echo # blank line
|
||||
echo "## $NEW_VERSION - $DATE" # new version heading
|
||||
echo "## $NEW_VERSION" # new version heading
|
||||
cat "$CHANGE_CHUNK_FILE" # previously unreleased changes
|
||||
sed "/$CURRENT_VERSION/ q" "$CHANGELOG_FILE" | tail -n 1 # the previous version heading
|
||||
sed "1,/$CURRENT_VERSION/ d" "$CHANGELOG_FILE" # everything after previous version heading
|
||||
) >"$CHANGELOG_FILE.bak"
|
||||
mv "$CHANGELOG_FILE.bak" "$CHANGELOG_FILE"
|
||||
) >"$CHANGELOG_FILE.bak"
|
||||
mv "$CHANGELOG_FILE.bak" "$CHANGELOG_FILE"
|
||||
|
||||
# format CHANGELOG file according to prettier
|
||||
npx -y prettier --write "$CHANGELOG_FILE" || true
|
||||
# format CHANGELOG file according to prettier
|
||||
npx -y prettier --write "$CHANGELOG_FILE" || true
|
||||
fi
|
||||
|
||||
# done; remove backup files
|
||||
rm -f $CARGO_MANIFEST.bak
|
||||
|
Loading…
Reference in New Issue
Block a user