Skip to content

Commit

Permalink
ci: Sync with Etherpad's src/bin/plugins/lib/npmpublish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
rhansen committed Mar 1, 2022
1 parent e3807c1 commit 05c586d
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 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:
Expand All @@ -11,31 +14,39 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
-
uses: actions/checkout@v3
-
uses: actions/setup-node@v3
with:
node-version: 12
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run lint
cache-dependency-path: |
package-lock.json
-
run: npm ci
-
run: npm test
-
run: npm run lint

publish-npm:
if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
-
uses: actions/checkout@v3
with:
# Fetch tags so that we can skip 'npm version patch' if there are no
# changes since the latest tag.
fetch-depth: 0
- uses: actions/setup-node@v3
-
uses: actions/setup-node@v3
with:
node-version: 12
registry-url: https://registry.npmjs.org/
cache: 'npm'
- name: Bump version (patch)
-
name: Bump version (patch)
run: |
LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1
NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1
Expand All @@ -45,6 +56,10 @@ jobs:
npm ci
npm version patch
git push --follow-tags
# This is required if the package has a prepare script that uses something
# in dependencies or devDependencies.
-
run: npm ci
# `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
Expand All @@ -55,10 +70,12 @@ jobs:
# 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.
- run: npm publish
-
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Add package to etherpad organization
-
name: Add package to etherpad organization
run: npm access grant read-write etherpad:developers
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

0 comments on commit 05c586d

Please sign in to comment.