Skip to content

Publish package to NPM #3

Publish package to NPM

Publish package to NPM #3

Workflow file for this run

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 .
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 run build
- 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}}