Daniel Zlotin před 8 roky
rodič
revize
f1e4cf492e
4 změnil soubory, kde provedl 106 přidání a 18 odebrání
  1. 12
    5
      .travis.yml
  2. 2
    0
      scripts/.npmrc
  3. 71
    0
      scripts/release.js
  4. 21
    13
      yarn.lock

+ 12
- 5
.travis.yml Zobrazit soubor

@@ -6,6 +6,7 @@ jdk:
6 6
 env:
7 7
   global:
8 8
     - NODE_VERSION=stable
9
+    - PATH=$PATH:$HOME/.yarn/bin
9 10
     - ANDROID_HOME=$HOME/android-sdk-linux
10 11
     - PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
11 12
 
@@ -18,8 +19,8 @@ branches:
18 19
   - v2
19 20
 
20 21
 cache:
22
+  yarn: true
21 23
   directories:
22
-    - $HOME/.yarn-cache
23 24
     - $HOME/.gradle/
24 25
     - $HOME/.m2
25 26
     - $ANDROID_HOME/licenses/
@@ -30,18 +31,24 @@ before_cache:
30 31
 
31 32
 before_install:
32 33
   - set -e
33
-  - ./scripts/clean.sh
34
+  - nvm install $NODE_VERSION
35
+  - curl -o- -L https://yarnpkg.com/install.sh | bash
34 36
 
35 37
 install:
36
-  - nvm install $NODE_VERSION
37
-  - npm i -g yarn
38
-  - yarn
38
+  - ./scripts/clean.sh
39
+  - yarn install
39 40
 
40 41
 script:
41 42
   - yarn run lint
42 43
   - yarn run test:js
43 44
   - ./scripts/installAndroidSDK.sh
44 45
   - yarn run test:android
46
+  - yarn run release
45 47
 
46 48
 after_script:
47 49
   - echo "BUILD FINISHED"
50
+
51
+notifications:
52
+  email: false
53
+  slack:
54
+    secure: ISBdKzsYD4eas+wxLkNTFrXreWome0YmGATqgAS1R3BcZ+ZhUgZUgC9j52Ix9JUpNN52xCZ131Wbihu8w0RpuvNogFsl64q0tBplmpNfghT1EAO85w7ZBgHpAi1fxsxUSLlO5fCKv4kX84yksyG7mBxr9tR97gVDl3chWqEUCh1Wd+dx+R0RkJpTQ+VmME5Jmywr2F1Lv1TlxGXs4yN8wlnix/V6ebYSI1qwAWjAk8nHPIGdYxNivcwkmzenkbQuHAZpI6uxWJ+Hpx+wn69sZXarXVg3M20A8dv6DiWsd7gZUQaeX+gJa1HrAxjjEl6fiJZC9Zuq1aZmMAy0EHBIN4EuRpPgDG5CzEE9/yfHEBvXbKDF2Uk2aLN3LHY+7Q8SAL6ckGJ9eSp0fu68SFYUq4YoyV1jAx7/1teWzFORSEPx/1kDYoUSqhyIojcC0FcLVvY77Ij23cN3bR+hY4mLeuyajHjl6pm5jS+iiiJgM55+H9mP+v1XhLj/Me+giDP1bBqvfL4BshwXElZ5pjEeUMnEEbfMQkHUpQ5c9/PZVrIuNal4JUYi649wVUltoan9Zm8s4AkX2p0aY5ZMy0gel2ADeyGUk+u262Jt17k31nzcpGwAXSAYNdFHJCnga8kHn2eKYPO76qpb4JlOH1kQ33oNIur9/MYvx8CeZdJBd64=

+ 2
- 0
scripts/.npmrc Zobrazit soubor

@@ -0,0 +1,2 @@
1
+email=${NPM_EMAIL}
2
+//registry.npmjs.org/:_authToken=${NPM_TOKEN}

+ 71
- 0
scripts/release.js Zobrazit soubor

