Update README.md #93
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |