[Shellscript] Deploy updates for apps on F-Droid

#!/bin/bash
set -e
echo "Welcome to F-Droid version publisher!"
echo 
echo "Press Ctrl+C at any time to abort."
echo

echo "+git status"
git status
echo

echo -n 'new versionCode="..." (integer) '
read vCode
echo -n 'new versionName="..." (string) '
read vName

echo "Change versionCode and versionName in AndroidManifest.xml, then press enter"
read
echo "+git add AndroidManifest.xml"
git add AndroidManifest.xml || git add app/AndroidManifest.xml

# Generate release notes, let the user edit them and move them to the fastlane changelogs directory
git log $(git describe --tags --abbrev=0)..HEAD --oneline --no-decorate --no-color | cut -d' ' -f2- > F-Droid-new-version-RELEASE-NOTES.txt
nano F-Droid-new-version-RELEASE-NOTES.txt 
echo "cp F-Droid-new-version-RELEASE-NOTES.txt ./fastlane/metadata/android/en-US/changelogs/${vCode}.txt"
cp F-Droid-new-version-RELEASE-NOTES.txt "./fastlane/metadata/android/en-US/changelogs/${vCode}.txt"

echo "+git add fastlane/metadata/android/en-US/changelogs"
git add fastlane/metadata/android/en-US/changelogs/

echo "+git commit -m 'Bump version'"
git commit -m "Bump version"

echo "+git tag -a v${vName} -F F-Droid-new-version-RELEASE-NOTES.txt"
git tag -a "v${vName}" -F F-Droid-new-version-RELEASE-NOTES.txt

echo "Press enter to publish the new version."
read
echo "+git pull && git push && git push --tags"
git pull && git push && git push --tags

echo "+rm F-Droid-new-version-RELEASE-NOTES.txt"
rm F-Droid-new-version-RELEASE-NOTES.txt

Installation:

mkdir -p ~/bin ; nano --nowrap ~/bin/fd-update.sh # or use any other editor
# Paste the content of the script above
chmod u+x ~/bin/fd-update.sh

To publish an update:

fd-update.sh

This will:

  • ask you some question and let you edit AndroidManifest.xml
  • Generate release notes from your commits and let you edit them (in nano, press Ctrl+K to delete a whole line)
  • Publish the new version with the release notes

If it doesn’t work, tell me.

Any questions, opinions, ideas, requests?

3 Likes

So I’ve got 3 hearts, 141 views and not a single feedback, although I found 2 bugs myself when I downloaded this script from here… If it doesn’t work for you or you tested it and decided not to use it for a particular reason, please tell me!

I do not even really believe that it even worked “out of the box” for all of the three people who liked this post :wink:. There must be further bugs.