You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.7 KiB

4 years ago
  1. # This workflow will run tests using node and then publish a package to the npm registry when a release is created
  2. # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
  3. name: Node.js Package
  4. on:
  5. pull_request:
  6. push:
  7. branches:
  8. - main
  9. - master
  10. jobs:
  11. test:
  12. runs-on: ubuntu-latest
  13. steps:
  14. # Clone ether/etherpad-lite to ../etherpad-lite so that ep_etherpad-lite
  15. # can be "installed" in this plugin's node_modules. The checkout v2 action
  16. # doesn't support cloning outside of $GITHUB_WORKSPACE (see
  17. # https://github.com/actions/checkout/issues/197), so the repo is first
  18. # cloned to etherpad-lite then moved to ../etherpad-lite. To avoid
  19. # conflicts with this plugin's clone, etherpad-lite must be cloned and
  20. # moved out before this plugin's repo is cloned to $GITHUB_WORKSPACE.
  21. - uses: actions/checkout@v2
  22. with:
  23. repository: ether/etherpad-lite
  24. path: etherpad-lite
  25. - run: mv etherpad-lite ..
  26. # etherpad-lite has been moved outside of $GITHUB_WORKSPACE, so it is now
  27. # safe to clone this plugin's repo to $GITHUB_WORKSPACE.
  28. - uses: actions/checkout@v2
  29. - uses: actions/setup-node@v1
  30. with:
  31. node-version: 12
  32. # All of ep_etherpad-lite's devDependencies are installed because the
  33. # plugin might do `require('ep_etherpad-lite/node_modules/${devDep}')`.
  34. # Eventually it would be nice to create an ESLint plugin that prohibits
  35. # Etherpad plugins from piggybacking off of ep_etherpad-lite's
  36. # devDependencies. If we had that, we could change this line to only
  37. # install production dependencies.
  38. - run: cd ../etherpad-lite/src && npm ci
  39. - run: npm ci
  40. # This runs some sanity checks and creates a symlink at
  41. # node_modules/ep_etherpad-lite that points to ../../etherpad-lite/src.
  42. # This step must be done after `npm ci` installs the plugin's dependencies
  43. # because npm "helpfully" cleans up such symlinks. :( Installing
  44. # ep_etherpad-lite in the plugin's node_modules prevents lint errors and
  45. # unit test failures if the plugin does `require('ep_etherpad-lite/foo')`.
  46. - run: npm install --no-save ep_etherpad-lite@file:../etherpad-lite/src
  47. - run: npm test
  48. - run: npm run lint
  49. publish-npm:
  50. if: github.event_name == 'push'
  51. needs: test
  52. runs-on: ubuntu-latest
  53. steps:
  54. - uses: actions/checkout@v2
  55. - uses: actions/setup-node@v1
  56. with:
  57. node-version: 12
  58. registry-url: https://registry.npmjs.org/
  59. - run: git config user.name 'github-actions[bot]'
  60. - run: git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
  61. - run: npm ci
  62. - run: npm version patch
  63. - run: git push --follow-tags
  64. # `npm publish` must come after `git push` otherwise there is a race
  65. # condition: If two PRs are merged back-to-back then master/main will be
  66. # updated with the commits from the second PR before the first PR's
  67. # workflow has a chance to push the commit generated by `npm version
  68. # patch`. This causes the first PR's `git push` step to fail after the
  69. # package has already been published, which in turn will cause all future
  70. # workflow runs to fail because they will all attempt to use the same
  71. # already-used version number. By running `npm publish` after `git push`,
  72. # back-to-back merges will cause the first merge's workflow to fail but
  73. # the second's will succeed.
  74. - run: npm publish
  75. env:
  76. NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
  77. ##ETHERPAD_NPM_V=2
  78. ## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh