From 0074fee8653317062cdb7445acf1c5662d769e0d Mon Sep 17 00:00:00 2001 From: Aunali321 <48486084+Aunali321@users.noreply.github.com> Date: Sun, 5 Mar 2023 14:53:51 +0530 Subject: [PATCH] build: new ci (#731) New Build CI Commits: * buid: re-do ci * build: ignore tags * build: get the latest flutter version automatically && formatting --------- Co-authored-by: EvadeMaster <93124920+EvadeMaster@users.noreply.github.com> --- .github/workflows/commit-build.yml | 114 +++++++++++++++++++++++++---- 1 file changed, 100 insertions(+), 14 deletions(-) diff --git a/.github/workflows/commit-build.yml b/.github/workflows/commit-build.yml index bb90180d..553f0651 100644 --- a/.github/workflows/commit-build.yml +++ b/.github/workflows/commit-build.yml @@ -1,35 +1,104 @@ -name: "Android CI Actions" - +name: Android Release on: push: branches: - "**" tags-ignore: - - "v*" # Ignore tags that start with "v" (e.g. v1.0.0) because they are handled by release-build.yml + - "v*" + + pull_request: + branches: + - "**" + + workflow_dispatch: jobs: - release: + version: + name: Create version number runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Set up JDK 12 - uses: actions/setup-java@v3 with: - java-version: '12' + fetch-depth: 0 + + - name: Fetch all history for all tags and branches + run: | + git config remote.origin.url https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git fetch --prune --depth=10000 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.7 + with: + versionSpec: "5.x" + + - name: Use GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.7 + + - name: Create version.txt with nuGetVersion + run: echo ${{ steps.gitversion.outputs.nuGetVersion }} > version.txt + + - name: Upload version.txt + uses: actions/upload-artifact@v2 + with: + name: gitversion + path: version.txt + + build: + name: Create Android Build + needs: version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Get version.txt + uses: actions/download-artifact@v2 + with: + name: gitversion + + - name: Create new file without newline char from version.txt + run: tr -d '\n' < version.txt > version1.txt + + - name: Read version + id: version + uses: juliangruber/read-file-action@v1 + with: + path: version1.txt + + - name: Update version in YAML + run: sed -i 's/99.99.99+99/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml + + - name: Download Android keystore + id: android_keystore + uses: timheuer/base64-to-file@v1.0.3 + with: + fileName: upload-keystore.jks + encodedString: ${{ secrets.SIGNING_KEYSTORE }} + + - name: Create key.properties + run: | + echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties + echo "storePassword=${{ secrets.SIGNING_KEYSTORE_PASSWORD }}" >> android/key.properties + echo "keyPassword=${{ secrets.SIGNING_KEY_PASSWORD }}" >> android/key.properties + echo "keyAlias=${{ secrets.SIGNING_KEY_ALIAS }}" >> android/key.properties + + - uses: actions/setup-java@v3 + with: distribution: 'zulu' + java-version: "12.x" + cache: gradle + - uses: subosito/flutter-action@v2 with: channel: 'stable' - - name: Set environment variables - run: echo $SECRETS | base64 -d > lib/utils/environment.dart - env: - SECRETS: ${{ secrets.SECRETS }} - - name: Set up Flutter + cache: true + + - name: Get dependencies run: flutter pub get + - name: Generate files with Builder run: flutter packages pub run build_runner build --delete-conflicting-outputs + - name: Build with Flutter env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -37,6 +106,7 @@ jobs: SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }} run: flutter build apk + - name: Sign APK id: sign_apk uses: ilharp/sign-android-release@v1 @@ -46,10 +116,26 @@ jobs: keyStorePassword: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }} keyAlias: ${{ secrets.SIGNING_KEY_ALIAS }} keyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} + - name: Add version to APK run: mv ${{ steps.sign_apk.outputs.signedFile }} revanced-manager-${{ env.RELEASE_VERSION }}.apk + - name: Upload APK uses: actions/upload-artifact@v3 with: name: revanced-manager-${{ env.RELEASE_VERSION }} path: revanced-manager-${{ env.RELEASE_VERSION }}.apk + + # deploy: + # name: Deploy Android Build + # needs: build + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v1 + # - name: Get Android Build from artifacts + # uses: actions/download-artifact@v2 + # with: + # name: android-release + +env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true