From 9f41d055313c62c46a421d447d50cd3b3011bdd9 Mon Sep 17 00:00:00 2001 From: lisonge Date: Sun, 3 Sep 2023 13:48:06 +0800 Subject: [PATCH] feat: github actions build apk --- .../{Apk-Build.yml => Build-Apk.yml} | 9 +-- .github/workflows/Build-Release.yml | 55 +++++++++++++++++++ .gitignore | 1 + 3 files changed, 59 insertions(+), 6 deletions(-) rename .github/workflows/{Apk-Build.yml => Build-Apk.yml} (73%) create mode 100644 .github/workflows/Build-Release.yml diff --git a/.github/workflows/Apk-Build.yml b/.github/workflows/Build-Apk.yml similarity index 73% rename from .github/workflows/Apk-Build.yml rename to .github/workflows/Build-Apk.yml index a307f55..91ac357 100644 --- a/.github/workflows/Apk-Build.yml +++ b/.github/workflows/Build-Apk.yml @@ -2,23 +2,20 @@ name: Apk-Build on: workflow_dispatch: - inputs: - name: - description: 'Person to greet' - required: true - default: 'Mona the Octocat' jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: '17' - run: chmod 777 ./gradlew - run: ./gradlew build + - name: Archive artifacts uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/Build-Release.yml b/.github/workflows/Build-Release.yml new file mode 100644 index 0000000..134ee04 --- /dev/null +++ b/.github/workflows/Build-Release.yml @@ -0,0 +1,55 @@ +name: Build Release + +on: + push: + tags: + - v* + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '17' + - run: chmod 777 ./gradlew + - run: ./gradlew build + + - name: Upload Asset + uses: actions/upload-artifact@v3 + with: + name: app-release.apk + path: app/build/outputs/apk/release/app-release.apk + + release: + needs: build + permissions: write-all + runs-on: ubuntu-latest + steps: + - name: Download Asset + uses: actions/download-artifact@v3 + with: + name: app-release.apk + + - 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 }} + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: app-release.apk + asset_name: app-release-${{ github.ref_name }}.apk + asset_content_type: application/vnd.android.package-archive diff --git a/.gitignore b/.gitignore index 37427ae..9953c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ local.properties .idea /kotlin-js-store +.vscode