-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (85 loc) · 2.9 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
name: Build OnePlus Flash Control
env:
main_project_module: app
playstore_name: Bartixxx
on:
push:
branches:
- 'master'
- '**' # Trigger for all branches
pull_request:
branches:
- '**' # Trigger for all branches
workflow_dispatch:
inputs:
prerelease:
description: 'Mark as Pre-release'
required: false
type: boolean
publish:
description: 'Publish release'
required: false
type: boolean
default: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Set current date and repository name as environment variables
- name: Set environment variables
run: |
echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
# Set up JDK for Gradle build
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
cache: 'gradle'
- name: Change wrapper permissions
run: chmod +x ./gradlew
# Run Gradle tests and build the project
- name: Run tests and build project
run: |
./gradlew test
./gradlew build
# Build APK release
- name: Build APK release
run: ./gradlew assembleRelease
# Rename unsigned APK to signed APK name
- name: Rename APK
run: mv app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-release.apk
# Get the current version from Gradle
- name: Get current version
id: version-env
run: |
./gradlew getVersion
echo "version=$(cat app/build/version.txt)" >> $GITHUB_ENV
# Sign APK release
- uses: r0adkll/sign-android-release@v1
name: Sign APK
id: sign_app
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.KEYSTORE_FILE }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "34.0.0"
# Upload signed APK as artifact
- uses: actions/upload-artifact@v4
with:
name: OnePlus Flash Control APK
path: ${{ steps.sign_app.outputs.signedReleaseFile }}
# Publish APK to GitHub Releases only for master branch
- name: Publish APK
if: github.ref == 'refs/heads/master' # Only publish for master branch
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ inputs.prerelease || 'true' }} # Default to 'true' if no input is provided
files: ${{ steps.sign_app.outputs.signedReleaseFile }}
tag_name: v${{ env.version }}