Sanmill/release.sh

110 lines
3.2 KiB
Bash
Raw Normal View History

#!/bin/bash
YAML_FILE=src/ui/flutter_app/pubspec.yaml
QT_RC_FILE=millgame.rc
FLUTTER_WINDOWS_RC_FILE=src/ui/flutter_app/windows/runner/Runner.rc
EN_CHANGLOG_DIR=fastlane/metadata/android/en-US/changelogs
2021-05-27 00:02:09 +08:00
DE_CHANGLOG_DIR=fastlane/metadata/android/de-DE/changelogs
2021-07-04 22:31:46 +08:00
ES_CHANGLOG_DIR=fastlane/metadata/android/es-ES/changelogs
ZH_CHANGLOG_DIR=fastlane/metadata/android/zh-CN/changelogs
2021-07-11 23:59:39 +08:00
SED=sed
if [ "$(uname)" == "Darwin" ]; then
SED=gsed
fi
# Update Build Number
./version.sh
# version: 1.0.6+1811
2021-07-11 23:59:39 +08:00
VERSION_STRING=`$SED -n '4p' $YAML_FILE`
echo "VERSION_STRING = $VERSION_STRING"
# 1.0.6+1811
FULL_VERSION=`echo $VERSION_STRING | cut -d ' ' -f 2`
echo "FULL_VERSION = $FULL_VERSION"
# 1.0.6
VERSION=`echo $FULL_VERSION | cut -d "+" -f 1`
echo "VERSION = $VERSION"
OLD_VERSION=$VERSION
echo "OLD_VERSION = $OLD_VERSION"
# 6
MAJOR_NUMBER=`echo $VERSION | cut -d "." -f 1`
MINOR_NUMBER=`echo $VERSION | cut -d "." -f 2`
PATCH_NUMBER=`echo $VERSION | cut -d "." -f 3`
echo "MAJOR_NUMBER = $MAJOR_NUMBER"
echo "MINOR_NUMBER = $MINOR_NUMBER"
echo "PATCH_NUMBER = $PATCH_NUMBER"
OLD_PATCH_NUMBER=$PATCH_NUMBER
echo "OLD_PATCH_NUMBER = $OLD_PATCH_NUMBER"
# 7
let "PATCH_NUMBER+=1"
echo "PATCH_NUMBER = $PATCH_NUMBER"
# 1.0.7
NEW_VERSION="${MAJOR_NUMBER}.${MINOR_NUMBER}.${PATCH_NUMBER}"
echo "NEW_VERSION = $NEW_VERSION"
# 1811
BUILD_NUMBER=`echo $FULL_VERSION | cut -d "+" -f 2`
echo "BUILD_NUMBER = $BUILD_NUMBER"
# 1.0.7+1811
NEW_FULL_VERSION="$NEW_VERSION+$BUILD_NUMBER"
echo "NEW_FULL_VERSION = $NEW_FULL_VERSION"
# version: 1.0.7+1811
NEW_VERSION_STRING="version: $NEW_FULL_VERSION"
echo "NEW_VERSION_STRING = $NEW_VERSION_STRING"
# Modify yaml
2021-07-11 23:59:39 +08:00
$SED -i "s/${VERSION_STRING}/${NEW_VERSION_STRING}/g" $YAML_FILE
# Modify Qt
OLD_FILEVERSION="$MAJOR_NUMBER,$MINOR_NUMBER,$OLD_PATCH_NUMBER"
FILEVERSION="$MAJOR_NUMBER,$MINOR_NUMBER,$PATCH_NUMBER"
2021-07-12 00:08:53 +08:00
$SED -i "s/${OLD_FILEVERSION},0/${FILEVERSION},0/g" $QT_RC_FILE
$SED -i "s/${OLD_VERSION}.0/${NEW_VERSION}.0/g" $QT_RC_FILE
# Modify Runner.rc
2021-07-11 23:59:39 +08:00
$SED -i "s/${OLD_FILEVERSION}/${FILEVERSION}/g" $FLUTTER_WINDOWS_RC_FILE
$SED -i "s/${OLD_VERSION}/${NEW_VERSION}/g" $FLUTTER_WINDOWS_RC_FILE
# Changelog
rm -f ${BUILD_NUMBER}.txt
touch ${BUILD_NUMBER}.txt
echo "v$NEW_VERSION" >> ${BUILD_NUMBER}.txt
echo >> ${BUILD_NUMBER}.txt
cp ${BUILD_NUMBER}.txt $EN_CHANGLOG_DIR
2021-05-27 00:02:09 +08:00
cp ${BUILD_NUMBER}.txt $DE_CHANGLOG_DIR
2021-07-04 22:31:46 +08:00
cp ${BUILD_NUMBER}.txt $ES_CHANGLOG_DIR
cp ${BUILD_NUMBER}.txt $ZH_CHANGLOG_DIR
rm -f ${BUILD_NUMBER}.txt
echo "* Release notes." >> $EN_CHANGLOG_DIR/${BUILD_NUMBER}.txt
2021-05-27 00:02:09 +08:00
echo "* Versionshinweise." >> $DE_CHANGLOG_DIR/${BUILD_NUMBER}.txt
2021-07-04 22:31:46 +08:00
echo "* Notas de publicación." >> $ES_CHANGLOG_DIR/${BUILD_NUMBER}.txt
echo "* 发布说明。" >> $ZH_CHANGLOG_DIR/${BUILD_NUMBER}.txt
2021-07-11 23:59:39 +08:00
vi $EN_CHANGLOG_DIR/${BUILD_NUMBER}.txt
vi $DE_CHANGLOG_DIR/${BUILD_NUMBER}.txt
vi $ES_CHANGLOG_DIR/${BUILD_NUMBER}.txt
vi $ZH_CHANGLOG_DIR/${BUILD_NUMBER}.txt
# Git commit
git status -s
git add .
git commit -m "Sanmill v$NEW_VERSION (${BUILD_NUMBER})" -m "Official release version of Sanmill v$NEW_VERSION" -s
git tag -d v$NEW_VERSION || true
2021-07-11 23:59:39 +08:00
git tag -m "Sanmill v$NEW_VERSION (${BUILD_NUMBER})" -m "Official release version of Sanmill v$NEW_VERSION" -s v$NEW_VERSION
2021-07-11 19:58:44 +08:00
git tag -v v$NEW_VERSION
git push origin v$NEW_VERSION -f
git push origin master