Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit a9eab2d

Browse files
committed
feat(ci): Automate app builds by fetching from upstream
1 parent bdcf243 commit a9eab2d

File tree

7 files changed

+175
-148
lines changed

7 files changed

+175
-148
lines changed

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
custom: https://signal.org/donate/
2+
github: pixincreate

.github/workflows/android.yml

-42
This file was deleted.

.github/workflows/android_build.yml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Android CI
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
permissions:
8+
contents: write
9+
10+
env:
11+
GRADLE_OPTS: -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-20.04
16+
17+
steps:
18+
- name: Checkout Forked Repo
19+
uses: actions/checkout@v4
20+
with:
21+
repository: pixincreate/Signal
22+
ref: main
23+
fetch-depth: 0
24+
submodules: true
25+
26+
- name: Setup Keystore File
27+
env:
28+
KEYSTORE: ${{ secrets.KEYSTORE_FILE }}
29+
GPG_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD_GPG }}
30+
run: |
31+
echo "$KEYSTORE" > keystore.jks.asc
32+
gpg -d --passphrase "$GPG_PASSWORD" --batch keystore.jks.asc > keystore.jks
33+
34+
- name: set up JDK 17
35+
uses: actions/setup-java@v4
36+
with:
37+
distribution: "temurin"
38+
java-version: "17"
39+
cache: "gradle"
40+
41+
- name: Setup Android SDK
42+
uses: android-actions/setup-android@v3
43+
44+
- name: Grant execute permission for gradlew
45+
run: chmod +x gradlew
46+
47+
- name: Build with Gradle
48+
run: |
49+
./gradlew clean assemblePlayFossProdRelease --stacktrace
50+
51+
- name: Find the APK file
52+
run: |
53+
apk_dir=app
54+
apk_files=$(find $apk_dir -name "*.apk")
55+
if [ -z "$apk_files" ]; then
56+
echo "No APK files found in $apk_dir"
57+
else
58+
echo "APK files found in $apk_dir:"
59+
echo "$apk_files"
60+
fi
61+
62+
apk_file=$(basename $(find "app" -name "*-arm64-v8a-release-unsigned-*.apk"))
63+
apk_name="${apk_file//unsigned/signed}"
64+
echo "APP_NAME=$apk_name" >> $GITHUB_ENV
65+
66+
- name: Sign the APK
67+
env:
68+
ALIAS_NAME: ${{ secrets.KEYSTORE_ALIAS_NAME }}
69+
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
70+
ALIAS_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD_ALIAS }}
71+
APP_PATH: "app/build/outputs/apk/playFossProd"
72+
run: |
73+
path=${ANDROID_HOME}/build-tools/$(ls ${ANDROID_HOME}/build-tools/ | tail -1)
74+
75+
$path/zipalign -v -p 4 ${{ env.APP_PATH }}/release/*-arm64-v8a-release-unsigned-*.apk ${{ env.APP_PATH }}/release/aligned.apk
76+
echo -e -n "\nAlignment Succeeded!\n"
77+
$path/apksigner sign --ks keystore.jks --ks-key-alias $ALIAS_NAME --ks-pass pass:$KEYSTORE_PASSWORD --key-pass pass:$ALIAS_PASSWORD --out ${{ env.APP_PATH }}/release/${{ env.APP_NAME }} ${{ env.APP_PATH }}/release/aligned.apk
78+
echo -e -n "\nAPK Signing completed successfully!\n"
79+
$path/apksigner verify ${{ env.APP_PATH }}/release/${{ env.APP_NAME }}
80+
81+
rm keystore.jks
82+
83+
- name: Get app version
84+
run: |
85+
version=$(echo "${{ env.APP_NAME }}" | sed 's/.*-\([0-9]\+\.[0-9]\+\.[0-9]\+\)\.apk/\1/')
86+
echo "app_version=v-${version}" >> $GITHUB_ENV
87+
88+
- name: Upload artifact
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: Signal-Android-${{ env.app_version }}
92+
path: app/build/outputs/apk/playFossProd/release/${{ env.APP_NAME }}
93+
retention-days: 2
94+
95+
- name: Release APK
96+
uses: "dciborow/[email protected]"
97+
with:
98+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
99+
automatic_release_tag: ${{ env.app_version }}
100+
prerelease: false
101+
title: Signal-Android-${{ env.app_version }}
102+
files: |
103+
app/build/outputs/apk/playFossProd/release/${{ env.APP_NAME }}

.github/workflows/diffuse.yml

-84
This file was deleted.

.github/workflows/docker.yml

-21
This file was deleted.

.github/workflows/update_fork.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Update Fork
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "30 5 * * MON,WED,FRI" # runs every monday, wednesday and friday at 05:30 UTC
7+
8+
permissions:
9+
contents: write
10+
actions: write
11+
12+
jobs:
13+
update_fork:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Forked Repo
18+
uses: actions/checkout@v4
19+
with:
20+
repository: pixincreate/Signal
21+
ref: main
22+
fetch-depth: "0"
23+
submodules: true
24+
25+
- name: Setup Git
26+
run: git config --global user.email ${{ secrets.EMAIL }} && git config --global user.name pixincreate
27+
28+
- name: Fetch from Upstream
29+
run: |
30+
git remote add upstream https://github.com/signalapp/Signal-Android.git
31+
git fetch upstream --tags
32+
upstream_commit="$(git rev-parse upstream/main)"
33+
echo "Upstream latest commit: ${upstream_commit}"
34+
for forked_commit in $(git rev-list -n 20 main); do
35+
if [ $upstream_commit != $forked_commit ]; then
36+
has_new_commits=true
37+
continue
38+
else
39+
has_new_commits=false
40+
break
41+
fi
42+
done
43+
if [ $has_new_commits == "true" ]; then
44+
git checkout main
45+
if ! git rebase upstream/main; then
46+
git diff
47+
echo "ERROR: Merge conflict encountered during rebase!"
48+
git rebase --abort
49+
exit 1
50+
fi
51+
git submodule update --init --recursive # Update the submodule
52+
git push -f origin main
53+
echo "Rebase successful!"
54+
else
55+
echo "ERROR: No commits to be synced!"
56+
exit 1
57+
fi
58+
59+
build_app:
60+
needs: update_fork
61+
uses: ./.github/workflows/android_build.yml
62+
secrets: inherit
63+
# References:
64+
# https://stackoverflow.com/questions/75192546/is-it-possible-to-call-another-workflow-file-from-another-workflow-files-condit/75225285#75225285
65+
# https://stackoverflow.com/questions/75191443/how-to-check-if-upstreams-head-latest-commit-is-present-in-forked-repo
66+
# https://stackoverflow.com/questions/75191328/why-does-git-rebase-upstream-main-behaves-differently-when-used-github-actions
67+
# https://stackoverflow.com/questions/62750603/github-actions-trigger-another-action-after-one-action-is-completed

gradle.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
org.gradle.jvmargs=-Xmx6g -Xms256m -XX:MaxMetaspaceSize=1g
1+
org.gradle.jvmargs=-Xmx6g -Xms512m -XX:MaxMetaspaceSize=1g
22
android.useAndroidX=true
33
android.experimental.androidTest.numManagedDeviceShards=4
44
android.defaults.buildfeatures.buildconfig=true
55
android.nonTransitiveRClass=false
66
android.nonFinalResIds=false
7+
org.gradle.unsafe.configuration-cache=true
8+
org.gradle.parallel=true
9+
kotlin.parallel.tasks.in.project=true

0 commit comments

Comments
 (0)