Skip to content

Commit

Permalink
Publish crna-kitchen-sink app to expo
Browse files Browse the repository at this point in the history
Publish the app to `https://exp.host/@storybook/crna-kitchen-sink?release-channel=branch-name`.

This enables contributors/ code reviewers without much RN experience to easily preview the app from their phone.

A side effect of publishing is it confirms the app at the very least bundles correctly.
  • Loading branch information
benoitdion committed Mar 20, 2019
1 parent 3e9303a commit ee38974
Show file tree
Hide file tree
Showing 6 changed files with 1,556 additions and 105 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ jobs:
command: |
cd examples-native/crna-kitchen-sink
yarn storybook --smoke-test
- run:
name: Publish React-Native-App example
command: |
./scripts/crna-publish.js
frontpage:
<<: *defaults
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ integration/__image_snapshots__/__diff_output__
/examples/cra-kitchen-sink/src/__image_snapshots__/__diff_output__/
lib/*.jar
lib/**/dll
.expo/packager-info.json
1 change: 1 addition & 0 deletions examples-native/crna-kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"babel-preset-expo": "^5.0.0",
"core-js": "^2.5.7",
"jest-expo": "^32.0.0",
"expo-cli": "^2.11.9",
"react-test-renderer": "16.5.1",
"schedule": "^0.4.0"
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"lint:md": "remark -q",
"lint:package": "sort-package-json",
"lint:ts": "tslint -p . -c tslint.json -t stylish",
"publish:crna": "yarn --cwd examples-native/crna-kitchen-sink expo publish",
"publish:debug": "npm run publish:latest -- --npm-tag=debug --no-push",
"publish:latest": "lerna publish --exact --concurrency 1 --force-publish",
"publish:next": "npm run publish:latest -- --npm-tag=next",
Expand Down
49 changes: 49 additions & 0 deletions scripts/crna-publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env node
const childProcess = require('child_process');
const log = require('npmlog');

const getCurrentBranch = () =>
childProcess
.execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim();

const sanitizeBranchName = branch => branch.replace(/[^a-zA-Z0-9-_]/g, '-');

const expoLogin = (username, password) => {
log.info('Logging in to expo');
childProcess.execSync(`yarn expo login -u '${username}' -p '${password}'`);
};

const expoLogout = () => {
log.verbose('Logging out from expo');
childProcess.execSync('yarn expo logout');
};

const expoPublish = channel => {
log.info(`Publishing to channel ${channel}`);
childProcess.execSync(`yarn publish:crna --release-channel=${channel}`);
log.info(
`crna-kitchen-sink app available at https://exp.host/@storybook/crna-kitchen-sink?release-channel=${channel}`
);
};

const username = process.env.EXPO_USERNAME;
const password = process.env.EXPO_PASSWORD;

if (!username) {
log.error('EXPO_USERNAME environment variable not set');
// 0 exit code because builds from forks will not have this variable set
process.exit(0);
}

if (!password) {
log.error('EXPO_PASSWORD environment variable not set');
// 0 exit code because builds from forks will not have this variable set
process.exit(0);
}

expoLogout();
expoLogin(username, password);
expoPublish(sanitizeBranchName(getCurrentBranch()));
expoLogout();
Loading

0 comments on commit ee38974

Please sign in to comment.