-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (60 loc) · 1.65 KB
/
release-module-npm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: NPM Release Module
on:
workflow_call:
inputs:
env_vars:
required: false
type: string
default: '{}'
registry_url:
required: false
type: string
default: 'https://registry.npmjs.org'
registry_scope:
required: false
type: string
default: '@digicatapult'
npm_build:
required: false
type: boolean
default: false
package_access:
required: false
type: string
default: 'public'
secrets:
REGISTRY_AUTH_TOKEN:
required: true
permissions:
contents: write
jobs:
publish-npm:
name: 'Publish package to NPMJS'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set environment variables from JSON
env:
ENV_VARS_JSON: "${{ inputs.env_vars }}"
run: |
echo "Parsing JSON environment variables..."
echo "$ENV_VARS_JSON" | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' >> $GITHUB_ENV
- name: Check version
id: get_version
uses: digicatapult/check-version@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: ${{ inputs.registry_url }}
scope: ${{ inputs.registry_scope }}
- name: Install Packages
run: npm ci
- name: Build
run: npm run build
if: inputs.npm_build == true
- name: Publish to npmjs packages
run: npm publish --access ${{ inputs.package_access }}
env:
NODE_AUTH_TOKEN: ${{ secrets.REGISTRY_AUTH_TOKEN }}