Release CI #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release CI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| title: | |
| required: false | |
| default: '**CI Manager**' | |
| description: 'Title' | |
| message: | |
| required: false | |
| default: 'No message.' | |
| description: 'Message' | |
| send_telegram: | |
| description: 'Release to Telegram' | |
| required: true | |
| default: false | |
| type: boolean | |
| send_playstore: | |
| description: 'Release on Play Store' | |
| required: true | |
| default: false | |
| type: boolean | |
| send_github: | |
| description: 'Release on GitHub' | |
| required: true | |
| default: false | |
| type: boolean | |
| buildType: | |
| description: "Build Type" | |
| type: choice | |
| required: true | |
| default: 'Alpha' | |
| options: | |
| - 'Release' | |
| - 'Playstore' | |
| - 'ReleaseCandidate' | |
| - 'Beta' | |
| - 'Alpha' | |
| - 'Debug' | |
| - 'DebugMin' | |
| jobs: | |
| spoofed-build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| spoofed_apk_path: ${{ steps.find_apk.outputs.APK_PATH }} | |
| spoofed_mapping_path: ${{ steps.find_mapping.outputs.MAPPING_PATH }} | |
| steps: | |
| - name: Parse input | |
| run: echo "BUILD_TYPE_CASED=$(echo '${{ inputs.buildType }}' | sed 's/^\(.*\)$/\L\1/')" >> $GITHUB_ENV | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Spoof Package ID | |
| run: chmod 755 spoof && ./spoof | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4.7.1 | |
| with: | |
| distribution: 'zulu' | |
| java-version: 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4.3.1 | |
| - name: Build Spoofed APK | |
| run: chmod 755 gradlew && ./gradlew assemble${{ inputs.buildType }} | |
| - name: Get release name | |
| if: success() && github.ref == 'refs/heads/master' | |
| id: release-name | |
| run: | | |
| name=`ls app/build/outputs/apk/${{ env.BUILD_TYPE_CASED }}/*.apk | awk -F '(/|.apk)' '{print $6}'` && echo "name=${name}" >> $GITHUB_OUTPUT | |
| - name: Find APK | |
| id: find_apk | |
| run: | | |
| APK_PATH=$(find app/build/outputs/apk/${{ env.BUILD_TYPE_CASED }} -name "*.apk" | head -n 1) | |
| echo "APK_PATH=$APK_PATH" >> $GITHUB_OUTPUT | |
| - name: Find mapping file | |
| id: find_mapping | |
| run: | | |
| MAPPING_PATH=$(find app/build/outputs/mapping/${{ env.BUILD_TYPE_CASED }} -name "mapping.txt" | head -n 1) | |
| echo "MAPPING_PATH=$MAPPING_PATH" >> $GITHUB_OUTPUT | |
| - name: Upload spoofed mapping as artifact | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: spoofed-mapping | |
| path: ${{ steps.find_mapping.outputs.MAPPING_PATH }} | |
| - name: Upload spoofed apk as artifact | |
| if: success() && github.ref == 'refs/heads/master' | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: spoofed-${{ steps.release-name.outputs.name }} | |
| path: app/build/outputs/apk/${{ env.BUILD_TYPE_CASED }}/*.apk | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: spoofed-build | |
| steps: | |
| - name: Parse input | |
| run: echo "BUILD_TYPE_CASED=$(echo '${{ inputs.buildType }}' | sed 's/^\(.*\)$/\L\1/')" >> $GITHUB_ENV | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4.7.1 | |
| with: | |
| distribution: 'zulu' | |
| java-version: 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4.3.1 | |
| - name: Build APK | |
| run: chmod 755 gradlew && ./gradlew assemble${{ inputs.buildType }} | |
| - name: Get release name | |
| if: success() && github.ref == 'refs/heads/master' | |
| id: release-name | |
| run: | | |
| name=`ls app/build/outputs/apk/${{ env.BUILD_TYPE_CASED }}/*.apk | awk -F '(/|.apk)' '{print $6}'` && echo "name=${name}" >> $GITHUB_OUTPUT | |
| - name: Find APK | |
| id: find_apk | |
| run: | | |
| APK_PATH=$(find app/build/outputs/apk/${{ env.BUILD_TYPE_CASED }} -name "*.apk" | head -n 1) | |
| echo "APK_PATH=$APK_PATH" >> $GITHUB_ENV | |
| - name: Find mapping file | |
| id: normal_mapping | |
| run: | | |
| MAPPING_PATH=$(find app/build/outputs/mapping/${{ env.BUILD_TYPE_CASED }} -name "mapping.txt" | head -n 1) | |
| echo "MAPPING_PATH=$MAPPING_PATH" >> $GITHUB_ENV | |
| - name: Get commit info and build timestamp | |
| id: meta | |
| run: | | |
| BUILD_DATE=$(date +"%Y-%m-%d %H:%M:%S") | |
| COMMIT_COUNT=$(git rev-list --count HEAD) | |
| VERSION=$((31320 + COMMIT_COUNT)) | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV | |
| - name: Upload files to Telegram | |
| if: github.event.inputs.send_telegram == 'true' | |
| uses: xz-dev/TelegramFileUploader@v1.1.1 | |
| with: | |
| to-who: '@MMRLCI' | |
| message: |- | |
| ${{ inputs.title }} | |
| #ci_${{ env.VERSION }} | |
| Build on ${{ env.BUILD_DATE }}. | |
| **What's new?** | |
| ${{ inputs.message }} | |
| Type: ${{ env.BUILD_TYPE_CASED }} | |
| [Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| files: | | |
| ${{ env.APK_PATH }} | |
| ${{ needs.spoofed-build.outputs.spoofed_apk_path }} | |
| env: | |
| API_ID: ${{ secrets.API_ID }} | |
| API_HASH: ${{ secrets.API_HASH }} | |
| BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| - name: Check if release exists | |
| if: github.event.inputs.send_github == 'true' | |
| id: check_release | |
| run: | | |
| if gh release view v${{ env.VERSION }} --repo ${{ github.repository }} > /dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| if: steps.check_release.outputs.exists == 'false' && github.event.inputs.send_github == 'true' | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: v${{ env.VERSION }} | |
| release_name: v${{ env.VERSION }} | |
| body: | | |
| ${{ inputs.title }} | |
| #ci_${{ env.VERSION }} | |
| Build on ${{ env.BUILD_DATE }}. | |
| ## What's new? | |
| ${{ inputs.message }} | |
| Type: ${{ env.BUILD_TYPE_CASED }} | |
| [Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload normal APK to GitHub Release | |
| if: steps.check_release.outputs.exists == 'false' && github.event.inputs.send_github == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ env.APK_PATH }} | |
| asset_name: normal.apk | |
| asset_content_type: application/vnd.android.package-archive | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload spoofed APK to GitHub Release | |
| if: steps.check_release.outputs.exists == 'false' && github.event.inputs.send_github == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ needs.spoofed-build.outputs.spoofed_apk_path }} | |
| asset_name: spoofed.apk | |
| asset_content_type: application/vnd.android.package-archive | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload normal mapping to GitHub Release | |
| if: steps.check_release.outputs.exists == 'false' && github.event.inputs.send_github == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ env.MAPPING_PATH }} | |
| asset_name: mapping.txt | |
| asset_content_type: text/plain | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload spoofed mapping to GitHub Release | |
| if: steps.check_release.outputs.exists == 'false' && github.event.inputs.send_github == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ needs.spoofed-build.outputs.spoofed_mapping_path }} | |
| asset_name: spoofed-mapping.txt | |
| asset_content_type: text/plain | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload normal mapping as artifact | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: mapping | |
| path: ${{ env.MAPPING_PATH }} | |
| - name: Upload normal apk as artifact | |
| if: success() && github.ref == 'refs/heads/master' | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: ${{ steps.release-name.outputs.name }} | |
| path: app/build/outputs/apk/${{ env.BUILD_TYPE_CASED }}/*.apk | |
| playstore-build: | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.send_playstore == 'true' | |
| steps: | |
| - name: Parse input | |
| run: | | |
| BUILD_TYPE_CASED=$(echo "${{ inputs.buildType }}" | sed 's/^\(.\)/\L\1/') | |
| echo "BUILD_TYPE_CASED=$BUILD_TYPE_CASED" >> $GITHUB_ENV | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up signing key | |
| run: | | |
| if [ ! -z "${{ secrets.KEY_STORE }}" ]; then | |
| echo keyStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> signing.properties | |
| echo keyAlias='${{ secrets.KEY_ALIAS }}' >> signing.properties | |
| echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> signing.properties | |
| echo keyStore='${{ github.workspace }}/key.jks' >> signing.properties | |
| echo ${{ secrets.KEY_STORE }} | base64 --decode > ${{ github.workspace }}/key.jks | |
| fi | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4.7.1 | |
| with: | |
| distribution: 'zulu' | |
| java-version: 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4.3.1 | |
| with: | |
| validate-wrappers: true | |
| cache-cleanup: always | |
| - name: Bundle with Gradle | |
| run: chmod 755 ./gradlew && ./gradlew bundle${{ inputs.buildType }} | |
| - name: Find AAB | |
| id: find_aab | |
| run: | | |
| AAB_PATH=$(find app/build/outputs/bundle/playstore -name "*.aab" | head -n 1) | |
| echo "AAB_PATH=$AAB_PATH" >> $GITHUB_ENV | |
| - name: Upload to Google Play | |
| uses: r0adkll/upload-google-play@v1.1.3 | |
| with: | |
| serviceAccountJsonPlainText: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }} | |
| packageName: com.dergoogler.mmrl | |
| releaseFiles: ${{ env.AAB_PATH }} | |
| track: production | |
| status: completed | |
| inAppUpdatePriority: 5 | |
| # userFraction: 0.1 | |