-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (47 loc) · 1.61 KB
/
publish.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
name: Publish package to NPM
on:
workflow_dispatch:
inputs:
version:
description: 'Enter the new version for the package'
required: true
jobs:
publish:
runs-on: ubuntu-latest
permissions: # Job-level permissions configuration starts here
contents: write # 'write' access to repository contents
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install dependencies
run: npm install
- name: Update version in package.json
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${{ github.event.inputs.version }}\"/" package.json
- name: Commit and push changes
run: |
git config --global user.email ${{secrets.ADMIN_EMAIL}}
git config --global user.name ${{secrets.ORG_NAME}}
git add package.json
if git diff --exit-code; then
echo "No changes to commit."
else
git add .
git commit -am "Bump version to ${{ github.event.inputs.version }}"
git pull origin main
git push https://${{secrets.WORKFLOW_TOKEN}}@github.com/ingrammicro-xvantage/xi-sdk-resellers-node.git main
fi
- name: Build SDK
run: |
npm ci
- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN}}