File: ghp-publish.sh

package info (click to toggle)
dygraphs 2.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,340 kB
  • sloc: javascript: 24,842; sh: 800; python: 581; makefile: 45
file content (35 lines) | stat: -rw-r--r-- 902 bytes parent folder | download
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
#!/bin/mksh
set -exo pipefail
case $KSH_VERSION {
(*MIRBSD\ KSH*) ;;
(*) echo E: do not call me with bash or something; exit 255 ;;
}

cd "$(dirname "$0")/.."

gitstatus=$(git status --porcelain)
if [[ -n $gitstatus ]]; then
	: repo unclean
	false
fi

curbranch=$(git branch --show-current)
[[ -n $curbranch ]]
curremote=$(git config --get "branch.$curbranch.remote")
[[ -n $curremote ]]
curremurl=$(git config --get "remote.$curremote.url")
[[ $curremurl = git@github.com:+([!\\\"])/+([!\\\"]).git ]]
shortrem=${curremurl%.git}
shortrem=${shortrem#git@github.com:}

curpkg=$(<package.json)
print -r -- "${curpkg%\}}" \
    ", \"repository\": { \"type\": \"git\", \"url\": \"https://github.com/$shortrem.git\" }" \
    ", \"name\": \"@$shortrem\"" \
    "}" | jq . >package.json

set +e
npm_config_registry=https://npm.pkg.github.com npm publish "$@"
rv=$?
git checkout package.json || rv=255
exit $rv