diff --git a/.github/workflows/release_update.yml b/.github/workflows/release_update.yml index 321e55c20..dc0b82fb8 100644 --- a/.github/workflows/release_update.yml +++ b/.github/workflows/release_update.yml @@ -1,6 +1,12 @@ name: Release update on: + push: + branches: + - "**" + paths: + - "fastlane/**" + - ".github/workflows/release_update.yml" workflow_dispatch: inputs: mode: @@ -25,6 +31,7 @@ on: jobs: release_update: + if: ${{ github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest env: GITHUB_ACCESS_KEY: ${{ secrets.GH_ACCESS_KEY }} @@ -101,7 +108,7 @@ jobs: bundle exec fastlane release_update_batch subdomains:"${{ github.event.inputs.subdomains }}" release_option:${{ github.event.inputs.release_option }} - name: Store app artifacts - if: ${{ github.event.inputs.mode == 'all' }} + if: ${{ always() && github.event.inputs.mode == 'all' }} uses: actions/upload-artifact@v4 with: name: app @@ -111,7 +118,7 @@ jobs: app/build/outputs/apk/debug/app-debug.apk - name: Store batch app artifacts - if: ${{ github.event.inputs.mode == 'batch' }} + if: ${{ always() && github.event.inputs.mode == 'batch' }} uses: actions/upload-artifact@v4 with: name: batch-app-artifacts @@ -119,9 +126,98 @@ jobs: batch_artifacts - name: Store batch summary - if: ${{ github.event.inputs.mode }} == 'batch' + if: ${{ always() && github.event.inputs.mode == 'batch' }} uses: actions/upload-artifact@v4 with: name: batch-summary path: | release_update_batch_summary.json + + push_batch_build: + if: ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest + env: + GITHUB_ACCESS_KEY: ${{ secrets.GH_ACCESS_KEY }} + GITHUB_USERNAME: ${{ secrets.GH_USERNAME }} + API_ACCESS_KEY: ${{ secrets.API_ACCESS_KEY }} + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Validate secrets + run: | + if [ -z "$(echo "$API_ACCESS_KEY" | tr -d '[:space:]')" ]; then + echo "ERROR: API_ACCESS_KEY is not available." + exit 1 + fi + if [ -z "$(echo "$GITHUB_USERNAME" | tr -d '[:space:]')" ]; then + echo "ERROR: GITHUB_USERNAME is not available (required for GitHub Packages Maven auth)." + exit 1 + fi + if [ -z "$(echo "$GITHUB_ACCESS_KEY" | tr -d '[:space:]')" ]; then + echo "ERROR: GITHUB_ACCESS_KEY is not available (required for GitHub Packages Maven auth)." + exit 1 + fi + + - name: Setup JDK 17 + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: 17 + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - name: Caching Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Setup ruby and fastlane + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + + - name: Cache Zoom SDK files + id: zoom-cache + uses: actions/cache@v3 + with: + path: | + ./mobilertc + ./commonlib + key: zoom_sdk_files + + - name: Setup Zoom SDK + if: steps.zoom-cache.outputs.cache-hit != 'true' + run: | + wget https://media.testpress.in/static/android/zoom_sdk.zip + unzip -o ./zoom_sdk.zip + + - name: Batch release (draft) + run: | + export LC_ALL=en_US.UTF-8 + export LANG=en_US.UTF-8 + bundle exec fastlane release_update_batch subdomains:"lms,lmsdemo" release_option:draft + + - name: Store push batch app artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: push-batch-app-artifacts + path: | + batch_artifacts + + - name: Store push batch release summary + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: push-batch-release-summary + path: | + release_update_batch_summary.json diff --git a/fastlane/Fastfile b/fastlane/Fastfile index d59a61832..63716bf04 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -12,6 +12,7 @@ desc "Release updates for a comma-separated batch of subdomains (always continue lane :release_update_batch do |params| raw_subdomains = params[:subdomains].to_s release_option = params[:release_option] + workspace_root = ENV["GITHUB_WORKSPACE"].to_s.strip.empty? ? Dir.pwd : ENV["GITHUB_WORKSPACE"].to_s subdomains = raw_subdomains .split(/[,\s]+/) @@ -32,9 +33,9 @@ lane :release_update_batch do |params| skipped = [] expected_artifacts = [ - { "src" => File.join("app", "build", "outputs", "bundle", "release", "app-release.aab"), "dst" => "app-release.aab" }, - { "src" => File.join("app", "build", "outputs", "apk", "release", "app-release.apk"), "dst" => "app-release.apk" }, - { "src" => File.join("app", "build", "outputs", "apk", "debug", "app-debug.apk"), "dst" => "app-debug.apk" } + { "src" => File.join(workspace_root, "app", "build", "outputs", "bundle", "release", "app-release.aab"), "dst" => "app-release.aab" }, + { "src" => File.join(workspace_root, "app", "build", "outputs", "apk", "release", "app-release.apk"), "dst" => "app-release.apk" }, + { "src" => File.join(workspace_root, "app", "build", "outputs", "apk", "debug", "app-debug.apk"), "dst" => "app-debug.apk" } ].freeze subdomains.each do |subdomain| @@ -60,7 +61,7 @@ lane :release_update_batch do |params| generate_customized_app_files(app_config: app_config) current_step = "collect_artifacts" - artifact_root = File.join("batch_artifacts", subdomain) + artifact_root = File.join(workspace_root, "batch_artifacts", subdomain) FileUtils.mkdir_p(artifact_root) missing = [] @@ -107,7 +108,7 @@ lane :release_update_batch do |params| } } - File.write("release_update_batch_summary.json", JSON.pretty_generate(summary)) + File.write(File.join(workspace_root, "release_update_batch_summary.json"), JSON.pretty_generate(summary)) UI.message("Batch release summary: requested=#{subdomains.length}, succeeded=#{succeeded.length}, failed=#{failed.length}, skipped=#{skipped.length}") if failed.any?