diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9c33641..e13a653 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,30 +10,52 @@ 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/android-version-actions@v1.1 + 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 @@ -41,11 +63,13 @@ jobs: 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 @@ -53,8 +77,8 @@ jobs: 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 @@ -62,7 +86,7 @@ jobs: 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