Release CI #12
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' | |
| spoof_build: | |
| description: 'Spoof Build (Telegram only)' | |
| required: true | |
| default: false | |
| type: boolean | |
| 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: 'Aplha' | |
| options: | |
| - 'Release' | |
| - 'Playstore' | |
| - 'ReleaseCandidate' | |
| - 'Beta' | |
| - 'Alpha' | |
| - 'Debug' | |
| - 'DebugMin' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Spoof Package ID | |
| if: github.event.inputs.spoof_build == 'true' | |
| run: echo $(ls) && chmod 755 spoof && ./spoof | |
| - 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 | |
| if: github.ref == 'refs/heads/master' | |
| 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: Build with Gradle | |
| run: chmod 755 ./gradlew && ./gradlew assemble${{ inputs.buildType }} | |
| - name: Bundle with Gradle (only PlayStore builds) | |
| if: github.event.inputs.buildType == 'Playstore' | |
| run: chmod 755 ./gradlew && ./gradlew bundle${{ 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: 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 }} | |
| env: | |
| API_ID: ${{ secrets.API_ID }} | |
| API_HASH: ${{ secrets.API_HASH }} | |
| BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| - name: Check if release exists | |
| 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' && github.event.inputs.spoof_build == 'false' && github.ref == 'refs/heads/master' | |
| 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 }}) | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Release Asset (APK) | |
| if: steps.check_release.outputs.exists == 'false' && github.event.inputs.send_github == 'true' && github.event.inputs.spoof_build == 'false' && github.ref == 'refs/heads/master' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ env.APK_PATH }} | |
| asset_name: ${{ steps.release-name.outputs.name }}.apk | |
| asset_content_type: application/vnd.android.package-archive | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Find AAB | |
| if: github.event.inputs.send_playstore == 'true' && github.event.inputs.spoof_build == 'false' | |
| 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 | |
| if: github.event.inputs.send_playstore == 'true' && github.event.inputs.spoof_build == 'false' | |
| 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 | |
| - name: Upload built apk | |
| 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 | |
| - name: Upload mappings | |
| if: success() && github.ref == 'refs/heads/master' | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: mappings | |
| path: app/build/outputs/mapping/${{ env.BUILD_TYPE_CASED }} |