chore(package): create an automated release script

This commit is contained in:
Phil Booth 2018-11-20 12:52:33 +00:00
Родитель 2649bbf634
Коммит 05acce118c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 36FBB106F9C32516
3 изменённых файлов: 158 добавлений и 53 удалений

Просмотреть файл

@ -1,5 +1,4 @@
<a name="v1.125.2"></a>
## v1.125.2 (2018-11-20)
## 1.125.2 (2018-11-20)
#### Bug Fixes
@ -8,8 +7,7 @@
<a name="v1.125.1"></a>
## v1.125.1 (2018-11-15)
## 1.125.1 (2018-11-15)
#### Bug Fixes
@ -22,8 +20,7 @@
<a name="v1.125.0"></a>
## v1.125.0 (2018-11-14)
## 1.125.0 (2018-11-14)
#### Bug Fixes
@ -40,8 +37,7 @@
<a name="v1.124.1"></a>
## v1.124.1 (2018-11-07)
## 1.124.1 (2018-11-07)
#### Bug Fixes
@ -50,8 +46,7 @@
<a name="v1.124.0"></a>
## v1.124.0 (2018-10-30)
## 1.124.0 (2018-10-30)
#### Features
@ -75,8 +70,7 @@
<a name="v1.122.0"></a>
## v1.122.0 (2018-10-02)
## 1.122.0 (2018-10-02)
#### Bug Fixes
@ -88,8 +82,7 @@
<a name="v1.121.0"></a>
## v1.121.0 (2018-09-18)
## 1.121.0 (2018-09-18)
#### Features
@ -97,8 +90,7 @@
<a name="v1.120.0"></a>
## v1.120.0 (2018-09-06)
## 1.120.0 (2018-09-06)
#### Features
@ -108,8 +100,7 @@
<a name="v1.119.0"></a>
## v1.119.0 (2018-08-22)
## 1.119.0 (2018-08-22)
#### Features
@ -126,8 +117,7 @@
<a name="v1.118.0"></a>
## v1.118.0 (2018-08-09)
## 1.118.0 (2018-08-09)
#### Bug Fixes
@ -136,8 +126,7 @@
<a name="v1.117.0"></a>
## v1.117.0 (2018-08-01)
## 1.117.0 (2018-08-01)
#### Features
@ -148,8 +137,7 @@
<a name="v1.116.3"></a>
## v1.116.3 (2018-07-26)
## 1.116.3 (2018-07-26)
#### Refactor
@ -161,8 +149,7 @@
<a name="v1.116.2"></a>
## v1.116.2 (2018-07-19)
## 1.116.2 (2018-07-19)
#### Bug Fixes
@ -171,7 +158,6 @@
<a name="1.116.1"></a>
## 1.116.1 (2018-07-18)
@ -186,7 +172,6 @@
<a name="1.116.0"></a>
## 1.116.0 (2018-07-12)
@ -216,7 +201,6 @@
<a name="1.115.0"></a>
## 1.115.0 (2018-06-26)

Просмотреть файл

@ -1,28 +1,8 @@
## Creating Releases
### Get dependencies if missing
1. Run `scripts/release.sh` if you're doing a major train bump,
or `scripts/release.sh patch` if you're tagging a patch release.
```
cargo install clog-cli
```
2. Do a `git log`, check everything looks ok (including the changelog).
### Tag a new minor release
* Update `Cargo.toml` and `Cargo.lock` with the new version.
* Set ENV variable for the version. Example: `export FXA_EMAIL_SERVICE_VERSION="v1.117.3"`
* Generate the changelog:
```
clog -F --setversion $FXA_EMAIL_SERVICE_VERSION -i CHANGELOG.md -o CHANGELOG.md
```
* Commit and send the PR for review.
* If all good, create a tag from the PR that was merged into the master branch.
*****
Additional docs:
* https://github.com/clog-tool/clog-cli#using-clog-from-the-command-line
3. `git push` the train branch and the tag.

141
scripts/release.sh Executable file
Просмотреть файл

