Skip to content

Commit

Permalink
unconditionally create git tag
Browse files Browse the repository at this point in the history
if the travis build passed, we want to create a git tag regardless of
whether or not a crate was published

then publish the crate only if the git tag didn't previously exist
  • Loading branch information
blaenk committed Aug 16, 2015
1 parent c2ad19f commit d1266dd
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions .travis/publish_crate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ set -o errexit -o nounset

([[ $TRAVIS_BRANCH != "master" ]] || [[ $TRAVIS_PULL_REQUEST != "false" ]]) && exit 0

cargo login $CRATESIO_TOKEN
version=$(cat Cargo.toml | awk -F'"' '/version/{print $2}')

if cargo publish; then
echo "Published new version on crates.io"

echo "Creating new git tag"
version=$(cat Cargo.toml | awk -F'"' '/version/{print $2}')
if ! git rev-parse $version > /dev/null 2>&1; then
echo "Creating new git tag $version"

git config user.name "Jorge Israel Peña"
git config user.email "[email protected]"

git remote add upstream "https://$GH_TOKEN@github.com/blaenk/hoedown.git"
git tag -a "v$version" -m "published https://crates.io/crates/hoedown/$version"
git push upstream --tags

echo "Publishing to crates.io"

cargo login $CRATESIO_TOKEN

if cargo publish; then
echo "Published new version on crates.io"
else
echo "Error; Perhaps version already exists?"
fi
else
echo "Version already existed"
echo "Tag $version already exists; no tag created, no crate published"
fi

0 comments on commit d1266dd

Please sign in to comment.