mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 03:52:15 +02:00
Render the official changelog for public releases
This enforces that the public changelog is up to date as it becomes the source for the changelog shipped with the app Checks that all the necessary release tools exist and that the changelog actually contains the information for the current version too Fixes #6197
This commit is contained in:
parent
d8d8870b9d
commit
4b088ebd4c
@ -7,31 +7,61 @@
|
||||
# tools/release.sh # For an alpha or beta release
|
||||
# tools/release.sh public # For a public (non alpha/beta) release
|
||||
|
||||
|
||||
# Basic expectations
|
||||
# - tools needed: sed, gawk, github-release, git
|
||||
# - authority needed: ability to commit/tag/push directly to master in AnkiDroid, ability to create releases
|
||||
# - ankidroiddocs checked out in a sibling directory (that is, '../ankidroiddocs' should exist with 'upstream' remote set correctly)
|
||||
|
||||
# Suffix configuration
|
||||
SUFFIX=""
|
||||
#SUFFIX="-EXPERIMENTAL"
|
||||
|
||||
PUBLIC=$1
|
||||
|
||||
# Define the location of the manifest file
|
||||
SRC_DIR="./AnkiDroid/src/main/"
|
||||
MANIFEST="AndroidManifest.xml"
|
||||
|
||||
if [ "$PUBLIC" = "public" ]; then
|
||||
echo "About to perform a public release. Please first:"
|
||||
echo "- Edit the version in AndroidManifest.xml manually but do not commit it."
|
||||
echo "Press Enter to continue."
|
||||
read -r
|
||||
else
|
||||
echo "Performing testing release."
|
||||
# Check basic expectations
|
||||
for UTILITY in sed gawk github-release asciidoctor; do
|
||||
if ! command -v "$UTILITY" >/dev/null 2>&1; then echo "$UTILITY" missing; exit 1; fi
|
||||
done
|
||||
if ! [ -f ../ankidroiddocs/changelog.asc ]; then
|
||||
echo "Could not find ../ankidroiddocs/changelog.asc?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! VERSION=$(grep android:versionName $SRC_DIR$MANIFEST | sed -e 's/.*="//' | sed -e 's/".*//')
|
||||
# Define the location of the manifest file
|
||||
SRC_DIR="./AnkiDroid/src/main"
|
||||
MANIFEST="$SRC_DIR/AndroidManifest.xml"
|
||||
CHANGELOG="$SRC_DIR/assets/changelog.html"
|
||||
|
||||
if ! VERSION=$(grep android:versionName $MANIFEST | sed -e 's/.*="//' | sed -e 's/".*//')
|
||||
then
|
||||
echo "Unable to get current version. Is sed installed?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$PUBLIC" = "public" ]; then
|
||||
echo "About to perform a public release. Please first:"
|
||||
echo "- Edit the version in AndroidManifest.xml manually but do not commit it."
|
||||
echo "- Author and merge a PR to ankidroiddocs/changelog.asc with details for the current version"
|
||||
echo "Press Enter to continue."
|
||||
read -r
|
||||
|
||||
# Render the new changelog
|
||||
if ! asciidoctor ../ankidroiddocs/changelog.asc -o "$CHANGELOG"
|
||||
then
|
||||
echo "Failed to render changelog?"
|
||||
exit 1
|
||||
fi
|
||||
if ! grep "Version $VERSION " "$CHANGELOG"
|
||||
then
|
||||
echo "Could not find entry for version $VERSION in rendered $CHANGELOG ?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Performing testing release."
|
||||
fi
|
||||
|
||||
exit 1
|
||||
|
||||
if [ "$PUBLIC" != "public" ]; then
|
||||
# Increment version name
|
||||
# Ex: 2.1beta7 to 2.1beta8
|
||||
@ -49,13 +79,13 @@ if [ "$PUBLIC" != "public" ]; then
|
||||
# Increment version code
|
||||
# It is an integer in AndroidManifest that nobody actually sees.
|
||||
# Ex: 72 to 73
|
||||
PREVIOUS_CODE=$(grep android:versionCode $SRC_DIR$MANIFEST | sed -e 's/.*="//' | sed -e 's/".*//')
|
||||
PREVIOUS_CODE=$(grep android:versionCode $MANIFEST | sed -e 's/.*="//' | sed -e 's/".*//')
|
||||
GUESSED_CODE=$((PREVIOUS_CODE + 1))
|
||||
|
||||
# Edit AndroidManifest.xml to bump version string
|
||||
echo "Bumping version from $PREVIOUS_VERSION$SUFFIX to $VERSION (and code from $PREVIOUS_CODE to $GUESSED_CODE)"
|
||||
sed -i -e s/"$PREVIOUS_VERSION"$SUFFIX/"$VERSION"/g $SRC_DIR$MANIFEST
|
||||
sed -i -e s/versionCode=\""$PREVIOUS_CODE"/versionCode=\""$GUESSED_CODE"/g $SRC_DIR$MANIFEST
|
||||
sed -i -e s/"$PREVIOUS_VERSION"$SUFFIX/"$VERSION"/g $MANIFEST
|
||||
sed -i -e s/versionCode=\""$PREVIOUS_CODE"/versionCode=\""$GUESSED_CODE"/g $MANIFEST
|
||||
fi
|
||||
|
||||
# Read the key passwords
|
||||
@ -68,15 +98,15 @@ export KEYPWD
|
||||
if ! ./gradlew publishReleaseApk
|
||||
then
|
||||
# APK contains problems, abort release
|
||||
git checkout -- $SRC_DIR$MANIFEST # Revert version change
|
||||
git checkout -- $MANIFEST # Revert version change
|
||||
exit
|
||||
fi
|
||||
|
||||
# Copy exported file to cwd
|
||||
cp AnkiDroid/build/outputs/apk/release/AnkiDroid-release.apk AnkiDroid-"$VERSION".apk
|
||||
|
||||
# Commit modified AndroidManifest.xml
|
||||
git add $SRC_DIR$MANIFEST
|
||||
# Commit modified AndroidManifest.xml (and changelog.html if it changed)
|
||||
git add $MANIFEST $CHANGELOG
|
||||
git commit -m "Bumped version to $VERSION
|
||||
@branch-specific"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user