play-console-cli icon indicating copy to clipboard operation
play-console-cli copied to clipboard

Feature: Firebase App Distribution integration (firebaseappdistribution/v1)

Open tamtom opened this issue 8 months ago • 3 comments

Summary

Add a new gplay firebase command group that integrates with the Firebase App Distribution API (v1), enabling developers to upload pre-release builds, manage testers and groups, distribute releases, and retrieve tester feedback — all from the same CLI they already use for Google Play Console.

Why this is applicable to Google Play

Many Google Play Console users also use Firebase App Distribution as their primary channel for distributing pre-release APKs and AABs to internal QA teams, beta testers, and stakeholders before promoting builds to Play Console tracks. Firebase App Distribution integrates with Play's internal app sharing service for AABs, and both services share the same Google Cloud service account authentication. Bringing Firebase App Distribution into gplay creates a single CLI for the entire Android release pipeline: build → distribute to testers via Firebase → collect feedback → promote to Play Console tracks.

Problem

Currently, developers managing both Firebase App Distribution and Google Play Console must switch between the Firebase CLI (firebase appdistribution:distribute) and gplay for different stages of their release workflow. There is no unified CLI experience for:

  • Uploading builds to Firebase App Distribution for pre-release testing
  • Managing Firebase tester pools (separate from Play Console track testers)
  • Distributing builds to specific tester groups with release notes
  • Retrieving tester feedback reports from Firebase
  • Checking AAB signing info for distributed bundles
  • Deleting old pre-release distributions

The existing gplay testers commands only manage Play Console track testers (via Edits.Testers), and gplay internal-sharing uses Play's internal app sharing — neither covers the Firebase App Distribution workflow.

Goals

  • Provide full CRUD for Firebase App Distribution testers and groups
  • Support uploading APKs and AABs to Firebase App Distribution
  • Enable distributing releases to testers/groups with release notes
  • Surface tester feedback reports for distributed releases
  • Support AAB info retrieval (signing certificate, integration status)
  • Follow existing CLI patterns (JSON-first, --output flag, --dry-run, --paginate)
  • Reuse the same service account auth already configured in gplay
  • Scope all commands by --project (Firebase/GCP project ID or number)

Proposed Commands

Command group: gplay firebase

gplay firebase <subcommand> [flags]

All subcommands require --project <firebase-project-id> (or GPLAY_FIREBASE_PROJECT env var / config field).


Uploads

# Upload an APK or AAB to Firebase App Distribution
gplay firebase upload --project <id> --app <app-id> --file <path> [--release-notes <text>] [--release-notes-file <path>]
  • --app is the Firebase app ID (e.g., 1:1234567890:android:abcdef)
  • --file accepts .apk or .aab files
  • Upload is a long-running operation; the CLI polls operations.get until complete, then prints the resulting release
  • Uses shared.ContextWithUploadTimeout for the upload, shared.ContextWithTimeout for polling
  • If --release-notes is provided, automatically patches the release after upload completes

Releases

# List releases for an app
gplay firebase releases list --project <id> --app <app-id> [--paginate] [--page-size <n>]

# Get a specific release
gplay firebase releases get --project <id> --app <app-id> --release <release-id>

# Update release notes
gplay firebase releases update --project <id> --app <app-id> --release <release-id> --release-notes <text>

# Distribute a release to testers and/or groups
gplay firebase releases distribute --project <id> --app <app-id> --release <release-id> [--testers <emails>] [--groups <group-aliases>]

# Batch delete releases
gplay firebase releases delete --project <id> --app <app-id> --releases <id1,id2,...> [--confirm]

Testers

# List all testers in the project
gplay firebase testers list --project <id> [--paginate] [--page-size <n>]

# Add testers by email
gplay firebase testers add --project <id> --emails <email1,email2,...>

# Remove testers by email
gplay firebase testers remove --project <id> --emails <email1,email2,...> [--confirm]

# Update a tester's display name
gplay firebase testers update --project <id> --tester <tester-id> --display-name <name>

Groups

# List all tester groups
gplay firebase groups list --project <id> [--paginate] [--page-size <n>]

# Create a new group
gplay firebase groups create --project <id> --alias <alias> --display-name <name>

# Get group details
gplay firebase groups get --project <id> --group <alias>

# Update a group
gplay firebase groups update --project <id> --group <alias> --display-name <name>

# Delete a group
gplay firebase groups delete --project <id> --group <alias> [--confirm]

# Add testers to a group
gplay firebase groups add-testers --project <id> --group <alias> --emails <email1,email2,...>

# Remove testers from a group
gplay firebase groups remove-testers --project <id> --group <alias> --emails <email1,email2,...> [--confirm]

