Daniel Zlotin 8 anni fa
parent
commit
f1e4cf492e
4 ha cambiato i file con 106 aggiunte e 18 eliminazioni
  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 Vedi File

6
 env:
6
 env:
7
   global:
7
   global:
8
     - NODE_VERSION=stable
8
     - NODE_VERSION=stable
9
+    - PATH=$PATH:$HOME/.yarn/bin
9
     - ANDROID_HOME=$HOME/android-sdk-linux
10
     - ANDROID_HOME=$HOME/android-sdk-linux
10
     - PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
11
     - PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
11
 
12
 
18
   - v2
19
   - v2
19
 
20
 
20
 cache:
21
 cache:
22
+  yarn: true
21
   directories:
23
   directories:
22
-    - $HOME/.yarn-cache
23
     - $HOME/.gradle/
24
     - $HOME/.gradle/
24
     - $HOME/.m2
25
     - $HOME/.m2
25
     - $ANDROID_HOME/licenses/
26
     - $ANDROID_HOME/licenses/
30
 
31
 
31
 before_install:
32
 before_install:
32
   - set -e
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
 install:
37
 install:
36
-  - nvm install $NODE_VERSION
37
-  - npm i -g yarn
38
-  - yarn
38
+  - ./scripts/clean.sh
39
+  - yarn install
39
 
40
 
40
 script:
41
 script:
41
   - yarn run lint
42
   - yarn run lint
42
   - yarn run test:js
43
   - yarn run test:js
43
   - ./scripts/installAndroidSDK.sh
44
   - ./scripts/installAndroidSDK.sh
44
   - yarn run test:android
45
   - yarn run test:android
46
+  - yarn run release
45
 
47
 
46
 after_script:
48
 after_script:
47
   - echo "BUILD FINISHED"
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 Vedi File

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

+ 71
- 0
scripts/release.js Vedi File

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 Vedi File

438
     babel-runtime "^6.0.0"
438
     babel-runtime "^6.0.0"
439
 
439
 
440
 babel-plugin-istanbul@^3.0.0:
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
   dependencies:
443
   dependencies:
444
     find-up "^1.1.2"
444
     find-up "^1.1.2"
445
-    istanbul-lib-instrument "^1.1.4"
445
+    istanbul-lib-instrument "^1.4.2"
446
     object-assign "^4.1.0"
446
     object-assign "^4.1.0"
447
-    test-exclude "^3.2.2"
447
+    test-exclude "^3.3.0"
448
 
448
 
449
 babel-plugin-jest-hoist@^18.0.0:
449
 babel-plugin-jest-hoist@^18.0.0:
450
   version "18.0.0"
450
   version "18.0.0"
3021
   dependencies:
3021
   dependencies:
3022
     append-transform "^0.3.0"
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
   dependencies:
3027
   dependencies:
3028
     babel-generator "^6.18.0"
3028
     babel-generator "^6.18.0"
3029
     babel-template "^6.16.0"
3029
     babel-template "^6.16.0"
3193
   version "18.0.0"
3193
   version "18.0.0"
3194
   resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-18.0.0.tgz#5c248846ea33fa558b526f5312ab4a6765e489b3"
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
 jest-resolve-dependencies@^18.1.0:
3200
 jest-resolve-dependencies@^18.1.0:
3197
   version "18.1.0"
3201
   version "18.1.0"
3198
   resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-18.1.0.tgz#8134fb5caf59c9ed842fe0152ab01c52711f1bbb"
3202
   resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-18.1.0.tgz#8134fb5caf59c9ed842fe0152ab01c52711f1bbb"
3430
     pinkie-promise "^2.0.0"
3434
     pinkie-promise "^2.0.0"
3431
     strip-bom "^2.0.0"
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
 lodash._arraycopy@^3.0.0:
3441
 lodash._arraycopy@^3.0.0:
3434
   version "3.0.0"
3442
   version "3.0.0"
3435
   resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1"
3443
   resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1"
4698
   dependencies:
4706
   dependencies:
4699
     commander "~2.8.1"
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
   version "5.3.0"
4710
   version "5.3.0"
4703
   resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
4711
   resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
4704
 
4712
 
5092
     os-tmpdir "^1.0.0"
5100
     os-tmpdir "^1.0.0"
5093
     rimraf "~2.2.6"
5101
     rimraf "~2.2.6"
5094
 
5102
 
5095
-test-exclude@^3.2.2:
5103
+test-exclude@^3.3.0:
5096
   version "3.3.0"
5104
   version "3.3.0"
5097
   resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-3.3.0.tgz#7a17ca1239988c98367b0621456dbb7d4bc38977"
5105
   resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-3.3.0.tgz#7a17ca1239988c98367b0621456dbb7d4bc38977"
5098
   dependencies:
5106
   dependencies:
5471
   resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-1.1.1.tgz#ac3c9d39f320c6dce5339969d054ef43dd333319"
5479
   resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-1.1.1.tgz#ac3c9d39f320c6dce5339969d054ef43dd333319"
5472
 
5480
 
5473
 whatwg-url@^4.1.0:
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
   dependencies:
5484
   dependencies:
5477
     tr46 "~0.0.3"
5485
     tr46 "~0.0.3"
5478
     webidl-conversions "^3.0.0"
5486
     webidl-conversions "^3.0.0"
5601
   resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.0.0.tgz#306c543835f09ee1a4cb23b7bce9ab341c91cdd4"
5609
   resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.0.0.tgz#306c543835f09ee1a4cb23b7bce9ab341c91cdd4"
5602
 
5610
 
5603
 yargs-parser@^4.2.0:
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
   dependencies:
5614
   dependencies:
5607
     camelcase "^3.0.0"
5615
     camelcase "^3.0.0"
5608
 
5616