# Creating and releasing CodePush updates

:::important

This guide describes the general process of releasing your CodePush updates. We recommend using Bitrise CI to automate the process: [CodePush updates with Bitrise CI](/release-management/codepush/codepush-updates-with-bitrise-ci).

:::

## Getting your CodePush credentials

:::note[API only]

If you use the GUI on bitrise.io to release your CodePush updates, you can skip this section.

:::

You need the following deployment credentials to be able to release CodePush updates with the API:

- A [deployment ID](/release-management/codepush/creating-a-codepush-deployment) from Bitrise CodePush.

  iOS and Android require separate deployment IDs.
- An [app ID](/release-management/getting-started-with-release-management/adding-a-new-app-to-release-management) from Bitrise Release Management.

  iOS and Android require separate app IDs.
- A deployment key.

  iOS and Android require separate deployment keys.
- A Bitrise API token: it can be either a [personal access token](/bitrise-platform/accounts/personal-access-tokens) or a [workspace API token](/bitrise-platform/workspaces/workspace-api-token).

You can save these credentials when creating the CodePush deployment. If you need to get them later, use the Release Management API:

1. Make sure you have a Bitrise API token:

   - [Creating a personal access token](/bitrise-platform/accounts/personal-access-tokens#creating-a-personal-access-token).
   - [Creating a Workspace API token](/bitrise-platform/workspaces/workspace-api-token#creating-a-workspace-api-token).
1. Get the app IDs from Release Management for both the iOS and the Android app:

   Open the app in Release Management, and copy the ID from the URL. It is the alphanumeric code at the end of the URL: https://app.bitrise.io/release-management/workspaces/4afb6c4bb001295/connected-apps/12a0cf2b-9cf1-401a-8904-393b18v449ca.
1. Get the deployment ID and the deployment key from the API:

   :::tip

   You can get both the ID and the key when creating the CodePush deployments. Read on if you didn't save them at the time.

   :::

   For the deployment ID, call the `deployments` endpoint. It returns all deployments:

   ```yaml
   curl -X 'GET' \
     'https://api.bitrise.io/release-management/v1/connected-apps/<APP-ID>/code-push/deployments' \
     -H 'accept: application/json' \
     -H 'authorization: <YOUR-ACCESS-TOKEN>'
   ```

   The response contains the deployment ID (`id`) for each deployment which you need in order to get the deployment key (`key`. Call `deployments` with the `id` value:

   ```yaml
   curl -X 'GET' \
     'https://api.bitrise.io/release-management/v1/connected-apps/<APP-ID>/code-push/deployments/<DEPLOYMENT-ID>' \
     -H 'accept: application/json' \
     -H 'authorization: <YOUR-ACCESS-TOKEN>'
   ```

With these credentials, you can proceed to release CodePush updates to your apps.

## Creating an update bundle

**React Native**

1. Make the updates to your code.
1. Create an update bundle for both iOS and Android:

   - iOS:

     ```bash
     npx react-native bundle \
       --platform ios \
       --dev false \
       --entry-file index.js \
       --bundle-output ./build/main.jsbundle \
       --assets-dest ./build
     ```
   - Android:

     ```bash
     npx react-native bundle \
       --platform android \
       --dev false \
       --entry-file index.js \
       --bundle-output ./build/index.android.bundle \
       --assets-dest ./build
     ```
1. Zip the build folder:

   ```bash
   zip -r update.zip ./build
   ```

**Expo**

1. Make the updates to your code.
1. Create an update bundle for both iOS and Android:

   - iOS:

     ```bash
     npx expo export:embed \
       --entry-file index.js \
       --platform ios \
       --dev false \
       --reset-cache \
       --bundle-output ./build/main.jsbundle \
       --assets-dest ./build \
       --minify false
     ```
   - Android:

     ```bash
     npx expo export:embed \
       --entry-file index.js \
       --platform android \
       --dev false \
       --reset-cache \
       --bundle-output ./build/index.android.bundle \
       --assets-dest ./build \
       --minify false
     ```
1. Zip the build folder:

   ```bash
   zip -r update.zip ./build
   ```

## Uploading the package to the Bitrise CodePush Server

You can upload the package either via the Release Management GUI or the Release Management API.

**GUI**

1. Open your app in Release Management.
1. Select **CodePush** on the left.
1. Click **New update**.

   ![20251217-rm-deployments.png](/img/_paligo/uuid-87908768-bac5-5e86-6412-826381a0b8a4.png)
1. Select your deployment in the **Deployment** field.
1. In the **Target versions** field, add the version range of the update.

   You can use range expressions: [Target versions](#target-versions).
1. Optionally, add an update description.
1. Check **Enabled for download** to make sure users can download the update.

   ![20251217-new-codepush-update-dialog.png](/img/_paligo/uuid-8e971849-b560-9393-f308-ed2587195b2c.png)
1. Optionally, check **Mandatory** to prompt users to update immediately.
1. Drag and drop the update file to the drag-and-drop area or click the area and select a file.

   :::important[File requirements]

   - Upload a `.bundle`, `.jsbundle`, or `.zip` file.
   - The maximum file size is 50 MB.

   :::
1. Set the percentage of users that will receive the update in the **Rollout percentage** field.

   You can increase the percentage value later. The default value is 100%.

   To roll out the update automatically, select **Automatically change rollout percentage over a 7-day period** instead, and set the start date and time in the **Rollout start** field. The percentage increases every day, from 1% on the first day to 100% on the seventh day. In this case, click **Schedule release** in the next step.
1. Click **Release update**.

**API**

1. Make sure your CodePush credentials are available: [Getting your CodePush credentials](#getting-your-codepush-credentials).
1. Clone the `release-management-recipes` repository from Bitrise.

   The repository contains a helper script that we will use to upload the update package.

   ```bash
   git clone https://github.com/bitrise-io/release-management-recipes
   ```
1. Go in to the `release-management-recipes` folder:

   ```bash
   cd release-management-recipes
   ```
1. Run the script to upload.

   The script requires the following input data:

   - The path of the `update.zip` file.
   - Your Bitrise API token: this can be either a [personal access token](/bitrise-platform/accounts/personal-access-tokens#creating-a-personal-access-token) or a [workspace API token](/bitrise-platform/workspaces/workspace-api-token).
   - A deployment ID.
   - The version of your app. For more information, see [Target versions](/release-management/codepush/creating-and-releasing-codepush-updates#target-versions).

   The final command should look something like this:

   ```bash
   UPDATE_PATH=../update.zip \
   AUTHORIZATION_TOKEN=<api-token> \
   DEPLOYMENT_ID=<deployment-id> \
   APP_VERSION=<app-version>  /bin/bash ./api/upload_code_push_package.sh
   ```

## Target versions

When creating an update for CodePush, you need to specify the app version when uploading the package to the CodePush server. This is a target version: users running the specified version of the app will receive the updates.

You can use range expressions to specify the version:

| Range expression | Who gets the update |
| --- | --- |
| 1.2.3 | Only devices running the specific binary app store version 1.2.3 of your app |
| * | Any device configured to consume updates from your CodePush app |
| 1.2.x | Devices running major version 1, minor version 2 and any patch version of your app |
| 1.2.3 - 1.2.7 | Devices running any binary version between 1.2.3 (inclusive) and 1.2.7 (inclusive) |
| >=1.2.3 &lt;1.2.7 | Devices running any binary version between 1.2.3 (inclusive) and 1.2.7 (exclusive) |
| 1.2 | Equivalent to >=1.2.0 &lt;1.3.0 |
| ~1.2.3 | Equivalent to >=1.2.3 &lt;1.3.0 |
| ^1.2.3 | Equivalent to >=1.2.3 &lt;2.0.0 |
