# Publish to the cloud with Codemagic (no Mac)

Publishes **iOS** and **Android** through the Codemagic cloud. Each platform has
its own workflow, so you can ship them separately or both together.

Some steps the **CLI does for you**; others are **manual**, done once in the
Codemagic dashboard or in the `codemagic.yaml` file. Each heading below says which is which.

## Prerequisites

- A [Codemagic](https://codemagic.io) account
- A Git repository connected to Codemagic
- iOS: Apple Developer account + app in App Store Connect
- Android: app in Google Play Console + a signing keystore

## 1. Add CI to the project — the CLI creates the file

```bash
kasy add ci
```

This creates `codemagic.yaml` at the project root (`ios-workflow` and
`android-workflow`).

## 2. Set up in the Codemagic dashboard — manual, once

These are secrets and can only be done in the dashboard — one time:

1. Open [codemagic.io/apps](https://codemagic.io/apps) and **connect your repository**.
2. **iOS** — *Integrations → App Store Connect*: connect the Apple API key. Its
   name goes in `integrations: app_store_connect:` in `codemagic.yaml`.
3. **Android** — *Code signing identities → Android keystores*: upload the
   keystore with **Reference name** `keystore_reference` (matching `codemagic.yaml`).
4. **Android** — upload the **Google Play service account** JSON as the secret
   variable `GOOGLE_PLAY_SERVICE_ACCOUNT_CREDENTIALS` (group `google_play`).

> The **app keys** (RevenueCat, backend, etc.) do **not** need to be filled in
> the dashboard: `kasy codemagic release` sends them automatically from your
> `.env`. If you'd rather trigger from the dashboard/push, add them to the
> variable groups instead.

## 3. Adjust 2 fields in `codemagic.yaml` — manual, once

The file already flags these with a `<-- Put your...` comment:

- **`publishing.app_store_connect.beta_groups`** (iOS) — replace `kasy` with the
  name of a tester group you create in TestFlight (App Store Connect → your app
  → TestFlight → Groups). Without this the build uploads, but nobody gets invited.
- **`publishing.email.recipients`** (iOS and Android) — put your email, or
  delete the whole `email:` section if you don't want notifications.

## 4. Set up in the terminal — the CLI drives it, once

```bash
kasy codemagic configure
```

You just paste the API token when the wizard asks; the rest is automatic — it
opens the **API token** page (Settings → Codemagic API), validates the token
and **lists your apps** to pick from — no IDs to type. It saves everything to
`.kasy/codemagic.env` (gitignored).

## 5. Trigger a build — the CLI does the rest

```bash
kasy codemagic release            # iOS + Android
kasy codemagic release --ios      # iOS only
kasy codemagic release --android  # Android only
```

The command reads your `.env` and carries the production keys (including the
RevenueCat production key, `appl_`/`goog_`) with the trigger. A step in
`codemagic.yaml` recreates the `.env` in the cloud before building, so the build
ships with the right keys. Per `codemagic.yaml`, iOS goes to TestFlight and
Android to the configured track (`internal` by default).

> **Android lands as a draft.** `codemagic.yaml` uploads with
> `submit_as_draft: true` — the build reaches the internal track, but you still
> need to open Play Console → Internal testing → Review release → Start
> rollout to actually release it to testers.

## Build status

```bash
kasy codemagic status <buildId>
```

## Can I use the Mac and Codemagic at the same time?

Yes. They are two paths to the same store; they don't conflict. The build number
is computed by the cloud (latest in the store + 1), so it rarely collides. For
day-to-day, pick one main path.

## Local Mac

If you have a Mac: see [ios-release.md](./ios-release.md) and `kasy ios release`.
