Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
098suraj authored Jan 10, 2023
1 parent 91152b0 commit 4fdbd3e
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,83 @@ on:

jobs:


generate-apk: # Job to generate debug apk
name: ⚙️Generate APK
runs-on: ubuntu-latest
steps:


- name: get repository name
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 17
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 17.0.1

java-version: 11.0.13

- name: Cache Gradle and wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradle executable
run: chmod +x ./gradlew


- name: Lint
run: ./gradlew lint


- name: Bump version code
uses: chkfung/[email protected]
with:
gradlePath: app/build.gradle
versionCode: ${{github.run_number}}

- name: Build debug apk
run: ./gradlew assembleDebug --stacktrace



- name: Upload debug apk
uses: actions/upload-artifact@v1
with:
name: Android-CI-CD
name: ${{ env.REPOSITORY_NAME }}
path: app/build/outputs/apk/debug/app-debug.apk

create-release: # Job to create a new github release and upload the generated apk
name: 🎉 Create Release
needs: [ generate-apk ]
runs-on: ubuntu-latest
steps:

- name: get repository name
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Download APK from build
uses: actions/download-artifact@v1
with:
name: Android-CI-CD
name: ${{ env.REPOSITORY_NAME }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
tag_name: ${{ github.run_number }}
release_name: ${{ env.REPOSITORY_NAME }} v${{ github.run_number }}

- name: Upload Release APK
id: upload_release_asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Android-CI-CD/app-debug.apk
asset_name: Android-CI-CD.apk
asset_content_type: application/zip
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.REPOSITORY_NAME }}/app-debug.apk
asset_name: ${{ env.REPOSITORY_NAME }}.apk
asset_content_type: application/zip

0 comments on commit 4fdbd3e

Please sign in to comment.