-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
44 lines (37 loc) · 988 Bytes
/
publish.sh
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
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 -t <githubToken> -p <packageName> [-o <orgName>]"
exit 1
}
# Default value for orgName
orgName="hk-artificial-intelligence-association"
# Parse command-line arguments
while getopts ":t:p:o:" opt; do
case ${opt} in
t)
githubToken=${OPTARG}
;;
p)
packageName=${OPTARG}
;;
o)
orgName=${OPTARG}
;;
\?)
usage
;;
esac
done
# Check if githubToken is provided
if [ -z "$githubToken" ]; then
echo "Please provide a GitHub token using the -t parameter."
usage
fi
# Set environment variable for GitHub token
export GITHUB_TOKEN=$githubToken
# Write .npmrc file with variable interpolation
npmrcContent="@$orgName:registry=https://npm.pkg.github.com/\n//npm.pkg.github.com/:_authToken=$githubToken"
echo -e $npmrcContent > .npmrc
# Publish the package
npm publish