forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (148 loc) · 5.63 KB
/
build-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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# This is the main Android apk build workflow for both nightly and beta releases.
# This is also configured to run as a workflow_call.
name: Build-Android
on:
workflow_dispatch:
inputs:
build-target:
description: 'Build Target (Release Type)'
type: choice
required: true
options:
- beta
- nightly
- non-release
default: "non-release"
git-ref:
description: "Build from Git Ref(master)"
required: true
default: "master"
enable-file-sync-production:
description: 'File sync production mode'
type: boolean
required: true
default: true
workflow_call:
inputs:
build-target:
type: string
required: true
enable-file-sync-production:
description: 'File sync production mode'
type: boolean
secrets:
ANDROID_KEYSTORE:
required: true
ANDROID_KEYSTORE_PASSWORD:
required: true
SENTRY_AUTH_TOKEN:
required: true
env:
CLOJURE_VERSION: '1.11.1.1413'
NODE_VERSION: '18'
JAVA_VERSION: '17'
jobs:
build-apk:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn cache directory
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
- name: Cache clojure deps
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-clojure-lib-${{ hashFiles('**/deps.edn') }}
- name: Setup clojure
uses: DeLaGuardo/[email protected]
with:
cli: ${{ env.CLOJURE_VERSION }}
- name: Retrieve tag version
id: ref
run: |
pkgver=$(node ./scripts/get-pkg-version.js "${{ inputs.build-target || github.event.inputs.build-target }}")
echo "version=$pkgver" >> $GITHUB_OUTPUT
- name: Update Nightly APP Version
if: ${{ inputs.build-target == '' || inputs.build-target == 'nightly' || github.event.inputs.build-target == 'nightly' }}
run: |
sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs
sed -i 's/versionName ".*"/versionName "${{ steps.ref.outputs.version }}"/g' android/app/build.gradle
- name: Set Build Environment Variables
run: |
echo "ENABLE_FILE_SYNC_PRODUCTION=${{ inputs.enable-file-sync-production || github.event.inputs.enable-file-sync-production || inputs.build-target == '' }}" >> $GITHUB_ENV
- name: Compile CLJS - app variant, use es6 instead of es-next
run: yarn install && yarn release-app
env:
LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
LOGSEQ_POSTHOG_TOKEN: ${{ secrets.LOGSEQ_POSTHOG_TOKEN }}
- name: Upload Sentry Sourcemaps (beta only)
if: ${{ github.repository == 'logseq/logseq' && (inputs.build-target == 'beta' || github.event.inputs.build-target == 'beta') }}
run: |
curl -sL https://sentry.io/get-cli/ | bash
release_name="logseq-android@${{ steps.ref.outputs.version }}"
sentry-cli releases new "${release_name}"
sentry-cli releases files "${release_name}" upload-sourcemaps --ext map --ext js ./static/js --url-prefix '~/static/js'
sentry-cli releases finalize "${release_name}"
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: logseq
SENTRY_PROJECT: logseq
- name: Prepare public Directory
run: |
cp -r static public/
rm -rvf public/static/js/publishing
rm -rvf public/static/js/*.js.map || true
rm -rvf public/static/*.*
rm -rvf public/static/ios
rm -rvf android/app/src/main/assets/public || true
- name: Sync public to Android Project
run: npx cap sync android
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Build Android
run: |
./gradlew clean
./gradlew zipApksForRelease
working-directory: android
env:
LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
- name: Sign Android APK
run: |
echo ${{ secrets.ANDROID_KEYSTORE }} | base64 -d > keystore.jks
/usr/local/lib/android/sdk/build-tools/33.0.0/apksigner sign \
--ks keystore.jks --ks-pass "pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" \
--in app/build/outputs/apk/release/app-release-unsigned.apk \
--out app-signed.apk
working-directory: android
- name: Rename Apk
run: |
mkdir builds
mv android/app-signed.apk ./builds/Logseq-android-${{ steps.ref.outputs.version }}.apk
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: logseq-android-builds
path: builds