Exp publish and CI

#1

I’m in the process of setting up CI for test and stage builds and would like to use exp publish to push the builds out from the CI server. However, it seems that the packager needs to be running in order to do a publish. I’m not looking to publish to the app store with these builds.

What am I overlooking? I don’t want to be running the packager on the CI server to publish test builds?

#2

exp publish will start a packager server automatically when you run it if one isn’t already running, and when the command finishes, it will stop the packager.

#3

that makes sense, something else is going wrong then. I get the following error when attempting to run exp publish. It works fine from the Expo XDE or if I started the packager previously.

exp publish
[exp] Making sure project is set up correctly...
[exp] Your project looks good!
[exp] Publishing...
[exp] No packager found for project at /Users/byron/Projects/[project].

I think what’s happening is that Expo XDE doesn’t stop the packager properly (this also happens when running exp start sometimes. I’ve seen this a few times where trying to start exp start from the command line after using Expo XDE gives the following error:

exp start
[exp] Making sure project is set up correctly...
[exp] Your project looks good!
[exp] exp is already running for this project. Exiting...
#4

Hmm.

Double check to make sure you’re not committing your local “.expo” directory (which we use to store current packager state).

#5

should be good there:

$ cat .gitignore
node_modules/**/*
.expo/*
npm-debug.*
#6

What version of exp are you using?

#7
"dependencies": {
    "expo": "^19.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "https://github.com/expo/react-native/archive/sdk-19.0.0.tar.gz"
  },

$ exp --version 43.0.0

#8

Sorry, I wasn’t clear earlier that you were running this locally.

Please delete your .expo directory in your project folder, ensure that no packagers are running, and then run exp publish and a packager should start automatically.

In CI, I would recommend making sure you delete .expo (may not be necessary depending on how you’re doing caching between builds in your CI provider)

#9

This might be helpful for some people.
I used circleci to do this. Here are my commands

nvm install 7
nvm alias default 7
npm install -g exp
npm install
npm test
exp login -u $EXP_USERNAME -p $EXP_PASSWORD
exp publish --non-interactive

Although sometimes build fail while running exp publish --non-interactive show error socket hang up

1 Like
Gitlab CI hangs on publish
#10

I figured my issues out. Basically I had a docker containing that was running on port 80 which was causing the packager to report that one is already running.

#11

But why does Expo rely on port 80 at all? I’m on a desktop that must keep a server running on port 80 at all times.

#12

I am getting

/bin/bash: exp: command not found
Exited with code 127

Here is my config.yml:

Do I need to maybe use a different docker?

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:8.9.4
    working_directory: ~/repo
    steps:
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          - v1-dependencies-
      - run: 
          name: Installing yarn
          command: yarn install
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}`Preformatted text`
      - run:
          name: Running Jest Tests
          command: yarn run test

  deploy:
    docker:
      - image: circleci/node:8.9.4
    working_directory: ~/repo
    steps:
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          - v1-dependencies-
      - run:
          name: Installing yarn
          command: yarn install
      - run:
          name: Installing exp
          command: yarn add exp
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
      - run: exp login --username EXPO_USER_NAME --password EXPO_PASSWORD
      - run: 
          name: Deploying to Expo
          command: exp build:android

workflows:
  version: 2
  build-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
1 Like
#13

You probably need to reference the executable in /node_modules/bin/exp

#14

I changed the exp install to be a global:

      - run:
          name: Installing exp
          command: yarn global add exp

…then changed the publish command to the following:

      - run:
          name: Deploying to Expo
          command: |
            export PATH="$PATH:$( yarn global bin )"
            exp login --username $EXPO_USER_NAME --password $EXPO_PASSWORD
            exp publish
2 Likes
#15

How did you fix this?