-
Notifications
You must be signed in to change notification settings - Fork 4
131 lines (115 loc) · 5.61 KB
/
android.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Android CI
on:
push:
branches: [ "main" ]
paths:
- android/**
- .github/workflows/*
pull_request:
branches: [ "main" ]
paths:
- android/**
- .github/workflows/*
release:
types: ["published"]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: source submodules
run: git submodule update --init
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: rust deps
run: cargo install [email protected] --locked
- name: rust targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi
- name: rust cache
uses: actions/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust/target/
# An explicit key for restoring and saving the cache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Run the post step to save the cache even if another step before fail
save-always: true
- name: gradle cargoNDK plugin needs this file for some reason
run: touch android/local.properties
- name: Grant execute permission for gradlew
working-directory: android/
run: chmod +x gradlew
- name: Build with Gradle
if: ${{ !(github.event_name == 'release') }}
working-directory: android/
run: ./gradlew build
- name: Decode and write Keystore
if: ${{ (github.event_name == 'release') }}
env:
SIGNING_STORE_BASE64: ${{ secrets.SIGNING_STORE_BASE64 }}
TMP_DIR: ${{ runner.temp }}
run: |
SIGNING_STORE_FILE_PATH="${TMP_DIR}/keystore.jks"
echo ${SIGNING_STORE_BASE64} | base64 -di > ${SIGNING_STORE_FILE_PATH}
- name: Change gradle signing config to github release
if: ${{ (github.event_name == 'release') }}
run: |
sed -i 's/signingConfigs.getByName("debug")/signingConfigs.getByName("github")/g' android/app/build.gradle.kts
- name: Build with Gradle for release
if: ${{ (github.event_name == 'release') }}
working-directory: android/
run: ./gradlew build assembleSource-originalRelease
env:
SIGNING_STORE_FILE_PATH: ${{ runner.temp }}/keystore.jks
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
- name: Upload apks to release assets
if: ${{ (github.event_name == 'release') }}
run: |
curl --fail -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.RELEASE_UPLOAD_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=sharepaste.oo-source-original-arm64-v8a-release.unstrippedlibs.apk" \
--data-binary "@android/app/build/outputs/apk/source-original/release/sharepaste.oo-source-original-arm64-v8a-release.apk"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.RELEASE_UPLOAD_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=sharepaste.oo-source-original-armeabi-v7a-release.unstrippedlibs.apk" \
--data-binary "@android/app/build/outputs/apk/source-original/release/sharepaste.oo-source-original-armeabi-v7a-release.apk"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.RELEASE_UPLOAD_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=sharepaste.oo-source-original-universal-release.unstrippedlibs.apk" \
--data-binary "@android/app/build/outputs/apk/source-original/release/sharepaste.oo-source-original-universal-release.apk"
- name: Upload Build Artifacts (Apks)
if: ${{ !(github.event_name == 'release') }}
uses: actions/[email protected]
with:
# Artifact name
name: BuiltApks-${{ github.sha }}
# A file, directory or wildcard pattern that describes what to upload
path: android/app/build/outputs/apk/**/release/
# The level of compression for Zlib to be applied to the artifact archive. The value can range from 0 to 9: - 0: No compression - 1: Best speed - 6: Default compression (same as GNU Gzip) - 9: Best compression Higher levels will result in better compression, but will take longer to complete. For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
compression-level: 9
# If true, an artifact with a matching name will be deleted before a new one is uploaded. If false, the action will fail if an artifact for the given name already exists. Does not fail if the artifact does not exist.
#overwrite: # optional, default is false