Skip to content

Optimize Android publish workflow by splitting PR and release build paths#109

Merged
AbandonedCart merged 4 commits intomainfrom
copilot/optimize-build-workflows
Apr 18, 2026
Merged

Optimize Android publish workflow by splitting PR and release build paths#109
AbandonedCart merged 4 commits intomainfrom
copilot/optimize-build-workflows

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

Publishing was slower than necessary because PR validation and release publishing shared the same heavy build path. This change separates fast feedback from publish-critical work while preserving release behavior.

  • Build-path split by event

    • PR runs now execute only a compile check (:app:compileGithubDebugKotlin).
    • Non-PR runs (publish path) keep full release assembly (assembleGithubRelease).
  • Publish-only steps isolated

    • Signing, artifact upload, and GitHub release creation remain gated to non-PR events.
    • This removes release packaging/signing overhead from PR validation runs.
  • Workflow overhead reductions

    • Checkout now explicitly disables submodule checkout.
    • Build hash is derived directly from GITHUB_SHA.
    • Artifact upload uses compression-level: 0 to reduce publish-path CPU time.
- name: Build PR Gradle checks
  if: github.event_name == 'pull_request'
  with:
    arguments: |
      --configure-on-demand
      --parallel
      :app:compileGithubDebugKotlin

- name: Build Release Gradle
  if: github.event_name != 'pull_request'
  with:
    arguments: |
      --configure-on-demand
      --parallel
      assembleGithubRelease

Summary by Sourcery

Split the Android workflow into separate paths for fast PR validation and full release publishing, while tightening checkout and artifact settings for efficiency.

Enhancements:

  • Limit Android workflow checkout to a shallow clone without submodules to reduce overhead.
  • Derive the build hash directly from GITHUB_SHA instead of computing branch and hash via git commands.
  • Introduce a PR-only Gradle compile job that runs a lightweight debug Kotlin compile instead of the full release build.
  • Restrict the full release Gradle build, signing, and artifact handling to non-pull-request events, including disabling compression for uploaded artifacts to speed publishing.

Copilot AI and others added 4 commits April 18, 2026 21:16
Agent-Logs-Url: https://github.com/intro-skipper/segment-editor-mobile/sessions/99b96c3a-4993-49a8-9105-15a9442423f1

Co-authored-by: AbandonedCart <1173913+AbandonedCart@users.noreply.github.com>
@AbandonedCart AbandonedCart marked this pull request as ready for review April 18, 2026 21:24
@AbandonedCart AbandonedCart merged commit da70cba into main Apr 18, 2026
2 of 3 checks passed
@AbandonedCart AbandonedCart deleted the copilot/optimize-build-workflows branch April 18, 2026 21:25
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 18, 2026

Reviewer's Guide

Splits the Android GitHub Actions workflow into distinct PR-validation and release build paths, simplifies build metadata generation, and tightens conditions around signing and artifact/release handling to reduce CI time and overhead.

Sequence diagram for PR vs release Android build in GitHub Actions

sequenceDiagram
    actor Developer
    participant GitHub
    participant Android_CI_Workflow
    participant Gradle
    participant Sign_Action
    participant Upload_Artifact
    participant GitHub_Releases

    Developer->>GitHub: Open_PR_or_push_tag
    GitHub->>Android_CI_Workflow: Trigger_android.yml

    Android_CI_Workflow->>Android_CI_Workflow: Checkout_repo
    Android_CI_Workflow->>Android_CI_Workflow: Set_build_hash_from_GITHUB_SHA
    Android_CI_Workflow->>Android_CI_Workflow: Setup_JDK_and_Android_SDK

    alt pull_request_event
        Android_CI_Workflow->>Gradle: :app:compileGithubDebugKotlin
        Gradle-->>Android_CI_Workflow: Compile_result_for_PR_validation
        Android_CI_Workflow-->>GitHub: Report_PR_check_status
    else non_pull_request_event
        Android_CI_Workflow->>Gradle: assembleGithubRelease
        Gradle-->>Android_CI_Workflow: Release_APK
        Android_CI_Workflow->>Sign_Action: Sign_release_APK
        Sign_Action-->>Android_CI_Workflow: Signed_APK
        Android_CI_Workflow->>Upload_Artifact: Upload_signed_APK
        Upload_Artifact-->>Android_CI_Workflow: Artifact_URL
        Android_CI_Workflow->>GitHub_Releases: Create_or_update_release
        GitHub_Releases-->>Android_CI_Workflow: Release_published
        Android_CI_Workflow-->>GitHub: Report_workflow_status
    end
Loading

Flow diagram for Android CI workflow split by event

flowchart TD
    A[GitHub_event_trigger
    pull_request_or_other] --> B[Run_android_CI_workflow]

    B --> C{Event_is_pull_request}

    C -- yes --> D[Checkout_repo
    fetch-depth_1
    submodules_false]
    D --> E[Set_build_hash
    from_GITHUB_SHA]
    E --> F[Setup_JDK_17]
    F --> G[Setup_Android_SDK]
    G --> H[Run_Gradle_PR_checks
    :app:compileGithubDebugKotlin
    configuration-cache_true]

    C -- no --> D2[Checkout_repo
    fetch-depth_1
    submodules_false]
    D2 --> E2[Set_build_hash
    from_GITHUB_SHA]
    E2 --> F2[Setup_JDK_17]
    F2 --> G2[Setup_Android_SDK]
    G2 --> H2[Run_Gradle_release_build
    assembleGithubRelease]
    H2 --> I[Sign_release_APK]
    I --> J[Upload_artifact
    compression-level_0]
    J --> K[Create_GitHub_release]
Loading

File-Level Changes

Change Details Files
Split Gradle build path so PRs run a lightweight compile task while non-PR events perform the full release assembly.
  • Added a PR-only Gradle cache step that runs :app:compileGithubDebugKotlin with configuration cache enabled when the event is pull_request.
  • Restricted the existing release Gradle cache step to non-pull_request events and ensured it runs assembleGithubRelease with parallel execution enabled.
.github/workflows/android.yml
Optimize repository checkout and build hash computation for CI efficiency.
  • Configured actions/checkout to use shallow fetch with fetch-depth: 1.
  • Disabled submodule checkout by setting submodules: false.
  • Replaced git-based branch/hash discovery with a simple GIT_HASH derived from the short form of GITHUB_SHA written into GITHUB_ENV.
.github/workflows/android.yml
Isolate publishing-related work (signing, artifact upload, and release handling) to non-PR events and reduce artifact upload overhead.
  • Gated the Android release signing step to only run for non-pull_request events.
  • Gated the artifact upload step to only run for non-pull_request events and set compression-level: 0 to lower CPU usage.
  • Ensured GitHub release-related steps only execute on non-PR events, preserving publish behavior while keeping PR validation fast.
.github/workflows/android.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • You removed the GIT_BRANCH environment variable; double-check any downstream steps or external consumers that might still rely on it and either keep setting it or update those usages accordingly.
  • Using github.event_name != 'pull_request' for the release path will also run the heavy build for events like workflow_dispatch or push on non-release branches; consider tightening this condition if you only want full releases on specific events or branches.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You removed the `GIT_BRANCH` environment variable; double-check any downstream steps or external consumers that might still rely on it and either keep setting it or update those usages accordingly.
- Using `github.event_name != 'pull_request'` for the release path will also run the heavy build for events like `workflow_dispatch` or `push` on non-release branches; consider tightening this condition if you only want full releases on specific events or branches.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants