-
Notifications
You must be signed in to change notification settings - Fork 75
96 lines (84 loc) · 3.44 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
name: Android CI
on:
workflow_dispatch:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up JDK 18
uses: actions/setup-java@v4
with:
java-version: '18'
distribution: 'temurin'
cache: gradle
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # Ensure this matches your project's Node.js version requirements
- name: Install Yarn
run: npm install -g yarn
- name: Install Dependencies
run: yarn install
- name: Decode Keystore
run: echo "${{ secrets.MYAPP_RELEASE_STORE_FILE_BASE64 }}" | base64 -d > $GITHUB_WORKSPACE/android/app/fotos-upload-key.jks
- name: Update Version Code and Name
run: |
latest_version=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r .tag_name)
new_version_code=$(grep 'versionCode' android/app/build.gradle | sed 's/[^0-9]*//g' | awk '{print $1 + 1}')
sed -i "s/versionCode [0-9]*/versionCode ${new_version_code}/" android/app/build.gradle
sed -i "s/versionName \".*\"/versionName \"${latest_version}\"/" android/app/build.gradle
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Android Bundle
run: |
cd android
chmod +x gradlew
./gradlew bundleRelease -Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/android/app/fotos-upload-key.jks -Pandroid.injected.signing.store.password=$MYAPP_RELEASE_STORE_PASSWORD -Pandroid.injected.signing.key.alias=$MYAPP_RELEASE_KEY_ALIAS -Pandroid.injected.signing.key.password=$MYAPP_RELEASE_KEY_PASSWORD
env:
MYAPP_RELEASE_STORE_PASSWORD: ${{ secrets.MYAPP_RELEASE_STORE_PASSWORD }}
MYAPP_RELEASE_KEY_ALIAS: ${{ secrets.MYAPP_RELEASE_KEY_ALIAS }}
MYAPP_RELEASE_KEY_PASSWORD: ${{ secrets.MYAPP_RELEASE_KEY_PASSWORD }}
- 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 = './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: `Fxfotos_${file}`,
data: fs.readFileSync(filePath)
});
}
}