From 5a87bcbd3fb1f280beeca9cd86ed34b794e22849 Mon Sep 17 00:00:00 2001 From: pboymt <10893582+pboymt@users.noreply.github.com> Date: Tue, 21 Mar 2023 22:32:08 +0800 Subject: [PATCH] =?UTF-8?q?build(actions):=20Github=20Workflow=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8F=91=E5=B8=83=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为 Github Workflow 添加构建发布的步骤,每次 Push 将会发布 PreRelease,每次 Tag 将会发布 Release。 --- .github/workflows/android.yml | 45 ++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 25e2a10..3972c2d 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -5,6 +5,8 @@ on: branches: [ "master" ] pull_request: branches: [ "master" ] + tags: + - "v*" workflow_dispatch: env: @@ -17,7 +19,6 @@ env: jobs: build: - runs-on: ubuntu-latest steps: @@ -35,9 +36,9 @@ jobs: uses: actions/cache@v2 with: path: ./opencv - key: opencv-for-android-${{ env.OPENCV_VERSION }} + key: ${{ runner.os }}-opencv-for-android-${{ env.OPENCV_VERSION }} restore-keys: | - opencv-for-android- + ${{ runner.os }}-opencv-for-android- - if: ${{ steps.cache-opencv.outputs.cache-hit != 'true' }} name: Download OpenCV4Android and extract to :opencv @@ -55,9 +56,9 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.NDK_VERSION }} - key: cache-ndk-${{ env.NDK_VERSION }} + key: ${{ runner.os }}-ndk-${{ env.NDK_VERSION }} restore-keys: | - cache-ndk- + ${{ runner.os }}-ndk- - if: ${{ steps.cache-ndk.outputs.cache-hit != 'true' }} name: Install NDK @@ -112,4 +113,36 @@ jobs: with: name: mapping-${{ github.sha }} path: app/build/outputs/mapping/release/mapping.txt - retention-days: 5 \ No newline at end of file + retention-days: 5 + + - name: Publish nightly build if on master + if: github.ref == 'refs/heads/master' + uses: softprops/action-gh-release@v1 + with: + files: | + app/build/outputs/apk/release/app-arm64-v8a-release.apk + app/build/outputs/apk/release/app-x86_64-release.apk + app/build/outputs/apk/release/app-armeabi-v7a-release.apk + app/build/outputs/apk/release/app-x86-release.apk + draft: true + prerelease: true + tag_name: nightly-${{ github.sha }} + name: Nightly build for commit ${{ github.sha }} + body: Nightly build for commit ${{ github.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish release if on tag + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v1 + with: + files: | + app/build/outputs/apk/release/app-arm64-v8a-release.apk + app/build/outputs/apk/release/app-x86_64-release.apk + app/build/outputs/apk/release/app-armeabi-v7a-release.apk + app/build/outputs/apk/release/app-x86-release.apk + draft: false + prerelease: false + tag_name: ${{ github.ref }} + name: Release ${{ github.ref }} + body: Release ${{ github.ref }} + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file