generated from meshery/meshery
-
Notifications
You must be signed in to change notification settings - Fork 30
81 lines (72 loc) · 2.71 KB
/
publish-npm-package.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Publish NPM Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
release_version:
description: "Release Version"
required: true
default: "prerelease"
type: choice
options:
- "prerelease"
- "patch"
- "minor"
- "major"
release_variant:
description: "Type of release"
required: true
default: "stable"
type: choice
options:
- "stable"
- "alpha"
- "beta"
jobs:
publish-gpr:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@master
with:
ref: "master"
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
scope: "@layer5"
- name: Install Dependencies
run: npm ci
- name: Update Release Version
env:
RELEASE_VERSION: ${{ inputs.release_version }}
RELEASE_VARIANT: ${{ inputs.release_variant }}
run: |
OLD_VERSION=$(node -e "console.log(require('./package.json').version)")
if [ $RELEASE_VERSION == "prerelease" ] && [ $RELEASE_VARIANT != "stable" ]; then npm version ${RELEASE_VERSION} --preid ${RELEASE_VARIANT}; fi
if [ $RELEASE_VERSION == "prerelease" ] && [ $RELEASE_VARIANT == "stable" ]; then npm version ${RELEASE_VERSION}; fi
if [ $RELEASE_VERSION != "prerelease" ] && [ $RELEASE_VARIANT != "stable" ]; then npm version pre${RELEASE_VERSION} --preid ${RELEASE_VARIANT}; fi
if [ $RELEASE_VERSION != "prerelease" ] && [ $RELEASE_VARIANT == "stable" ]; then npm version ${RELEASE_VERSION}; fi
git add './'
NEW_VERSION=$(node -e "console.log(require('./package.json').version)")
echo "Updated Package Version" >> $GITHUB_STEP_SUMMARY
echo "info Old Version: ${OLD_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "info New Version: ${NEW_VERSION}" >> $GITHUB_STEP_SUMMARY
- name: Build Package
run: |
npm run build
echo "Build New Package" >> $GITHUB_STEP_SUMMARY
- name: Publish Package
run: npm publish --verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Commit and push version change
run: |
git status
git pull --rebase -f
git push --verbose
echo "Pushed Package changes" >> $GITHUB_STEP_SUMMARY