Feedback

# List feedback reports for a release
gplay firebase feedback list --project <id> --app <app-id> --release <release-id> [--paginate] [--page-size <n>]

# Get a specific feedback report
gplay firebase feedback get --project <id> --app <app-id> --release <release-id> --report <report-id>

# Delete a feedback report
gplay firebase feedback delete --project <id> --app <app-id> --release <release-id> --report <report-id> [--confirm]

AAB Info

# Get Android App Bundle signing info
gplay firebase aab-info --project <id> --app <app-id>

Implementation Details

API Endpoints

The Firebase App Distribution REST API v1 base URL is https://firebaseappdistribution.googleapis.com. Key resources:

Resource Endpoint Pattern Methods
Upload POST /upload/v1/{app=projects/*/apps/*}/releases:upload upload (media)
Releases /v1/{parent=projects/*/apps/*}/releases list, get, patch, batchDelete, distribute
Feedback Reports /v1/{parent=projects/*/apps/*/releases/*}/feedbackReports list, get, delete
Release Operations /v1/{name=projects/*/apps/*/releases/*/operations/*} get (for polling upload status)
Groups /v1/{parent=projects/*}/groups create, list, get, patch, delete, batchJoin, batchLeave
Testers /v1/{parent=projects/*}/testers list, patch, batchAdd, batchRemove
AAB Info /v1/{name=projects/*/apps/*/aabInfo} get

Authentication

  • Uses the same service account already configured via gplay auth login --service-account
  • Requires the OAuth scope https://www.googleapis.com/auth/cloud-platform
  • The service account must have appropriate Firebase App Distribution roles (e.g., roles/firebaseappdistribution.admin) on the GCP project
  • Firebase App Distribution API must be enabled in the GCP project (firebaseappdistribution.googleapis.com)
  • Resource names are scoped to GCP project number/ID, not the Play Console package name — hence the --project flag instead of --package

Go Client Library

Use the official Google API Go client: google.golang.org/api/firebaseappdistribution/v1

This is already available through the existing google.golang.org/api v0.272.0 dependency in go.mod. Key service types:

  • firebaseappdistribution.Service — top-level service
  • firebaseappdistribution.MediaService — binary upload
  • firebaseappdistribution.ProjectsAppsReleasesService — release CRUD + distribute
  • firebaseappdistribution.ProjectsGroupsService — group management
  • firebaseappdistribution.ProjectsTestersService — tester management
  • firebaseappdistribution.ProjectsAppsReleasesFeedbackReportsService — feedback
  • firebaseappdistribution.ProjectsAppsReleasesOperationsService — upload polling

Initialize with the existing service account credentials:

import (
    firebaseappdistribution "google.golang.org/api/firebaseappdistribution/v1"
    "google.golang.org/api/option"
)

svc, err := firebaseappdistribution.NewService(ctx,
    option.WithCredentialsFile(keyPath),
    option.WithScopes(firebaseappdistribution.CloudPlatformScope),
)

New Packages and Files

internal/
├── cli/
│   └── firebase/                    # New command group package
│       ├── firebase.go              # Root `gplay firebase` command
│       ├── upload.go                # Upload subcommand
│       ├── releases.go              # Releases subcommands (list, get, update, distribute, delete)
│       ├── testers.go               # Testers subcommands (list, add, remove, update)
│       ├── groups.go                # Groups subcommands (list, create, get, update, delete, add-testers, remove-testers)
│       ├── feedback.go              # Feedback subcommands (list, get, delete)
│       ├── aabinfo.go               # AAB info subcommand
│       └── firebase_test.go         # Tests
├── firebaseclient/                  # New Firebase API client wrapper (mirrors playclient pattern)
│   ├── client.go                    # Service initialization, auth, config resolution
│   └── client_test.go              # Tests

Relationship to Existing Commands

Existing Command Firebase Equivalent Key Difference
gplay testers gplay firebase testers Play testers are per-track; Firebase testers are per-project
gplay internal-sharing upload-apk/bundle gplay firebase upload Internal sharing gives URLs; Firebase distributes to tester groups with notifications
gplay release gplay firebase releases distribute Play releases go to tracks; Firebase releases go directly to testers/groups
gplay tracks list gplay firebase releases list Different resource models
(none) gplay firebase feedback No equivalent — unique to Firebase App Distribution
(none) gplay firebase groups No equivalent — Firebase has its own group model

Upload Handling

  1. Open file with os.Open, validate extension (.apk or .aab)
  2. Create upload context with shared.ContextWithUploadTimeout
  3. Call MediaService.Upload(app).Media(file, googleapi.ContentType("application/octet-stream"))
  4. The upload returns a GoogleLongrunningOperation — poll with ProjectsAppsReleasesOperationsService.Get until Done == true
  5. Parse the result into a GoogleFirebaseAppdistroV1Release
  6. If --release-notes was provided, call ProjectsAppsReleasesService.Patch to set notes
  7. Print the final release object

Configuration

Add optional firebase_project field to Config struct:

{
  "package_name": "com.example.app",
  "firebase_project": "my-project-123"
}

Resolution order for project: --project flag > GPLAY_FIREBASE_PROJECT env var > config firebase_project.

Output Format

All commands follow the existing JSON-first pattern:

  • Default: minified JSON
  • --output table: human-readable table
  • --output markdown: markdown table
  • --pretty: pretty-printed JSON

Acceptance Criteria

  • [ ] gplay firebase --help shows all subcommands with clear descriptions
  • [ ] gplay firebase upload uploads APK/AAB files, polls for completion, prints the resulting release
  • [ ] gplay firebase releases list lists releases with pagination support (--paginate)
  • [ ] gplay firebase releases distribute distributes a release to specified testers and/or groups
  • [ ] gplay firebase releases update updates release notes on an existing release
  • [ ] gplay firebase releases delete batch-deletes releases with --confirm guard
  • [ ] gplay firebase testers list/add/remove/update provides full tester lifecycle management
  • [ ] gplay firebase groups list/create/get/update/delete provides full group lifecycle management
  • [ ] gplay firebase groups add-testers/remove-testers manages group membership
  • [ ] gplay firebase feedback list/get/delete surfaces tester feedback reports
  • [ ] gplay firebase aab-info retrieves AAB signing info
  • [ ] All commands support --output json/table/markdown and --pretty
  • [ ] --dry-run intercepts write operations (upload, distribute, delete, create, update)
  • [ ] --project flag is required and validated; falls back to GPLAY_FIREBASE_PROJECT env var and config
  • [ ] --app flag uses Firebase app ID format (validated)
  • [ ] Authentication reuses existing service account from gplay auth
  • [ ] New firebaseclient package mirrors the playclient pattern for service initialization
  • [ ] firebase.FirebaseCommand() registered in internal/cli/registry/registry.go
  • [ ] Config struct extended with optional firebase_project field
  • [ ] All subcommands set UsageFunc: shared.DefaultUsageFunc
  • [ ] Comprehensive tests for flag validation, error messages, and output formatting
  • [ ] gplay docs generate includes the new Firebase commands

References

tamtom avatar Apr 04 '26 18:04 tamtom

Implementation Checklist

Command & Registration

  • [ ] Command group gplay firebase-distribution (or gplay fad) in internal/cli/firebasedistribution/
  • [ ] Subcommands: upload, groups list/create/delete, testers list/add/remove, releases list/get/delete
  • [ ] Registered in internal/cli/registry/registry.go
  • [ ] UsageFunc: shared.DefaultUsageFunc set on all commands
  • [ ] Dedicated client wrapper for firebaseappdistribution/v1 API
  • [ ] Long-running operation polling for async upload processing
  • [ ] shared.ContextWithUploadTimeout used for binary uploads
  • [ ] Required flags validated with stderr error messages

Tests

  • [ ] CLI black-box tests in internal/cmdtest/firebase_distribution_test.go
  • [ ] Unit tests for group/tester management logic
  • [ ] Error paths: missing --project, missing --app, invalid binary path, upload timeout

Docs & Help

  • [ ] --help output follows existing conventions
  • [ ] Command docs regenerated: gplay docs generate

Validation (before opening PR)

make format
make lint
make test
make build
/tmp/gplay firebase-distribution --help
/tmp/gplay firebase-distribution upload --help
/tmp/gplay firebase-distribution upload              # missing required flags → stderr error
/tmp/gplay firebase-distribution groups list --help

tamtom avatar Apr 05 '26 04:04 tamtom

Addendum to checklist above — docs CI gate:

The PR CI now runs make check-docs on every PR. This means:

  1. After implementing the command, run make docs to regenerate GPLAY.md
  2. Commit the updated GPLAY.md alongside your code changes
  3. If you forget, the PR check will fail with: "GPLAY.md is out of date"

This ensures every user-facing command, flag, and help text is always reflected in the reference docs.

tamtom avatar Apr 05 '26 04:04 tamtom

Consolidating individual feature requests into the roadmap so new visitors see a clean tracker. This item is on the roadmap: #245 — please 👍 there and comment which item you're waiting on. Reopen or file a fresh issue if you start on a PR.

tamtom avatar Jul 05 '26 10:07 tamtom