Release CI #77
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: '**MMRL**' | |
| 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 | |
| jobs: | |
| build-release: | |
| name: Build Release | |
| uses: ./.github/workflows/build.yml | |
| with: | |
| buildType: 'Release' | |
| secrets: inherit | |
| build-debug: | |
| name: Build Debug | |
| uses: ./.github/workflows/build.yml | |
| with: | |
| buildType: 'Debug' | |
| secrets: inherit | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [build-release, build-debug] | |
| if: inputs.send_telegram == 'true' || inputs.send_github == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Download Release APK | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.build-release.outputs.release-name }} | |
| path: release-apk | |
| - name: Download Debug APK | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.build-debug.outputs.release-name }} | |
| path: debug-apk | |
| - name: Download Mappings | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: mapping | |
| path: mapping | |
| - name: Find Release APK | |
| id: find_release_apk | |
| run: | | |
| APK_PATH=$(find release-apk -name "*.apk" | head -n 1) | |
| echo "APK_PATH=$APK_PATH" >> $GITHUB_OUTPUT | |
| - name: Find Debug APK | |
| id: find_debug_apk | |
| run: | | |
| APK_PATH=$(find debug-apk -name "*.apk" | head -n 1) | |
| echo "APK_PATH=$APK_PATH" >> $GITHUB_OUTPUT | |
| - name: Find mapping file | |
| id: find_mapping | |
| run: | | |
| MAPPING_PATH=$(find mapping -name "mapping.txt" | head -n 1) | |
| echo "MAPPING_PATH=$MAPPING_PATH" >> $GITHUB_OUTPUT | |
| - 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: Set release platforms message | |
| id: platforms | |
| run: | | |
| PLATFORMS="" | |
| if [[ "${{ github.event.inputs.send_github }}" == "true" ]]; then | |
| PLATFORMS="${PLATFORMS}- **GitHub**: [Release](${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ env.VERSION }})\n" | |
| fi | |
| if [[ "${{ github.event.inputs.send_playstore }}" == "true" ]]; then | |
| PLATFORMS="${PLATFORMS}- **Google Play**: [Play Store](https://play.google.com/store/apps/details?id=com.dergoogler.mmrl)\n" | |
| fi | |
| echo -e "PLATFORMS<<EOF\n${PLATFORMS}EOF" >> $GITHUB_ENV | |
| - name: Upload files to Telegram | |
| if: 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 }} | |
| This release was released on the following platforms: | |
| ${{ env.PLATFORMS }} | |
| [Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| files: | | |
| ${{ steps.find_release_apk.outputs.APK_PATH }} | |
| ${{ steps.find_debug_apk.outputs.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: 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' && 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: ${{ inputs.buildType }} | |
| [Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Release APK to GitHub | |
| if: steps.check_release.outputs.exists == 'false' && inputs.send_github == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_release_apk.outputs.APK_PATH }} | |
| asset_name: release.apk | |
| asset_content_type: application/vnd.android.package-archive | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Debug APK to GitHub | |
| if: steps.check_release.outputs.exists == 'false' && inputs.send_github == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_debug_apk.outputs.APK_PATH }} | |
| asset_name: debug.apk | |
| asset_content_type: application/vnd.android.package-archive | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload mapping to GitHub | |
| if: steps.check_release.outputs.exists == 'false' && inputs.send_github == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_mapping.outputs.MAPPING_PATH }} | |
| asset_name: mapping.txt | |
| asset_content_type: text/plain | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| playstore: | |
| name: Release to Play Store | |
| runs-on: ubuntu-latest | |
| if: inputs.send_playstore == 'true' | |
| needs: build-release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - 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 bundlePlaystore | |
| - 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_OUTPUT | |
| - 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: ${{ steps.find_aab.outputs.AAB_PATH }} | |
| track: production | |
| status: completed | |
| inAppUpdatePriority: 5 |