Work on release/deploy functionality.

pull/455/head
Fredrik Öhrström 2022-01-25 09:58:37 +01:00
rodzic a353e4899b
commit f925788826
3 zmienionych plików z 169 dodań i 0 usunięć

Wyświetl plik

@ -333,5 +333,24 @@ extract_fuzz_telegram_seeds:
relay: utils/relay.c
gcc -g utils/relay.c -o relay -O0 -ggdb -fsanitize=address -fno-omit-frame-pointer -fprofile-arcs -ftest-coverage
# Bump major number
release_major:
@./scripts/release.sh major
# Bump minor number
release_minor:
@./scripts/release.sh minor
# Bump patch number
release_patch:
@./scripts/release.sh patch
# Bump release candidate number, ie a bug in the previous RC was found!
release_rc:
@./scripts/release.sh rc
deploy:
@./scripts/deploy.sh
# Include dependency information generated by gcc in a previous compile.
include $(wildcard $(patsubst %.o,%.d,$(PROG_OBJS) $(DRIVER_OBJS)))

67
scripts/deploy.sh 100755
Wyświetl plik

@ -0,0 +1,67 @@
#!/bin/bash
# Grab all text up to the "Version x.y.z-RC1: <date>" line
# There should be no text.
CHANGES=$(sed '/Version /q' CHANGES | grep -v ^Version | sed '/./,$!d' | \
tac | sed -e '/./,$!d' | tac | sed -e '/./,$!d' > /tmp/release_changes)
if [ -s /tmp/release_changes ]
then
echo "Oups! There are changes declared in the CHANGES file. There should not be if you are going to deploy."
exit 0
fi
# Grab all text between the Version RC and the previous VERSION.
sed -n '/^Version.*-RC[0-9]:/,/^Version .*\.[0-9]\+:/{p;/^Version .*\.[0-9]\+:/q}' CHANGES \
| grep -v "^Version " | sed '/./,$!d' \
| tac | sed -e '/./,$!d' | tac | sed -e '/./,$!d' > /tmp/release_changes
if [ ! -s /tmp/release_changes ]
then
echo "Oups! There should be changes declared in the CHANGES file between the RC version and the previous released version."
exit 0
fi
OLD_MESSAGE=$(grep -m 1 ^Version CHANGES)
RC_VERSION=$(grep -m 1 ^Version CHANGES | sed 's/Version \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\1 \2 \3/')
MAJOR=$(echo "$RC_VERSION" | cut -f 1 -d ' ')
MINOR=$(echo "$RC_VERSION" | cut -f 2 -d ' ')
PATCH=$(echo "$RC_VERSION" | cut -f 3 -d ' ')
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
NEW_MESSAGE="Version $NEW_VERSION: $(date +'%Y-%m-%d')"
PREV_GIT_MESSAGE=$(git log -1 --pretty=%B)
if [ "PREV_GIT_MESSAGE" != "$OLD_MESSAGE" ]
then
echo "Oups! Something is wrong in the git log. Expected last commit to say \"$OLD_MESSAGE\" but it does not!"
exit 0
fi
echo
echo "Deploying release $NEW_MESSAGE with changelog:"
echo "----------------------------------------------------------------------------------"
cat /tmp/release_changes
echo "----------------------------------------------------------------------------------"
echo
while true; do
read -p "Ok to deploy release? y/n " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
sed 's/"version": "[\.0-9]*"/"version": "'$NEW_VERSION'"/' ha-addon/config.json > /tmp/release_haconfig
echo "Updated version number in ha-addon/config.json to $NEW_VERSION"
sed "s/$OLD_MESSAGE/$NEW_MESSAGE/" CHANGES > /tmp/release_changes
echo "Updated version string in CHANGES"
git commit -am "$NEW_MESSAGE"
git tag "$NEW_VERSION"

83
scripts/release.sh 100755
Wyświetl plik

@ -0,0 +1,83 @@
#!/bin/bash
TYPE=$1
if [ "$TYPE" != "major" ] && [ "$TYPE" != "minor" ] && [ "$TYPE" != "patch" ] && [ "$TYPE" != "rc" ]
then
echo "You must supply major,minor or patch!"
exit 0
fi
# Grab all text up to the "Version x.y.z: <date>" line
# If there is no text, then we have to add some information to CHANGES
# before we make a release.
CHANGES=$(sed '/Version /q' CHANGES | grep -v ^Version | sed '/./,$!d' | \
tac | sed -e '/./,$!d' | tac | sed -e '/./,$!d' > /tmp/release_changes)
if [ ! -s /tmp/release_changes ]
then
echo "Oups! There are no changes declared in the CHANGES file. There should be some for a release!"
exit 0
fi
VERSION=$(grep -m 1 ^Version CHANGES | sed 's/Version \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\(-RC[ 0-9]\?\)\?:.*/\1 \2 \3 \4/')
MAJOR=$(echo "$VERSION" | cut -f 1 -d ' ')
MINOR=$(echo "$VERSION" | cut -f 2 -d ' ')
PATCH=$(echo "$VERSION" | cut -f 3 -d ' ')
RC=$(echo "$VERSION" | cut -f 4 -d ' ')
if [ ! "$RC" = "" ]
then
if [ ! "$TYPE" = "rc" ]
then
echo "Previous tag was a release candidate. You should run \"make release_rc\""
echo "if you need to create another release candidate. Or \"make deploy\" if"
echo "the candidate passed testing."
exit 0
fi
# The previous tag was an RC version, ie we are fixing a bug in a release candidate.
# Bump to next release candidate.
RC="${RC#-RC}"
RC=$((RC+1))
else
# rc can only be used when the previous tag was also an rc!
if [ "$TYPE" = "rc" ] ; then echo "You must supply major,minor or patch! Not rc." ; exit 0; fi
# otherwise you supply major, minor or patch.
if [ "$TYPE" = "major" ] ; then MAJOR=$((MAJOR+1)) ; fi
if [ "$TYPE" = "minor" ] ; then MINOR=$((MINOR+1)) ; fi
if [ "$TYPE" = "patch" ] ; then PATCH=$((PATCH+1)) ; fi
RC=1
fi
RC_VERSION="$MAJOR.$MINOR.$PATCH-RC$RC"
MESSAGE="Version $RC_VERSION: $(date +'%Y-%m-%d')"
echo
echo "$MESSAGE"
echo "----------------------------------------------------------------------------------"
cat /tmp/release_changes
echo "----------------------------------------------------------------------------------"
echo
while true; do
read -p "Ok to create release candidate? y/n " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
# Insert release candidate line in CHANGES.
CMD="1 i\$MESSAGE"
sed -i "$CMD" CHANGES
git commit -am "$MESSAGE"
git tag "$RC_VERSION"
echo "Now do: git push ; git push --tags"
#git push
#git push --tags