|
4 | 4 | name: Node.js Package |
5 | 5 |
|
6 | 6 | on: |
7 | | - pull_request: |
8 | | - push: |
9 | | - branches: |
10 | | - - main |
11 | | - - master |
| 7 | + workflow_call: |
12 | 8 |
|
13 | 9 | jobs: |
14 | | - test: |
| 10 | + publish-npm: |
15 | 11 | runs-on: ubuntu-latest |
16 | 12 | steps: |
17 | | - # Clone ether/etherpad-lite to ../etherpad-lite so that ep_etherpad-lite |
18 | | - # can be "installed" in this plugin's node_modules. The checkout v2 action |
19 | | - # doesn't support cloning outside of $GITHUB_WORKSPACE (see |
20 | | - # https://github.com/actions/checkout/issues/197), so the repo is first |
21 | | - # cloned to etherpad-lite then moved to ../etherpad-lite. To avoid |
22 | | - # conflicts with this plugin's clone, etherpad-lite must be cloned and |
23 | | - # moved out before this plugin's repo is cloned to $GITHUB_WORKSPACE. |
24 | | - - uses: actions/checkout@v2 |
| 13 | + - uses: actions/setup-node@v4 |
| 14 | + with: |
| 15 | + node-version: 20 |
| 16 | + registry-url: https://registry.npmjs.org/ |
| 17 | + - name: Check out Etherpad core |
| 18 | + uses: actions/checkout@v3 |
25 | 19 | with: |
26 | 20 | repository: ether/etherpad-lite |
27 | | - path: etherpad-lite |
28 | | - - run: mv etherpad-lite .. |
29 | | - # etherpad-lite has been moved outside of $GITHUB_WORKSPACE, so it is now |
30 | | - # safe to clone this plugin's repo to $GITHUB_WORKSPACE. |
31 | | - - uses: actions/checkout@v2 |
32 | | - - uses: actions/setup-node@v1 |
| 21 | + - uses: pnpm/action-setup@v3 |
| 22 | + name: Install pnpm |
33 | 23 | with: |
34 | | - node-version: 12 |
35 | | - # All of ep_etherpad-lite's devDependencies are installed because the |
36 | | - # plugin might do `require('ep_etherpad-lite/node_modules/${devDep}')`. |
37 | | - # Eventually it would be nice to create an ESLint plugin that prohibits |
38 | | - # Etherpad plugins from piggybacking off of ep_etherpad-lite's |
39 | | - # devDependencies. If we had that, we could change this line to only |
40 | | - # install production dependencies. |
41 | | - - run: cd ../etherpad-lite/src && npm ci |
42 | | - - run: npm ci |
43 | | - # This runs some sanity checks and creates a symlink at |
44 | | - # node_modules/ep_etherpad-lite that points to ../../etherpad-lite/src. |
45 | | - # This step must be done after `npm ci` installs the plugin's dependencies |
46 | | - # because npm "helpfully" cleans up such symlinks. :( Installing |
47 | | - # ep_etherpad-lite in the plugin's node_modules prevents lint errors and |
48 | | - # unit test failures if the plugin does `require('ep_etherpad-lite/foo')`. |
49 | | - - run: npm install --no-save ep_etherpad-lite@file:../etherpad-lite/src |
50 | | - - run: npm test |
51 | | - - run: npm run lint |
52 | | - |
53 | | - publish-npm: |
54 | | - if: github.event_name == 'push' |
55 | | - needs: test |
56 | | - runs-on: ubuntu-latest |
57 | | - steps: |
58 | | - - uses: actions/checkout@v2 |
59 | | - - uses: actions/setup-node@v1 |
| 24 | + version: 8 |
| 25 | + run_install: false |
| 26 | + - name: Get pnpm store directory |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 30 | + - uses: actions/cache@v4 |
| 31 | + name: Setup pnpm cache |
60 | 32 | with: |
61 | | - node-version: 12 |
62 | | - registry-url: https://registry.npmjs.org/ |
63 | | - - run: git config user.name 'github-actions[bot]' |
64 | | - - run: git config user.email '41898282+github-actions[bot]@users.noreply.github.com' |
65 | | - - run: npm ci |
66 | | - - run: npm version patch |
67 | | - - run: git push --follow-tags |
| 33 | + path: ${{ env.STORE_PATH }} |
| 34 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-pnpm-store- |
| 37 | + - |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + - |
| 42 | + name: Bump version (patch) |
| 43 | + run: | |
| 44 | + LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1 |
| 45 | + NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1 |
| 46 | + [ "${NEW_COMMITS}" -gt 0 ] || exit 0 |
| 47 | + git config user.name 'github-actions[bot]' |
| 48 | + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 49 | + pnpm i |
| 50 | + pnpm version patch |
| 51 | + git push --follow-tags |
| 52 | + # This is required if the package has a prepare script that uses something |
| 53 | + # in dependencies or devDependencies. |
| 54 | + - |
| 55 | + run: pnpm i |
68 | 56 | # `npm publish` must come after `git push` otherwise there is a race |
69 | 57 | # condition: If two PRs are merged back-to-back then master/main will be |
70 | 58 | # updated with the commits from the second PR before the first PR's |
|
75 | 63 | # already-used version number. By running `npm publish` after `git push`, |
76 | 64 | # back-to-back merges will cause the first merge's workflow to fail but |
77 | 65 | # the second's will succeed. |
78 | | - - run: npm publish |
| 66 | + - |
| 67 | + run: pnpm publish |
79 | 68 | env: |
80 | 69 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
81 | | - |
82 | | -##ETHERPAD_NPM_V=2 |
83 | | -## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh |
| 70 | + #- |
| 71 | + # name: Add package to etherpad organization |
| 72 | + # run: pnpm access grant read-write etherpad:developers |
| 73 | + # env: |
| 74 | + # NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
0 commit comments