-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Nemo157/auto_publish
Add auto publishing of tags from travis ci
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
TAG=${1:?'Missing tag to publish for'} | ||
TOKEN=${2:?'Missing crates.io token to publish with'} | ||
|
||
if ! grep -Fxq "version = "'"'"$TAG"'"' Cargo.toml | ||
then | ||
echo "Tag $TAG doesn't appear to be the version in Cargo.toml" | ||
fi | ||
|
||
cargo publish --verbose --token "$TOKEN" | ||
|
||
# Setup this repo to publish the docs | ||
git fetch origin gh-pages | ||
git checkout -b gh-pages FETCH_HEAD | ||
|
||
# Move the built docs into versioned folder | ||
mv target/doc docs/$TAG | ||
|
||
# Update the index to point to the versioned docs | ||
sed -i'' -e '/<!-- TRAVIS: PUT THE DOCS HERE-->/a\ | ||
<li><a href="docs/'"$TAG"'/hamlet/">'"$TAG"'</a></li> | ||
' index.html | ||
|
||
# Add the changes | ||
git add docs/$TAG | ||
git add index.html | ||
|
||
# Commit and push | ||
git commit -m "Add API docs for $TAG" | ||
git push origin gh-pages:gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
: ${TRAVIS:?'This should only be run on Travis CI'} | ||
GITHUB_TOKEN=${1:?'Must provide github token'} | ||
REPO_SLUG=${2:?'Must provide repo slug'} | ||
|
||
echo "machine github.com login $GITHUB_TOKEN password x-oauth-basic" >> ~/.netrc | ||
chmod 0600 ~/.netrc | ||
git remote set-url --push origin "https://github.com/$REPO_SLUG" |