forked from Sunbird-inQuiry/player
-
Notifications
You must be signed in to change notification settings - Fork 3
64 lines (52 loc) · 1.81 KB
/
publish-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
name: 🚀 Publish NPM Package
on:
pull_request:
branches:
- '**'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code Repository
uses: actions/checkout@v4
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
scope: '@tekdi'
- name: Debug NPM Token Secret
run: |
echo "NPM_TOKEN value is: '${{ secrets.NPM_TOKEN }}'"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# - name: Authenticate to npm
# run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: 📦 Install Dependencies
run: npm install
- name: 🛠️ Build Library
run: npm run build-lib
- name: 🔍 Ensure jq is installed
run: sudo apt-get install -y jq
- name: 🔍 Check if Version Exists
id: check-version
run: |
cd dist/quml-library
PACKAGE_NAME=$(jq -r .name package.json)
PACKAGE_VERSION=$(jq -r .version package.json)
NPM_REGISTRY="https://registry.npmjs.org"
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$NPM_REGISTRY/$PACKAGE_NAME/$PACKAGE_VERSION")
echo "status=$STATUS" >> $GITHUB_ENV
- name: 🚢 Publish to NPM
if: env.status != '200'
run: |
if [[ "$(jq -r .version package.json)" == *"beta"* ]]; then
npm publish --tag=beta --provenance --access public
else
npm publish --provenance --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 📜 Log Version Exists
if: env.status == '200'
run: echo "Version already exists, skipping publish."