diff --git a/package.json b/package.json index eda7095..14545c5 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "build-apk": "npm run sync && npm run build-apk-only", "fix-path-apk": "sed --in-place 's|/hackernews|.|g' 'android/app/src/main/assets/public/index.html'", "sync": "npm run build && npm run sync-only", - "build-apk-only": "(cd android && bash ./gradlew assembleDebug)", + "build-apk-only": "(npm run bump && cd android && bash ./gradlew assembleDebug)", "sync-only": "cap sync && npm run fix-path-apk", "push": "npm run build && git add -A && git commit && git push", "bump": "bash ./scripts/bumpVersionNumber.sh" diff --git a/scripts/bumpVersionNumber.sh b/scripts/bumpVersionNumber.sh index e968ccc..a849b42 100644 --- a/scripts/bumpVersionNumber.sh +++ b/scripts/bumpVersionNumber.sh @@ -1,7 +1,12 @@ #!/bin/bash +# Go to the root dir of the repo +cd "$(git rev-parse --show-toplevel)" || return allVersionNumbers="$(git tag | grep --extended-regexp 'v[0-9]+.[0-9]+.[0-9]')" +numberOfVersionNumbers="$(echo "${allVersionNumbers}" | wc --lines)" newVersionNumber="$( echo "${allVersionNumbers}" | tail --lines 1 | awk --field-separator=. '/[0-9]+./{$NF++;print}' OFS=. )" git tag -a "${newVersionNumber}" -m "Bump version" +sed --in-place --regexp-extended "s/versionCode [0-9]+/versionCode ${numberOfVersionNumbers}/" ./android/app/build.gradle +sed --in-place --regexp-extended "s/versionName \".*\"/versionName \"${newVersionNumber/v/}\"/" ./android/app/build.gradle