Skip to content

Commit

Permalink
Create deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
098suraj authored Jan 10, 2023
1 parent d9d22a5 commit 28dae22
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: AppBuild

on:
pull_request:
branches:
- 'master'
push:
branches:
- 'master'

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 11
uses: actions/setup-java@v1
with:
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: 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: ${{ 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: ${{ env.REPOSITORY_NAME }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
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: ${{ env.REPOSITORY_NAME }}/app-debug.apk
asset_name: ${{ env.REPOSITORY_NAME }}.apk
asset_content_type: application/zip

0 comments on commit 28dae22

Please sign in to comment.