1
1
mirror of https://github.com/primer/css.git synced 2024-11-13 08:04:16 +03:00

Merge pull request #257 from primer/shawnbot/publish-release

Update automated publish logic for RCs and "final" releases
This commit is contained in:
Shawn Allen 2017-07-20 16:34:41 -07:00 committed by GitHub
commit b84884ae8d
7 changed files with 117 additions and 33 deletions

View File

@ -13,6 +13,7 @@
},
"devDependencies": {
"commit-status": "^4.1.0",
"lerna": "^2.0.0"
"lerna": "^2.0.0",
"semver": "^5.3.0"
}
}

View File

@ -3,18 +3,20 @@ set -e
# --yes gets passed in by .travis.yml,
# which makes this easier to test locally
args=${@:1}
args=$@
# always publish a pr release if this is a PR build
if [[ $TRAVIS_EVENT_TYPE = pull_request ]]; then
script/release-pr ${args}
if [[ "$TRAVIS_EVENT_TYPE" = "pull_request" ]]; then
script/release-pr $args
# merges to dev build a release candidate
elif [[ $TRAVIS_BRANCH = dev ]]; then
script/release-candidate ${args}
elif [[ "$TRAVIS_BRANCH" =~ "^release-" ]]; then
script/release-candidate $args
# publish a release when we merge to master
elif [[ $TRAVIS_BRANCH = master ]]; then
script/release ${args}
elif [[ "$TRAVIS_BRANCH" = "master" ]]; then
script/release $args
else
echo "⚠️ This isn't a PR and '${TRAVIS_BRANCH}' isn't a release branch."
echo "⚠️ This isn't a PR and '$TRAVIS_BRANCH' isn't a release branch."
exit 1
fi
script/notify

22
script/notify Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
# the commit status context
context="npm publish"
# get the published version of primer-css from its package.json
package=primer-css
version=$(jq -r .version modules/$package/package.json)
published="$package@$version"
# XXX this will go away if we build pushes instead of PRs
if [[ "$TRAVIS_PULL_REQUEST_SHA" != "" ]]; then
# setting TRAVIS_COMMIT inline here is a fix for:
# <https://github.com/taskworld/commit-status/issues/5>
export TRAVIS_COMMIT=$TRAVIS_PULL_REQUEST_SHA
fi
echo "📡 Transmitting publish status for $published..."
# TODO point this at the contributing docs!
commit-status success "$context" "$published" \
"https://unpkg.com/$published/build/build.css"

View File

@ -1,4 +1,4 @@
#!/bin/bash
set -e
echo "📦 Publishing latest release!"
echo lerna publish
echo "📦 Publishing latest release..."
lerna exec -- npm publish

View File

@ -1,4 +1,67 @@
#!/bin/bash
set -e
echo "👌 Publishing release candidate..."
echo lerna publish --npm-tag=rc
PATH=$(npm bin):$PATH
package=primer-css
npm_tag=rc
log=/tmp/rc.log
function bump() {
npm version --no-git $@
}
function publish() {
npm publish --silent --tag=$npm_tag $@
}
# get the version we're publishing as a release candidate
local_version=$(jq -r .version modules/$package/package.json)
if [[ $local_version =~ "-" ]]; then
echo "❌ Found pre-release version: $package@$local_version; bailing!"
exit 1
else
echo "🏔 Local version: $package@$local_version"
fi
# get the version most recently published to the rc dist-tag
rc_version=$(npm info $package@$npm_tag version)
echo "📦 Published version for $package@$npm_tag: $rc_version"
rc_release=${rc_version%-*}
# determine the
next_version=$(
semver --increment prerelease --preid $npm_tag $rc_version
)
echo "🤜 Next version: $package@$next_version"
# strip the pre-release version, yielding just major.minor.patch
pre_version=${next_version:${#local_version}}
echo " Prerelease suffix: '$pre_version'"
# get the name of every module
# FIXME there's gotta be a better way to do this
modules=$(lerna exec pwd | xargs basename)
# if this is the same version, we need to bump the prerelease
# for all of the modules using the same prerelease identifier
echo "Updating all module versions in place..."
echo
for module in $modules; do
pushd modules/$module > /dev/null
# determine the local version (in git)
module_version=$(jq -r .version package.json)
module_next_version="$module_version$pre_version"
echo "$module@$module_version => $module_next_version"
# "upgrade" to the most recent RC version so that
# `npm version prerelease` can increment automatically
bump --quiet "$module_next_version" >> $log
popd > /dev/null
done
# publish all the things!
lerna exec --bail -- npm publish --tag=$npm_tag

View File

@ -1,26 +1,8 @@
#!/bin/bash
set -e
args=${@:1}
package=primer-css
args=$@
npm_tag=pr
# the commit status context
context=npm/publish/${npm_tag}
echo "🐦 Publishing PR release to dist-tag '${npm_tag}'..."
lerna publish --npm-tag=${npm_tag} --canary --no-git ${args}
# get the published version of primer-css from its package.json
version=`jq -r .version modules/${package}/package.json`
slug="${package}@${version}"
echo "📡 Transmitting release success for ${slug} ..."
if [[ $TRAVIS_PULL_REQUEST_SHA ]]; then
# setting TRAVIS_COMMIT inline here is a fix for:
# <https://github.com/taskworld/commit-status/issues/5>
TRAVIS_COMMIT=$TRAVIS_PULL_REQUEST_SHA \
commit-status success ${context} \
"npm install ${slug}" \
"https://unpkg.com/${slug}/build/build.css"
fi
echo "🐦 Publishing PR release to dist-tag '$npm_tag'..."
lerna publish --npm-tag=$npm_tag --canary --no-git $args

14
script/version Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
if [[ $# -lt 1 ]]; then
echo "You must provide a version!"
exit 1
fi
version=$1
module=${2:-primer-css}
cd modules/$module
echo "${module}@$(jq -r .version package.json) => ${version}"
npm version --no-git ${@:1} > /dev/null