Skip to content

Commit f41b34e

Browse files
authored
Create npm-publish.yml
1 parent cf5816b commit f41b34e

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
6+
name: Publish
7+
8+
on:
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
16+
name: Build and publish to npm
17+
steps:
18+
- name: Check actor permission level
19+
uses: skjnldsv/check-actor-permission@v2
20+
with:
21+
require: admin
22+
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
26+
- name: Read package.json node and npm engines version
27+
uses: skjnldsv/[email protected]
28+
id: versions
29+
with:
30+
fallbackNode: '^12'
31+
fallbackNpm: '^6'
32+
33+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
34+
uses: actions/setup-node@v2
35+
with:
36+
node-version: ${{ steps.versions.outputs.nodeVersion }}
37+
38+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
39+
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
40+
41+
- name: Install dependencies & build
42+
run: |
43+
npm ci
44+
npm run build --if-present
45+
46+
- name: Publish
47+
run: |
48+
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
49+
npm publish
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)