Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.

Commit 2ab920d

Browse files
committed
Add npm auto publish
1 parent f80a0c9 commit 2ab920d

5 files changed

Lines changed: 1571 additions & 12 deletions

File tree

.github/workflows/npmpublish.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
4+
name: Node.js Package
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
- master
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
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
25+
with:
26+
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
33+
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
60+
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
68+
# `npm publish` must come after `git push` otherwise there is a race
69+
# condition: If two PRs are merged back-to-back then master/main will be
70+
# updated with the commits from the second PR before the first PR's
71+
# workflow has a chance to push the commit generated by `npm version
72+
# patch`. This causes the first PR's `git push` step to fail after the
73+
# package has already been published, which in turn will cause all future
74+
# workflow runs to fail because they will all attempt to use the same
75+
# already-used version number. By running `npm publish` after `git push`,
76+
# back-to-back merges will cause the first merge's workflow to fail but
77+
# the second's will succeed.
78+
- run: npm publish
79+
env:
80+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
81+
82+
##ETHERPAD_NPM_V=2
83+
## NPM configuration automatically created using src/bin/plugins/updateAllPluginsScript.sh

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
/.idea/*
88
.ep_initialized
99
node_modules
10-
package-lock.json

0 commit comments

Comments
 (0)