2017-04-13 10:14:19 +03:00
|
|
|
#!/bin/bash
|
2024-03-29 18:56:51 +03:00
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
# SPDX-FileCopyrightText: 2017 Tobias Kaminsky <tobias@kaminsky.me>
|
2024-04-30 13:16:39 +03:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
2024-03-29 18:56:51 +03:00
|
|
|
#
|
2017-04-13 10:14:19 +03:00
|
|
|
date=$(date +%Y%m%d)
|
2020-03-04 09:40:33 +03:00
|
|
|
oldLibraryCommit=$(grep "androidLibraryVersion\ =" build.gradle)
|
2020-03-02 18:07:11 +03:00
|
|
|
libraryCommit=$(curl https://api.github.com/repos/nextcloud/android-library/commits/master | jq .sha | sed s'/\"//g')
|
2017-04-13 10:14:19 +03:00
|
|
|
|
|
|
|
# use current date for version code/name
|
2022-03-22 09:58:39 +03:00
|
|
|
sed -i "/versionDev/,/\}/ s/versionCode .*/versionCode $date/" app/build.gradle
|
|
|
|
sed -i "/versionDev/,/\}/ s/versionName .*/versionName \"$date\"/" app/build.gradle
|
2017-04-13 10:14:19 +03:00
|
|
|
|
2020-03-02 18:07:11 +03:00
|
|
|
# change library
|
2020-03-03 09:22:49 +03:00
|
|
|
sed -i s"#androidLibraryVersion\ =.*#androidLibraryVersion =\"$libraryCommit\"#" build.gradle
|
2024-02-29 10:36:27 +03:00
|
|
|
./gradlew --console=plain --dependency-verification lenient -q --write-verification-metadata sha256,pgp help
|
2020-03-02 18:07:11 +03:00
|
|
|
|
2017-04-13 10:14:19 +03:00
|
|
|
# build signed apk
|
2022-03-16 09:31:08 +03:00
|
|
|
source ndk.env
|
|
|
|
yes | sdkmanager --licenses
|
|
|
|
|
|
|
|
if [ ! -e ~/android-sdk/ndk/${NDK_VERSION} ]; then
|
|
|
|
sdkmanager "ndk;${NDK_VERSION}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -e ~/android-sdk/cmake/${CMAKE_VERSION} ]; then
|
|
|
|
sdkmanager "cmake;${CMAKE_VERSION}"
|
|
|
|
fi
|
|
|
|
|
2017-04-13 10:14:19 +03:00
|
|
|
./gradlew assembleVersionDevRelease >> /tmp/dev.log 2>&1
|
|
|
|
|
2019-04-08 14:57:13 +03:00
|
|
|
if [ $? != 0 ] ; then
|
2017-04-13 10:14:19 +03:00
|
|
|
echo "Build error!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# sign
|
2018-04-23 10:50:50 +03:00
|
|
|
mkdir -p ~/apks
|
|
|
|
|
2017-04-13 10:14:19 +03:00
|
|
|
source ~/.gradle/devVersionSecrets
|
2020-11-20 14:58:07 +03:00
|
|
|
apksigner sign --ks-pass env:VERSION_DEV_STORE_PASSWORD \
|
2017-04-13 10:14:19 +03:00
|
|
|
--key-pass env:VERSION_DEV_KEY_PASSWORD \
|
|
|
|
--ks $VERSION_DEV_STORE_FILE \
|
2018-04-23 10:50:50 +03:00
|
|
|
--out ~/apks/nextcloud-dev-$date.apk \
|
2022-03-11 13:30:59 +03:00
|
|
|
./app/build/outputs/apk/versionDev/release/versionDev-release-$date.apk
|
2017-04-13 10:14:19 +03:00
|
|
|
|
|
|
|
# use the current date
|
|
|
|
echo $date > ~/apks/latest
|
|
|
|
|
|
|
|
ln -s nextcloud-dev-$date.apk latest.apk
|
|
|
|
mv latest.apk ~/apks/
|
|
|
|
|
|
|
|
# remove all but the latest 5 apks
|
|
|
|
/bin/ls -t ~/apks/*.apk | awk 'NR>6' | xargs rm -f
|
|
|
|
|
2020-03-07 05:27:27 +03:00
|
|
|
lastBuildTag=$(git tag | grep dev | tail -n1)
|
2020-02-27 08:24:21 +03:00
|
|
|
# Show only the commit subject in the changelog and filter out:
|
|
|
|
# * Merges
|
|
|
|
# * Dependabot commits
|
|
|
|
# * Commits touching only non-user-facing stuff like tests
|
|
|
|
# * Version bump commits
|
2020-03-07 05:27:27 +03:00
|
|
|
# * Anything reachable from the previous dev edition tag
|
2022-03-11 13:30:59 +03:00
|
|
|
changelog=$(git log --no-merges --invert-grep --author=dependabot --pretty='format:%s' HEAD "^$lastBuildTag" -- ':!app/src/androidTest' ':!.*' ':!scripts/' ':!screenshots' ':!CHANGELOG.md' | grep -vE '^daily dev [[:digit:]]{8}$')
|
2020-02-27 08:24:21 +03:00
|
|
|
# Make Transifex updates have a nicer description
|
|
|
|
if echo "$changelog" | grep -q 'tx-robot'; then
|
|
|
|
changelog=$(echo "$changelog" | grep -v 'tx-robot')
|
|
|
|
# This is a funky bashism - preceding a single-quote string with $ lets you put escape chars in it
|
|
|
|
changelog="${changelog}"$'\nUpdate translations'
|
|
|
|
fi
|
2019-04-08 14:57:13 +03:00
|
|
|
|
2020-02-27 08:24:21 +03:00
|
|
|
# Check if the library was updated
|
2020-03-04 09:40:33 +03:00
|
|
|
if ! echo $oldLibraryCommit | grep -q $libraryCommit; then
|
2020-02-27 08:24:21 +03:00
|
|
|
changelog="${changelog}"$'\nUpdate Nextcloud Android library'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Collapse dependency updates into a single "Update dependencies" entry
|
2020-03-07 05:27:27 +03:00
|
|
|
if git log --pretty='format:%an' HEAD "^$lastBuildTag" | grep -q dependabot; then
|
2020-02-27 08:24:21 +03:00
|
|
|
changelog="${changelog}"$'\nUpdate 3rd-party dependencies'
|
|
|
|
fi
|
|
|
|
|
2020-01-23 15:40:35 +03:00
|
|
|
# changelog
|
2023-02-06 14:19:50 +03:00
|
|
|
echo "$changelog" > src/versionDev/fastlane/metadata/android/en-US/changelogs/$date.txt
|
2020-01-23 15:40:35 +03:00
|
|
|
|
2020-01-29 10:38:03 +03:00
|
|
|
git add .
|
2019-04-08 14:57:13 +03:00
|
|
|
git commit -m "daily dev $date" -m "$changelog"
|
2017-12-08 13:39:48 +03:00
|
|
|
git push
|
2017-12-04 10:26:20 +03:00
|
|
|
|
2017-04-13 10:14:19 +03:00
|
|
|
git tag dev-$date
|
|
|
|
git push origin dev-$date
|