From 627c6b20a785d8bd009222695c788294e6d1e638 Mon Sep 17 00:00:00 2001 From: Arno Krapf Date: Wed, 24 Jan 2024 10:19:29 +0100 Subject: [PATCH] adding separate deploy stage --- .github/workflows/android.yml | 49 ++++++++++++++++--------- .github/workflows/deploy.yml | 57 +++++++++++++++++++++++++++++ .github/workflows/qmllint-check.yml | 4 +- 3 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 4a07072..3ebaa5e 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,21 +1,31 @@ -name: Android +name: Android Build + on: workflow_call: workflow_dispatch: + push: + branches: + - '*' + - '!main' + pull_request: + branches: + - main + +env: + QTOPCUA_BUILD_ARGS: "-DFEATURE_open62541_security:BOOL=ON -DFEATURE_gds:BOOL=ON -DCMAKE_BUILD_TYPE=Release" + QT_PATH: "/opt/Qt/6.6.1" + SSL_PATH: "dependencies/android_openssl/ssl_3" + ANDROID_VERSION_CODE: ${{github.run_number}} + ANDROID_VERSION_NAME: "0.0.0" jobs: - build: - runs-on: ubuntu-latest + android-build: + runs-on: thuban container: image: stateoftheartio/qt6:6.6-android-aqt options: --user root timeout-minutes: 60 - env: - QTOPCUA_BUILD_ARGS: "-DFEATURE_open62541_security:BOOL=ON -DFEATURE_gds:BOOL=ON -DCMAKE_BUILD_TYPE=Release" - QT_PATH: "/opt/Qt/6.6.1" - SSL_PATH: "dependencies/android_openssl/ssl_3" - ANDROID_VERSION_CODE: "3" - ANDROID_VERSION_NAME: "1.0.0" + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -73,6 +83,14 @@ jobs: cmake --build ./build/qtopcua /opt/Qt/Tools/CMake/bin/cmake --install ./build/qtopcua rm -rf ./build/qtopcua + - name: Check if we build a tag + id: checkref + run: echo ::set-output name=is_tag::$(echo "${{ github.ref }}" | grep -q '^refs/tags/' && echo true || echo false) + - name: Set Version + if: steps.checkref.outputs.is_tag == 'true' + run: | + TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///') + echo "ANDROID_VERSION_NAME=$TAG" >> $GITHUB_ENV - name: Build App run: | mkdir -p ./build/opc_ua_browser && \ @@ -103,14 +121,11 @@ jobs: keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} env: BUILD_TOOLS_VERSION: "33.0.0" - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: - name: Signed app bundle + name: android-apk path: ${{steps.sign_apk.outputs.signedReleaseFile}} - - uses: r0adkll/upload-google-play@v1 + - uses: actions/upload-artifact@v3 with: - serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} - releaseFiles: ${{steps.sign_aab.outputs.signedReleaseFile}} - packageName: com.basyskom.opcua.app - track: internal - status: draft \ No newline at end of file + name: android-abb + path: ${{steps.sign_aab.outputs.signedReleaseFile}} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..73e4fea --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,57 @@ +name: Deploy + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build: + uses: ./.github/workflows/android.yml + if: github.ref == 'refs/heads/main' + + + deploy: + needs: build + if: github.ref == 'refs/heads/main' + runs-on: thuban + steps: + - uses: actions/download-artifact@v3 + - name: Get Version Tag + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Rename APK + run: mv ./android-apk/android-build-release-unsigned-signed.apk ./android-apk/opc-ua-browser_${{ github.run_number }}_${{ env.RELEASE_VERSION }}.apk + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RELEASE_VERSION }} + release_name: Release ${{ env.RELEASE_VERSION }} + body: | + New Release ${{ env.RELEASE_VERSION }} + draft: true + prerelease: false + - 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: ./android-apk/opc-ua-browser_${{ github.run_number }}_${{ env.RELEASE_VERSION }}.apk + asset_name: opc-ua-browser_${{ github.run_number }}_${{ env.RELEASE_VERSION }}.apk + asset_content_type: application/zip + #${GITHUB_REF#refs/*/} + #- uses: r0adkll/upload-google-play@v1 + # with: + # serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} + # releaseFiles: ./android-abb/android-build-release.aab + # packageName: com.basyskom.opcua.app + # track: internal + # status: draft + + +# ./android-abb/android-build-release.aab +# ./android-apk/android-build-release-unsigned-signed.apk \ No newline at end of file diff --git a/.github/workflows/qmllint-check.yml b/.github/workflows/qmllint-check.yml index a645778..7fef587 100644 --- a/.github/workflows/qmllint-check.yml +++ b/.github/workflows/qmllint-check.yml @@ -13,4 +13,6 @@ jobs: with: fetch-depth: 1 - name: Validate QML - uses: liri-infra/qmllint-action@master \ No newline at end of file + uses: liri-infra/qmllint-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}