CI.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. name: CI
  2. on:
  3. push:
  4. branches: [master, develop]
  5. tags-ignore:
  6. - '**'
  7. pull_request:
  8. jobs:
  9. build:
  10. if: "!contains(github.event.head_commit.message, 'skip ci')"
  11. strategy:
  12. fail-fast: false
  13. matrix:
  14. os: [ubuntu-latest, macos-latest, windows-latest]
  15. name: stable - ${{ matrix.os }} - node@12
  16. runs-on: ${{ matrix.os }}
  17. steps:
  18. - uses: actions/checkout@v2
  19. - name: Setup node
  20. uses: actions/setup-node@v1
  21. with:
  22. node-version: 12
  23. - name: Set platform name
  24. run: |
  25. export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
  26. echo "::set-env name=PLATFORM_NAME::$NODE_PLATFORM_NAME"
  27. shell: bash
  28. - name: Install llvm
  29. if: matrix.os == 'windows-latest'
  30. run: choco install -y llvm
  31. - name: Set llvm path
  32. if: matrix.os == 'windows-latest'
  33. uses: allenevans/set-env@v1.0.0
  34. with:
  35. LIBCLANG_PATH: 'C:\\Program Files\\LLVM\\bin'
  36. - name: Install
  37. uses: actions-rs/toolchain@v1
  38. with:
  39. toolchain: stable
  40. profile: minimal
  41. override: true
  42. - name: Generate Cargo.lock
  43. uses: actions-rs/cargo@v1
  44. with:
  45. command: generate-lockfile
  46. - name: Cache cargo registry
  47. uses: actions/cache@v1
  48. with:
  49. path: ~/.cargo/registry
  50. key: stable-${{ matrix.os }}-node@12-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
  51. - name: Cache cargo index
  52. uses: actions/cache@v1
  53. with:
  54. path: ~/.cargo/git
  55. key: stable-${{ matrix.os }}gnu-node@12-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
  56. - name: Cache NPM dependencies
  57. uses: actions/cache@v1
  58. with:
  59. path: node_modules
  60. key: npm-cache-${{ matrix.os }}-node@12-${{ hashFiles('yarn.lock') }}
  61. restore-keys: |
  62. npm-cache-
  63. - name: 'Install dependencies'
  64. run: yarn install --frozen-lockfile --registry https://registry.npmjs.org
  65. - name: 'Build'
  66. run: yarn build
  67. - name: Upload artifact
  68. uses: actions/upload-artifact@v2
  69. with:
  70. name: bindings-${{ env.PLATFORM_NAME }}
  71. path: index.${{ env.PLATFORM_NAME }}.node
  72. - name: Clear the cargo caches
  73. run: |
  74. cargo install cargo-cache --no-default-features --features ci-autoclean
  75. cargo-cache
  76. test_binding:
  77. name: Test bindings on ${{ matrix.os }} - node@${{ matrix.node }}
  78. needs:
  79. - build
  80. strategy:
  81. fail-fast: false
  82. matrix:
  83. os: [ubuntu-latest, macos-latest, windows-latest]
  84. node: ['10', '12', '14']
  85. runs-on: ${{ matrix.os }}
  86. steps:
  87. - uses: actions/checkout@v2
  88. - name: Setup node
  89. uses: actions/setup-node@v1
  90. with:
  91. node-version: ${{ matrix.node }}
  92. - name: Set platform name
  93. run: |
  94. export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
  95. echo "::set-env name=PLATFORM_NAME::$NODE_PLATFORM_NAME"
  96. shell: bash
  97. # Do not cache node_modules, or yarn workspace links broken
  98. - name: 'Install dependencies'
  99. run: yarn install --frozen-lockfile --registry https://registry.npmjs.org
  100. - name: Download artifacts
  101. uses: actions/download-artifact@v2
  102. with:
  103. name: bindings-${{ env.PLATFORM_NAME }}
  104. path: .
  105. - name: List packages
  106. run: ls -R .
  107. shell: bash
  108. - name: Test bindings
  109. run: yarn test
  110. dependabot:
  111. needs:
  112. - test_binding
  113. runs-on: ubuntu-latest
  114. steps:
  115. - name: auto-merge
  116. uses: ridedott/dependabot-auto-merge-action@master
  117. with:
  118. GITHUB_LOGIN: dependabot[bot]
  119. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  120. publish:
  121. name: Publish
  122. runs-on: ubuntu-latest
  123. needs: test_binding
  124. steps:
  125. - uses: actions/checkout@v2
  126. - name: Setup node
  127. uses: actions/setup-node@v1
  128. with:
  129. node-version: 12
  130. - name: Cache NPM dependencies
  131. uses: actions/cache@v1
  132. with:
  133. path: node_modules
  134. key: npm-cache-ubuntu-latest-${{ hashFiles('yarn.lock') }}
  135. restore-keys: |
  136. npm-cache-
  137. - name: 'Install dependencies'
  138. run: yarn install --frozen-lockfile --registry https://registry.npmjs.org
  139. - name: Download all artifacts
  140. uses: actions/download-artifact@v2
  141. with:
  142. path: .
  143. - name: List packages
  144. run: ls -R .
  145. shell: bash
  146. - name: Publish
  147. run: |
  148. if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
  149. then
  150. node ./scripts/upload-to-release.js
  151. echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
  152. npm publish
  153. else
  154. echo "Not a release, skipping publish"
  155. fi
  156. env:
  157. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  158. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}