1
1
mirror of https://github.com/primer/css.git synced 2024-11-23 20:38:58 +03:00
css/script/publish
2019-02-04 15:19:23 -08:00

42 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
set -e
if [[ -z $GITHUB_REF ]]; then
echo "[publish] GITHUB_REF is not set; bailing"
exit
fi
name=$(cat package.json | fx .name)
branch="${GITHUB_REF/refs\/heads\//}"
sha="${GITHUB_SHA:0:7}"
echo "[publish] $name (branch: '$branch', sha: '$sha')"
flags="--dry-run"
if [[ $branch = "master" ]]; then
version=$(cat package.json | fx .version)
if [[ $(npm view "$name@$version") = $version ]]; then
echo "[publish] $name@$version is already published; bailing"
exit
else
echo "[publish] here we go!"
fi
elif [[ $branch =~ ^release- ]]; then
npm version "${branch/release-/}-pre.$sha"
flags="$flags --tag next"
else
npm version "0.0.0-alpha.$sha"
flags="$flags --tag canary"
fi
context="npm publish primer"
export GH_STATUS_TOKEN=$GITHUB_TOKEN
npx commit-status $context pending "publishing $version..."
script/prepublish
npm publish $flags
script/postpublish
npx commit-status $context success "published $version" "https://unpkg.com/$name@$version/"