2020-11-02 17:13:24 +01:00
|
|
|
# This workflow will run tests using node and then publish a package to the npm registry when a release is created
|
|
|
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
|
|
|
|
|
|
name: Node.js Package
|
|
|
|
|
|
|
|
on:
|
2020-11-23 17:34:26 +01:00
|
|
|
pull_request:
|
2020-11-02 17:13:24 +01:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
2020-11-23 17:34:26 +01:00
|
|
|
test:
|
2020-11-02 17:13:24 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-11-23 19:37:44 +01:00
|
|
|
# Clone ether/etherpad-lite to ../etherpad-lite so that ep_etherpad-lite
|
|
|
|
# can be "installed" in this plugin's node_modules. The checkout v2 action
|
|
|
|
# doesn't support cloning outside of $GITHUB_WORKSPACE (see
|
|
|
|
# https://github.com/actions/checkout/issues/197), so the repo is first
|
|
|
|
# cloned to etherpad-lite then moved to ../etherpad-lite. To avoid
|
|
|
|
# conflicts with this plugin's clone, etherpad-lite must be cloned and
|
|
|
|
# moved out before this plugin's repo is cloned to $GITHUB_WORKSPACE.
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
2022-03-01 23:17:16 +01:00
|
|
|
uses: actions/checkout@v3
|
2020-11-23 17:34:26 +01:00
|
|
|
with:
|
|
|
|
repository: ether/etherpad-lite
|
|
|
|
path: etherpad-lite
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
|
|
|
run: mv etherpad-lite ..
|
2020-11-23 19:37:44 +01:00
|
|
|
# etherpad-lite has been moved outside of $GITHUB_WORKSPACE, so it is now
|
|
|
|
# safe to clone this plugin's repo to $GITHUB_WORKSPACE.
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
2022-03-01 23:17:16 +01:00
|
|
|
uses: actions/checkout@v3
|
2024-03-13 19:11:19 +01:00
|
|
|
- uses: pnpm/action-setup@v3
|
|
|
|
name: Install pnpm
|
|
|
|
with:
|
|
|
|
version: 8
|
|
|
|
run_install: false
|
|
|
|
- name: Get pnpm store directory
|
|
|
|
shell: bash
|
2022-01-27 23:47:28 +01:00
|
|
|
run: |
|
2024-03-13 19:11:19 +01:00
|
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
|
|
- uses: actions/cache@v4
|
|
|
|
name: Setup pnpm cache
|
2020-11-02 17:13:24 +01:00
|
|
|
with:
|
2024-03-13 19:11:19 +01:00
|
|
|
path: ${{ env.STORE_PATH }}
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-store-
|
2020-11-23 19:37:44 +01:00
|
|
|
# All of ep_etherpad-lite's devDependencies are installed because the
|
|
|
|
# plugin might do `require('ep_etherpad-lite/node_modules/${devDep}')`.
|
|
|
|
# Eventually it would be nice to create an ESLint plugin that prohibits
|
|
|
|
# Etherpad plugins from piggybacking off of ep_etherpad-lite's
|
|
|
|
# devDependencies. If we had that, we could change this line to only
|
|
|
|
# install production dependencies.
|
2024-03-13 19:11:19 +01:00
|
|
|
- run: pnpm i && pnpm link --global
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
2024-03-13 19:11:19 +01:00
|
|
|
run: cd ../etherpad-lite/src && pnpm i && pnpm link $PLUGIN_NAME
|
|
|
|
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
2024-03-13 19:11:19 +01:00
|
|
|
run: pnpm run test
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
|
|
|
run: npm run lint
|
2020-11-02 17:13:24 +01:00
|
|
|
|
|
|
|
publish-npm:
|
2020-11-23 17:34:26 +01:00
|
|
|
if: github.event_name == 'push'
|
|
|
|
needs: test
|
2020-11-02 17:13:24 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
2022-03-01 23:17:16 +01:00
|
|
|
uses: actions/checkout@v3
|
2024-03-13 19:11:19 +01:00
|
|
|
- uses: pnpm/action-setup@v3
|
|
|
|
name: Install pnpm
|
2021-06-14 20:46:04 +02:00
|
|
|
with:
|
2024-03-13 19:11:19 +01:00
|
|
|
version: 8
|
|
|
|
run_install: false
|
|
|
|
- name: Get pnpm store directory
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
|
|
- uses: actions/cache@v4
|
|
|
|
name: Setup pnpm cache
|
|
|
|
with:
|
|
|
|
path: ${{ env.STORE_PATH }}
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-store-
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
2024-03-13 19:11:19 +01:00
|
|
|
uses: actions/checkout@v3
|
2020-11-02 17:13:24 +01:00
|
|
|
with:
|
2024-03-13 19:11:19 +01:00
|
|
|
fetch-depth: 0
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
|
|
|
name: Bump version (patch)
|
2021-06-14 20:46:04 +02:00
|
|
|
run: |
|
|
|
|
LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1
|
|
|
|
NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1
|
|
|
|
[ "${NEW_COMMITS}" -gt 0 ] || exit 0
|
|
|
|
git config user.name 'github-actions[bot]'
|
|
|
|
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
2024-03-13 19:11:19 +01:00
|
|
|
pnpm i
|
|
|
|
pnpm version patch
|
2021-06-14 20:46:04 +02:00
|
|
|
git push --follow-tags
|
2022-02-25 02:56:49 +01:00
|
|
|
# This is required if the package has a prepare script that uses something
|
|
|
|
# in dependencies or devDependencies.
|
|
|
|
-
|
2024-03-13 19:11:19 +01:00
|
|
|
run: pnpm i
|
2021-01-05 22:11:29 +01:00
|
|
|
# `npm publish` must come after `git push` otherwise there is a race
|
|
|
|
# condition: If two PRs are merged back-to-back then master/main will be
|
|
|
|
# updated with the commits from the second PR before the first PR's
|
|
|
|
# workflow has a chance to push the commit generated by `npm version
|
|
|
|
# patch`. This causes the first PR's `git push` step to fail after the
|
|
|
|
# package has already been published, which in turn will cause all future
|
|
|
|
# workflow runs to fail because they will all attempt to use the same
|
|
|
|
# already-used version number. By running `npm publish` after `git push`,
|
|
|
|
# back-to-back merges will cause the first merge's workflow to fail but
|
|
|
|
# the second's will succeed.
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
|
|
|
run: npm publish
|
2020-11-02 17:13:24 +01:00
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
|
|
|
name: Add package to etherpad organization
|
2022-01-21 02:27:48 +01:00
|
|
|
run: npm access grant read-write etherpad:developers
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|