Simplify Expo releases with Standard Version
Tags: expo, beginners, tutorial, version
Published: 2020-01-15 19:58:11

---
title: Simplify Expo releases with Standard Version
published: true
description: Customize and automate your Expo app release flow with Standard Version.
tags: expo, beginner, tutorial, version
cover_image: https://thepracticaldev.s3.amazonaws.com/i/imkfawmbmvemqfoa41ln.jpg
---

Releasing your apps _can_ be a repetitive, sometimes even annoying task. You prepared and built your app for the stores, only to find out you forgot to bump a version code. If you don't like to do this, the great people from [Conventional Changelog](http://github.com/conventional-changelog) got just the thing for you!

Standard version is a tool to simplify the release process with a single command, `yarn standard-version`. It's customizable and should have everything you need, like generated changelogs from [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). If you don't know the tool yet, [check out the documentation first](https://github.com/conventional-changelog/standard-version#standard-version).

In this guide, I'll show you how to configure [Standard version for Expo](https://github.com/expo-community/standard-version-expo#readme). We will set up an example project and configure it for automated `expo.version`, `expo.android.versionCode` and `expo.ios.buildNumber`.


## 🚀 Let's get going

First things first, create an empty Expo project using the blank template. 

```bash
$ expo init --template blank
```

Next, we need to define a starting version for our project. Standard version uses the [`package.json`'s `version`](https://docs.npmjs.com/files/package.json#version) property to determine the current version. This value is used to calculate the next release. Let's set this property to `0.0.0`.

```json
{
  "version": "0.0.0",
  "main": "node_modules/expo/AppEntry.js",
  ...
}
```

Now add Standard version, with the Expo extension, to our dev dependencies.

```bash
$ yarn add --dev standard-version@next standard-version-expo
```

> Currently, [standard-version@7.1.0](https://github.com/conventional-changelog/standard-version/issues/507#issuecomment-565806449) is the only version that supports updaters from packages. That's why we need `@next` here.

You can test the project by running standard-version in dry-run mode. This mode only tells what it will do without doing anything.

```bash
$ yarn standard-version --dry-run
```

> If you get the `Invalid Version: undefined` error, it means the `package.json` doesn't have a starting version.


### ⚙️ Configure Standard version

Now that we've set up the basics, we need to configure Standard version for Expo. Create a file named `.versionrc.js` with:

```js
module.exports = {
  bumpFiles: [
    {
      filename: 'package.json',
    },
    {
      filename: 'app.json',
      updater: require.resolve('standard-version-expo'),
    },
  ],
};
```

> This tells Standard version that we want to update `app.json`, using the default updater from the Expo extension. The updater bumps `expo.version` with the new version, so you don't have to! 😬 

> Note: We also want to update our `package.json`, with the default updater, to keep a single source of truth for our versions. (See [PR #3](https://github.com/expo-community/standard-version-expo/pull/3) for more details)

Test your configuration again with `--dry-run`, if you see the following output, you did an excellent job. 🦄

```bash
$ yarn standard-version --dry-run

✔ bumping version in app.json from 1.0.0 to 0.0.1
✔ created CHANGELOG.md
✔ outputting changes to CHANGELOG.md
...
✔ committing app.json and CHANGELOG.md
✔ tagging release v0.0.1
```

Now commit these changes and create a new minor version.

```bash
$ git add .
$ git commit -m 'feat: add standard version for releases'
$ yarn standard-version --release-as minor
```

After running the tool, you should have a new `CHANGELOG.md` and an updated `app.json` file! You still need to push the local changes to remote, but that also gives you an option to revert changes if something went wrong. 🧑‍🔧


### 📱 Configure build versions

If you are planning on releasing your app to the stores, we need to configure Standard version a bit more. It also needs to update the [Android version codes](https://docs.expo.io/versions/latest/workflow/configuration/#android) and [iOS build numbers](https://docs.expo.io/versions/latest/workflow/configuration/#ios). Let's start by updating our manifest with iOS and Android configuration.

```json
{
  "expo": {
    ...
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.bycedric.awesomeapp",
      "buildNumber": "0.0.0"
    },
    "android": {
      "package": "com.bycedric.awesomeapp",
      "versionCode": 0
    }
  }
}

```

Great, now we need to tell Standard version about these new properties. The values should change on every release, just like our `expo.version`. To do this, open up `.versionrc.js` and add the new version bumpers.

```js
module.exports = {
  bumpFiles: [
    {
      filename: 'package.json',
    },
    {
      filename: 'app.json',
      updater: require.resolve('standard-version-expo'),
    },
    {
      filename: 'app.json',
      updater: require.resolve('standard-version-expo/android'),
    },
    {
      filename: 'app.json',
      updater: require.resolve('standard-version-expo/ios'),
    },
  ],
};

```
> There are multiple types of version updaters, each with their own "tactic". You can [find them all here](https://github.com/expo-community/standard-version-expo#usage). For simplicity, let's stick to the recommended bumpers for now. 

That's it! If you commit these changes and run Standard version, it will update the build version numbers for you too. 🌈

```bash
$ git add .
$ git commit -m 'feat: add standard version for releases'
$ yarn standard-version --release-as patch
```

## 🤝 Thanks for reading!

I hope this can be useful for anyone. If you use this library, feel free to reach out. I'd love to hear about your experiences with the tool. Also, feel free to reach out if you have great ideas to make it better or if you are stuck. 🙆‍♂️


## 📚 Extra goodies

- Join the [Expo Developers slack](https://slack.expo.io/) for Expo related stuff.

- Join the [Node Tooling slack](https://devtoolscommunity.herokuapp.com/) for Standard version or Conventional Commits stuff.

- Read more about [Standard Version](https://github.com/conventional-changelog/standard-version)

- Find out everything about the [Standard Version Expo](https://github.com/expo-community/standard-version-expo) integration

> Edit: I made a mistake of not adding `package.json` to our `.versionrc.js`. Thanks to [awinograd](https://github.com/expo-community/standard-version-expo/pull/3) for spotting and fixing it!

> Cover photo by [Robert Metz](https://unsplash.com/@___rob__?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)