@ -0,0 +1,141 @@
#!/bin/sh
set -e
LAST_TAG=`git describe --tags --abbrev=0`
COMMITS=`git log $LAST_TAG..HEAD --pretty=oneline --abbrev-commit`
if [ "$COMMITS" = "" ]; then
echo "Release aborted: I see no work."
exit 1
fi
case "$1" in
"")
BUILD_TYPE="Train"
;;
"patch")
BUILD_TYPE="Patch"
;;
*)
echo "Release aborted: Invalid argument \"$1\"."
exit 1
;;
esac
while read -r COMMIT; do
HASH=`echo "$COMMIT" | cut -d ' ' -f 1`
MESSAGE=`echo "$COMMIT" | cut -d ':' -f 2- | awk '{$1=$1};1'`
TYPE=`echo "$COMMIT" | cut -d ' ' -f 2 | awk '{$1=$1};1' | cut -d ':' -f 1 | cut -d '(' -f 1 | awk '{$1=$1};1'`
AREA=`echo "$COMMIT" | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{$1=$1};1'`
if [ "$AREA" = "$COMMIT" ]; then
AREA=""
fi
if [ "$AREA" != "" ]; then
AREA="$AREA: "
fi
case "$TYPE" in
"feat")
if [ "$FEAT_SUMMARY" = "" ]; then
FEAT_SUMMARY="### New features\n"
fi
FEAT_SUMMARY="$FEAT_SUMMARY\n* $AREA$MESSAGE ($HASH)"
;;
"fix")
if [ "$FIX_SUMMARY" = "" ]; then
FIX_SUMMARY="### Bug fixes\n"
fi
FIX_SUMMARY="$FIX_SUMMARY\n* $AREA$MESSAGE ($HASH)"
;;
"perf")
if [ "$PERF_SUMMARY" = "" ]; then
PERF_SUMMARY="### Performance improvements\n"
fi
PERF_SUMMARY="$PERF_SUMMARY\n* $AREA$MESSAGE ($HASH)"
;;
"refactor")
if [ "$REFACTOR_SUMMARY" = "" ]; then
REFACTOR_SUMMARY="### Refactorings\n"
fi
REFACTOR_SUMMARY="$REFACTOR_SUMMARY\n* $AREA$MESSAGE ($HASH)"
;;
"revert")
if [ "$REFACTOR_SUMMARY" = "" ]; then
REVERT_SUMMARY="### Reverted changes\n"
fi
REVERT_SUMMARY="$REVERT_SUMMARY\n* $AREA$MESSAGE ($HASH)"
;;
*)
if [ "$OTHER_SUMMARY" = "" ]; then
OTHER_SUMMARY="### Other changes\n"
fi
OTHER_SUMMARY="$OTHER_SUMMARY\n* $AREA$MESSAGE ($HASH)"
;;
esac
done <<< "$COMMITS"
if [ "$FEAT_SUMMARY" != "" ]; then
FEAT_SUMMARY="$FEAT_SUMMARY\n\n"
fi
if [ "$FIX_SUMMARY" != "" ]; then
FIX_SUMMARY="$FIX_SUMMARY\n\n"
fi
if [ "$PERF_SUMMARY" != "" ]; then
PERF_SUMMARY="$PERF_SUMMARY\n\n"
fi
if [ "$REFACTOR_SUMMARY" != "" ]; then
REFACTOR_SUMMARY="$REFACTOR_SUMMARY\n\n"
fi
if [ "$REVERT_SUMMARY" != "" ]; then
REVERT_SUMMARY="$REVERT_SUMMARY\n\n"
fi
if [ "$OTHER_SUMMARY" != "" ]; then
OTHER_SUMMARY="$OTHER_SUMMARY\n\n"
fi
SUMMARY="$BREAK_SUMMARY$FEAT_SUMMARY$FIX_SUMMARY$PERF_SUMMARY$REFACTOR_SUMMARY$OTHER_SUMMARY"
MAJOR=`echo "$LAST_TAG" | cut -d '.' -f 1 | cut -d 'v' -f 2`
TRAIN=`echo "$LAST_TAG" | cut -d '.' -f 2`
PATCH=`echo "$LAST_TAG" | cut -d '.' -f 3`
LAST_VERSION="$MAJOR.$TRAIN.$PATCH"
SED_FRIENDLY_LAST_VERSION="$MAJOR\\.$TRAIN\\.$PATCH"
case "$BUILD_TYPE" in
"Train")
TRAIN=`expr $TRAIN + 1`
PATCH=0
;;
"Patch")
PATCH=`expr $PATCH + 1`
;;
esac
NEW_VERSION="$MAJOR.$TRAIN.$PATCH"
NEW_TAG="v$NEW_VERSION"
sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_VERSION/$NEW_VERSION/g" Cargo.toml
rm Cargo.toml.release.bak
sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_VERSION/$NEW_VERSION/g" Cargo.lock
rm Cargo.lock.release.bak
LOG="CHANGELOG.md"
TEMP="__release_$LOG.$NEW_VERSION.tmp"
awk "{ gsub(/^## $LAST_VERSION/, \"## $NEW_VERSION\n\n$SUMMARY## $LAST_VERSION\") }; { print }" "$LOG" > "$TEMP"
mv "$TEMP" "$LOG"
GIT_FRIENDLY_SUMMARY=`echo "$SUMMARY" | sed "s/#//g" | sed "s/^ //"`
git commit -a -m "release: $NEW_VERSION"
git tag -a "$NEW_TAG" -m "`echo \"$BUILD_TYPE release $NEW_VERSION\\n\\n$GIT_FRIENDLY_SUMMARY\"`"