-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (122 loc) · 4.75 KB
/
android_deploy.yml
File metadata and controls
129 lines (122 loc) · 4.75 KB
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
name: FxBlox Android Deploy
on:
workflow_dispatch:
release:
types: [published]
jobs:
deploy-android:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space
run: |
echo "Disk space before cleanup:"
df -h
# Remove unused software to free up space
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/share/boost
sudo rm -rf /usr/share/swift
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# Remove Docker images
sudo docker image prune --all --force || true
# Clean apt cache
sudo apt-get clean
echo "Disk space after cleanup:"
df -h
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # Use the same Node.js version as your project requirements
- name: Set up JDK 18
uses: actions/setup-java@v3
with:
java-version: '18'
distribution: 'temurin'
- name: Enable Corepack
run: |
corepack enable
corepack prepare yarn@3.6.4 --activate
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: 'cmdline-tools;latest'
- name: Yarn Install
run: yarn install
- name: Ensure Symlink
run: npm run ensure:symlink
- name: Install CMake
run: |
echo "##[group]Install CMake"
sdkmanager --install "cmake;3.10.2.4988404"
yes | sdkmanager --licenses
echo "##[endgroup]"
- name: Install Android Build Tools
run: sdkmanager "build-tools;29.0.3"
- name: List Build Tools Directory
run: ls -la /usr/local/lib/android/sdk/build-tools/29.0.3
- name: Add Build Tools to PATH
run: echo "/usr/local/lib/android/sdk/build-tools/29.0.3" >> $GITHUB_PATH
- name: Get NPM Package Version
run: echo "NPM_PACKAGE_VERSION=$(node -p "require('${{ github.workspace }}/apps/box/package.json').version")" >> $GITHUB_ENV
- name: Show GITHUB_ENV
run: echo $GITHUB_ENV
- name: Decode Keystore
run: echo "${{ secrets.SIGNING_KEY_BASE64 }}" | base64 -d > ${{ github.workspace }}/apps/box/android/app/signingKey.jks
- name: Build Android Release
run: |
cd ${{ github.workspace }}/apps/box/android
chmod +x gradlew
# Clean before build to ensure fresh state
./gradlew clean
./gradlew bundleRelease -Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/apps/box/android/app/signingKey.jks -Pandroid.injected.signing.store.password=$KEY_STORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEY_ALIAS -Pandroid.injected.signing.key.password=$KEY_PASSWORD --no-daemon
env:
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx4g -XX:+HeapDumpOnOutOfMemoryError"'
- name: List Directory
run: ls -la ${{ github.workspace }}/apps/box/android/app/build/outputs/bundle/release
- name: Get Release Info
id: get-release-info
uses: actions/github-script@v5
with:
script: |
let uploadUrl = 0;
try {
const release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
uploadUrl = release.data.id;
} catch (error) {
console.log('Error fetching latest release: ', error.message);
}
return uploadUrl;
- name: Print release upload URL
run: echo "Upload URL is ${{ steps.get-release-info.outputs.result }}"
- name: Upload Update File Parts to Release
uses: actions/github-script@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const fs = require('fs');
const path = require('path');
const directory = '${{ github.workspace }}/apps/box/android/app/build/outputs/bundle/release';
const files = fs.readdirSync(directory);
for (const file of files) {
if (file.startsWith('app')) {
const filePath = path.join(directory, file);
console.log(`Uploading ${file}...`);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ steps.get-release-info.outputs.result }},
name: `FxBlox_${file}`,
data: fs.readFileSync(filePath)
});
}
}