@@ -0,0 +1,71 @@
1
+const cp = require('child_process');
2
+const p = require('path');
3
+const semver = require('semver');
4
+
5
+function execSync(cmd) {
6
+  cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
7
+}
8
+
9
+function execSyncRead(cmd) {
10
+  return String(cp.execSync(cmd, {stdio: ['inherit', 'pipe', 'inherit']})).trim();
11
+}
12
+
13
+function execSyncSilently(cmd) {
14
+  cp.execSync(cmd, {stdio: ['ignore', 'ignore', 'ignore']});
15
+}
16
+
17
+function validateEnv() {
18
+  if (!process.env.CI || !process.env.TRAVIS) {
19
+    throw new Error(`releasing is only available from Travis CI`);
20
+  }
21
+
22
+  if (process.env.TRAVIS_BRANCH !== 'master') {
23
+    console.error(`not publishing on branch ${process.env.TRAVIS_BRANCH}`);
24
+    return false;
25
+  }
26
+
27
+  if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
28
+    console.error(`not publishing as triggered by pull request ${process.env.TRAVIS_PULL_REQUEST}`);
29
+    return false;
30
+  }
31
+
32
+  return true;
33
+}
34
+
35
+function setupGit() {
36
+  execSyncSilently(`git config --global push.default simple`);
37
+  execSyncSilently(`git config --global user.email "${process.env.GIT_EMAIL}"`);
38
+  execSyncSilently(`git config --global user.name "${process.env.GIT_USER}"`);
39
+  const remoteUrl = new RegExp(`https?://(\\S+)`).exec(execSyncRead(`git remote -v`))[1];
40
+  execSyncSilently(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
41
+  execSync(`git checkout master`);
42
+}
43
+
44
+function calcNewVersion() {
45
+  const nextTaggedVersion = execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
46
+  console.log(`next tagged version is: ${nextTaggedVersion}`);
47
+  return semver.inc(nextTaggedVersion, 'prerelease');
48
+}
49
+
50
+function copyNpmRc() {
51
+  const npmrcPath = p.resolve(`${__dirname}/.npmrc`);
52
+  execSync(`cp -rf ${npmrcPath} .`);
53
+}
54
+
55
+function tagAndPublish(newVersion) {
56
+  console.log(`new version is: ${newVersion}`);
57
+  execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
58
+  execSyncSilently(`git push deploy --tags`);
59
+  execSync(`npm publish --tag next`);
60
+}
61
+
62
+function run() {
63
+  if (!validateEnv()) {
64
+    return;
65
+  }
66
+  setupGit();
67
+  copyNpmRc();
68
+  tagAndPublish(calcNewVersion());
69
+}
70
+
71
+run();

+ 21
- 13
yarn.lock Zobrazit soubor

@@ -438,13 +438,13 @@ babel-plugin-external-helpers@^6.18.0:
438 438
     babel-runtime "^6.0.0"
439 439
 
440 440
 babel-plugin-istanbul@^3.0.0:
441
-  version "3.0.0"
442
-  resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-3.0.0.tgz#da7324520ae0b8a44b6a078e72e883374a9fab76"
441
+  version "3.1.2"
442
+  resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-3.1.2.tgz#11d5abde18425ec24b5d648c7e0b5d25cd354a22"
443 443
   dependencies:
444 444
     find-up "^1.1.2"
445
-    istanbul-lib-instrument "^1.1.4"
445
+    istanbul-lib-instrument "^1.4.2"
446 446
     object-assign "^4.1.0"
447
-    test-exclude "^3.2.2"
447
+    test-exclude "^3.3.0"
448 448
 
449 449
 babel-plugin-jest-hoist@^18.0.0:
450 450
   version "18.0.0"
@@ -3021,9 +3021,9 @@ istanbul-lib-hook@^1.0.0-alpha.4:
3021 3021
   dependencies:
3022 3022
     append-transform "^0.3.0"
3023 3023
 
3024
-istanbul-lib-instrument@^1.1.1, istanbul-lib-instrument@^1.1.4, istanbul-lib-instrument@^1.3.0:
3025
-  version "1.3.1"
3026
-  resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.3.1.tgz#112c25a4f2f9bc361d13d14bbff992331b974e52"
3024
+istanbul-lib-instrument@^1.1.1, istanbul-lib-instrument@^1.3.0, istanbul-lib-instrument@^1.4.2:
3025
+  version "1.4.2"
3026
+  resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.4.2.tgz#0e2fdfac93c1dabf2e31578637dc78a19089f43e"
3027 3027
   dependencies:
3028 3028
     babel-generator "^6.18.0"
3029 3029
     babel-template "^6.16.0"
@@ -3193,6 +3193,10 @@ jest-mock@^18.0.0:
3193 3193
   version "18.0.0"
3194 3194
   resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-18.0.0.tgz#5c248846ea33fa558b526f5312ab4a6765e489b3"
3195 3195
 
3196
+jest-react-native@18.x.x:
3197
+  version "18.0.0"
3198
+  resolved "https://registry.yarnpkg.com/jest-react-native/-/jest-react-native-18.0.0.tgz#77dd909f069324599f227c58c61c2e62168726ba"
3199
+
3196 3200
 jest-resolve-dependencies@^18.1.0:
3197 3201
   version "18.1.0"
3198 3202
   resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-18.1.0.tgz#8134fb5caf59c9ed842fe0152ab01c52711f1bbb"
@@ -3430,6 +3434,10 @@ load-json-file@^1.0.0:
3430 3434
     pinkie-promise "^2.0.0"
3431 3435
     strip-bom "^2.0.0"
3432 3436
 
3437
+lodash-es@^4.2.0:
3438
+  version "4.17.4"
3439
+  resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"
3440
+
3433 3441
 lodash._arraycopy@^3.0.0:
3434 3442
   version "3.0.0"
3435 3443
   resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1"
@@ -4698,7 +4706,7 @@ seek-bzip@^1.0.3:
4698 4706
   dependencies:
4699 4707
     commander "~2.8.1"
4700 4708
 
4701
-"semver@2 || 3 || 4 || 5", semver@5.x, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@~5.3.0:
4709
+"semver@2 || 3 || 4 || 5", semver@5.x, semver@5.x.x, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@~5.3.0:
4702 4710
   version "5.3.0"
4703 4711
   resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
4704 4712
 
@@ -5092,7 +5100,7 @@ temp@0.8.3:
5092 5100
     os-tmpdir "^1.0.0"
5093 5101
     rimraf "~2.2.6"
5094 5102
 
5095
-test-exclude@^3.2.2:
5103
+test-exclude@^3.3.0:
5096 5104
   version "3.3.0"
5097 5105
   resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-3.3.0.tgz#7a17ca1239988c98367b0621456dbb7d4bc38977"
5098 5106
   dependencies:
@@ -5471,8 +5479,8 @@ whatwg-fetch@>=0.10.0, whatwg-fetch@^1.0.0:
5471 5479
   resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-1.1.1.tgz#ac3c9d39f320c6dce5339969d054ef43dd333319"
5472 5480
 
5473 5481
 whatwg-url@^4.1.0:
5474
-  version "4.1.1"
5475
-  resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.1.1.tgz#567074923352de781e3500d64a86aa92a971b4a4"
5482
+  version "4.2.0"
5483
+  resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.2.0.tgz#abf1a3f5ff4bc2005b3f0c2119382631789d8e44"
5476 5484
   dependencies:
5477 5485
     tr46 "~0.0.3"
5478 5486
     webidl-conversions "^3.0.0"
@@ -5601,8 +5609,8 @@ yallist@^2.0.0:
5601 5609
   resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.0.0.tgz#306c543835f09ee1a4cb23b7bce9ab341c91cdd4"
5602 5610
 
5603 5611
 yargs-parser@^4.2.0:
5604
-  version "4.2.0"
5605
-  resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.0.tgz#6ced869cd05a3dca6a1eaee38b68aeed4b0b4101"
5612
+  version "4.2.1"
5613
+  resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.1.tgz#29cceac0dc4f03c6c87b4a9f217dd18c9f74871c"
5606 5614
   dependencies:
5607 5615
     camelcase "^3.0.0"
5608 5616