CI.yaml 5.2 KB

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