Notes

Doing automated Git Flow branch deploys on their own Expo release channels with Bitbucket Pipelines

Edit on GitHub

DevOps

background

  • I have an Expo based React Native app that i publish with expo publish
  • I follow git flow branch naming and structure
  • I gave multiple people working on plenty of features that we need to test separately

what i want

Publish every branch to it’s own release channel automatically

the issue

Because i’m using Git Flow, the branch naming is feature/my-awesome-branch. I can get the branch name with a built-in pipeline variable, but the / after feature doesn’t work with Expo release channel naming. You can’t have a / in a release channel name..

[06:23:47] Release channel name can only contain lowercase letters, numbers and special characters . _ and -

the solution

  • Get the branch name with ${BITBUCKET_BRANCH}, do some sed magic to remove / in the name, and voila!

the code

 1feature/*:
 2  - step:
 3      name: Publish to Expo
 4      deployment: feature
 5      caches:
 6        - npm
 7      script:
 8        - unset NPM_CONFIG_USER
 9        - npm ci
10        - npm install -g --unsafe-perm expo-cli
11        - expo login -u ${EXPO_USERNAME} -p ${EXPO_PASSWORD}
12        - RELEASE_CHANNEL_FEATURE=$(echo ${BITBUCKET_BRANCH} | sed 's|feature/|feature_|')
13        - expo publish --clear --release-channel ${RELEASE_CHANNEL_FEATURE} # RELEASE_CHANNEL is a based on branch name (feature/my-feature => feature_my-feature)