Skip to content

Fix gradle build action #15

Fix gradle build action

Fix gradle build action #15

name: Generated APK AAB (Upload - Create Artifact To Github Action)
env:
# The name of the main module repository
main_project_module: app
on:
push:
branches:
- 'master'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
# Set Repository Name As Env Variable
- name: Set repository name as env variable
run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
- name: Set Up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
cache: 'gradle'
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Create google-sevices.json
run: cat /home/runner/work/LFilms/LFilms/app/google-services.json | base64
- name: Putting data
env:
DATA: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: echo $DATA > /home/runner/work/LFilms/LFilms/app/google-services.json
# Setuup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
# Execute Gradle build
- name: Execute Gradle build
run: ./gradlew build
- name: Retrieve Version
run: |
echo "::set-output name=VERSION_NAME::$(${{github.workspace}}/gradlew -q printVersionName)"
id: android_version
- name: Get version
run: |
echo "VERSION_NAME=${{steps.android_version.outputs.VERSION_NAME}}" >> $GITHUB_ENV
- name: Upload APK Release
uses: actions/upload-artifact@v3
with:
name: ${{ env.repository_name }}-v${{ env.VERSION_NAME }}.apk
path: ${{ github.workspace }}/app/build/outputs/apk/release/app-release.apk
- name: Create release and upload apk
uses: ncipollo/release-action@v1
with:
artifacts: ${{ github.workspace }}/app/build/outputs/apk/release/app-release.apk
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ env.VERSION_NAME }}
body: |
[${{ github.event.head_commit.message }}](${{ github.event.head_commit.url }})
draft: true
prerelease: false
allowUpdates: true