grafana/scripts/circle-release-next-packages.sh
Dominik Prokop de705229ba
Build: Release packages under next tag when changes detected on master (#18062)
* Testing lerna on circle

* Remove dependency on test task, fix yarn

* yarn fix

* Run lerna from local bin

* Use packages cache, run lern via npx

* Add packages:build

* Install packages before release

* Remove cache tmp

* add lerna bootstrap

* temporarily add tsignore

* lerna add data package to ui

* Remove @types/lodas resolution

* Try any...

* Typo fix

* Add publishing packages

* update lerna publish script

* Reset git befgore publishing package

* Correct lerna version

* Packages version bump

* Remove postpublish

* Publish to npm

* Set git creds before commit

* Rename job and run it after frontend tests and build passes

* Run next packages release on master but not when tagged with release

* Minor copy

* Update circle's config

* Fix config
2019-07-15 14:19:08 +02:00

43 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
function parse_git_hash() {
git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/\1/"
}
function prapare_version_commit () {
echo $'\nCommiting version changes. This commit will not be checked-in!'
git config --global user.email "circleci@grafana.com"
git config --global user.name "CirceCI"
git commit -am "Version commit"
}
#Get current version from lerna.json
PACKAGE_VERSION=`grep '"version"' lerna.json | cut -d '"' -f 4`
# Get short current commit's has
GIT_SHA=$(parse_git_hash)
echo "Commit: ${GIT_SHA}"
echo "Current lerna.json version: ${PACKAGE_VERSION}"
# count packages that changed
count=`npx lerna changed --loglevel silent | awk '{c++} END {print c}'`
if [ -z $count ]; then
echo "No changes in packages, skipping packages publishing"
else
echo "Changes detected in ${count} packages"
echo "Releasing packages under ${PACKAGE_VERSION}-${GIT_SHA}"
npx lerna version ${PACKAGE_VERSION}-${GIT_SHA} --no-git-tag-version --no-push --force-publish -y
echo $'\nGit status:'
git status -s
echo $'\nBuilding packages'
yarn packages:build
prapare_version_commit
echo $'\nPublishing packages'
yarn packages:publishNext
fi