|
| 1 | +pass=$$(cat ks.passwd) |
| 2 | +branch_name=$$(git symbolic-ref HEAD) |
| 3 | + |
| 4 | +branch=$$(git symbolic-ref HEAD | cut -d "/" -f 3) |
| 5 | +# track = 'internal', 'alpha', 'beta', 'production' |
| 6 | +track=$$(python3 track.py $(branch)) |
| 7 | + |
| 8 | +releaseVersion=$$(sed -n '1p' version.properties | cut -d "=" -f 2) |
| 9 | +stagingVersion=$$(sed -n '2p' version.properties | cut -d "=" -f 2) |
| 10 | +nightlyVersion=$$(sed -n '3p' version.properties | cut -d "=" -f 2) |
| 11 | +label=$$(sed -n '4p' version.properties | cut -d "=" -f 2) |
| 12 | +tagVersion=$$(sed -n '5p' version.properties | cut -d "=" -f 2) |
| 13 | + |
| 14 | +# label=${releaseVersion}.${stagingVersion}.${nightlyVersion} |
| 15 | + |
| 16 | +aab_output=${label}.aab |
| 17 | +apk_output=${label}.apk |
| 18 | + |
| 19 | +APP_1=${label}.apk |
| 20 | +APP_2=${label}_1.apk |
| 21 | + |
| 22 | +CONTAINER_NAME=deku_sms_container_${label} |
| 23 | +CONTAINER_NAME_1=deku_sms_container_${label}_1 |
| 24 | +CONTAINER_NAME_BUNDLE=deku_sms_container_${label}_bundle |
| 25 | +CONTAINER_NAME_COMMIT_CHECK=$(commit)_commit_check |
| 26 | + |
| 27 | +minSdk=24 |
| 28 | + |
| 29 | +github_url=https://api.github.com/repos/dekusms/DekuSMS-Android/releases |
| 30 | +docker_apk_image=deku_sms_apk_image |
| 31 | +docker_apk_image_commit_check=docker_apk_image_commit_check |
| 32 | +docker_app_image=deku_sms_app_image |
| 33 | + |
| 34 | +diff_check: |
| 35 | + @echo "Building apk output: ${APP_1}" |
| 36 | + @docker build -t ${docker_apk_image} --platform linux/amd64 --target apk-builder . |
| 37 | + @docker run --name ${CONTAINER_NAME} -e PASS=$(pass) ${docker_apk_image} && \ |
| 38 | + docker cp ${CONTAINER_NAME}:/android/app/build/outputs/apk/release/app-release.apk apk-outputs/${APP_1} |
| 39 | + @sleep 3 |
| 40 | + @echo "Building apk output: ${APP_2}" |
| 41 | + @docker run --name ${CONTAINER_NAME_1} -e PASS=$(pass) ${docker_apk_image} && \ |
| 42 | + docker cp ${CONTAINER_NAME_1}:/android/app/build/outputs/apk/release/app-release.apk apk-outputs/${APP_2} |
| 43 | + @diffoscope apk-outputs/${APP_1} apk-outputs/${APP_2} |
| 44 | + @echo $? | exit |
| 45 | + |
| 46 | +docker-build-aab: diff_check |
| 47 | + @sleep 5 |
| 48 | + @docker build -t ${docker_app_image} --platform linux/amd64 --target bundle-builder . |
| 49 | + @docker run --name ${CONTAINER_NAME_BUNDLE} -e PASS=$(pass) -e MIN_SDK=$(minSdk) ${docker_app_image} && \ |
| 50 | + docker cp ${CONTAINER_NAME_BUNDLE}:/android/app/build/outputs/bundle/release/app-bundle.aab apk-outputs/${aab_output} |
| 51 | + |
| 52 | +build-apk: |
| 53 | + @echo "+ Building apk output: ${apk_output} - ${branch_name}" |
| 54 | + @./gradlew clean assembleRelease |
| 55 | + @apksigner sign --ks app/keys/app-release-key.jks \ |
| 56 | + --ks-pass pass:$(pass) \ |
| 57 | + --in app/build/outputs/apk/release/app-release-unsigned.apk \ |
| 58 | + --out apk-outputs/${apk_output} |
| 59 | + @shasum apk-outputs/${apk_output} |
| 60 | + |
| 61 | +bump_version: |
| 62 | + @python3 -m venv venv; \ |
| 63 | + ( \ |
| 64 | + . venv/bin/activate; \ |
| 65 | + pip3 install -r requirements.txt; \ |
| 66 | + python3 bump_version.py $(branch_name); \ |
| 67 | + git add . ; \ |
| 68 | + git commit -m "release: making release"; \ |
| 69 | + ) |
| 70 | + |
| 71 | +build-aab: |
| 72 | + @echo "+ Building aab output: ${aab_output} - ${branch_name}" |
| 73 | + @./gradlew clean bundleRelease |
| 74 | + @apksigner sign --ks app/keys/app-release-key.jks \ |
| 75 | + --ks-pass pass:$(pass) \ |
| 76 | + --in app/build/outputs/bundle/release/app-release.aab \ |
| 77 | + --out apk-outputs/${aab_output} \ |
| 78 | + --min-sdk-version ${minSdk} |
| 79 | + @shasum apk-outputs/${aab_output} |
| 80 | + |
| 81 | +test-flight: |
| 82 | + # check if builds can be signed |
| 83 | + @if [ ! -f "app/keys/app-release-key.jks" ]; then \ |
| 84 | + echo "+ [ERROR] app/keys/app-release-key.jks file not found for signing"; \ |
| 85 | + exit 1; \ |
| 86 | + else \ |
| 87 | + python3 -m venv venv; \ |
| 88 | + ( \ |
| 89 | + . venv/bin/activate; \ |
| 90 | + pip3 install -r requirements.txt; \ |
| 91 | + python3 release.py --github_url "${github_url}"; \ |
| 92 | + ) \ |
| 93 | + fi |
| 94 | + |
| 95 | +release-cd: requirements.txt bump_version docker-build-aab |
| 96 | + @echo "+ Target branch for relase: ${branch}" |
| 97 | + @git tag -f ${tagVersion} |
| 98 | + @git push origin ${branch_name} |
| 99 | + @git push --tag |
| 100 | + @python3 -m venv venv |
| 101 | + @( \ |
| 102 | + . venv/bin/activate; \ |
| 103 | + pip3 install -r requirements.txt; \ |
| 104 | + python3 release.py \ |
| 105 | + --version_code ${tagVersion} \ |
| 106 | + --version_name ${label} \ |
| 107 | + --description "<b>Release</b>: ${label}<br><b>Build No</b>: ${tagVersion}<br><b>shasum</b>: $$(shasum apk-outputs/$(apk_output))" \ |
| 108 | + --branch ${branch} \ |
| 109 | + --track ${track} \ |
| 110 | + --app_bundle_file apk-outputs/${aab_output} \ |
| 111 | + --app_apk_file apk-outputs/${apk_output} \ |
| 112 | + --status "completed" \ |
| 113 | + --platform "all" \ |
| 114 | + --github_url "${github_url}" \ |
| 115 | + ) |
| 116 | + |
| 117 | + |
| 118 | +clean: |
| 119 | + @containers=$$(docker ps -a --filter "ancestor=$(docker_apk_image)" --format "{{.ID}}"); \ |
| 120 | + if [ -n "$$containers" ]; then \ |
| 121 | + docker stop $$containers; \ |
| 122 | + docker rm $$containers; \ |
| 123 | + fi |
| 124 | + @containers=$$(docker ps -a --filter "ancestor=$(docker_app_image)" --format "{{.ID}}"); \ |
| 125 | + if [ -n "$$containers" ]; then \ |
| 126 | + docker stop $$containers; \ |
| 127 | + docker rm $$containers; \ |
| 128 | + fi |
| 129 | + @containers=$$(docker ps -a --filter "ancestor=$(docker_apk_image_commit_check)" --format "{{.ID}}"); \ |
| 130 | + if [ -n "$$containers" ]; then \ |
| 131 | + docker stop $$containers; \ |
| 132 | + docker rm $$containers; \ |
| 133 | + fi |
| 134 | + @echo "y" | docker builder prune -a |
| 135 | + @echo "y" | docker image prune -a |
0 commit comments