Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate docs for the CLI #40

Merged
merged 6 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ jobs:
destination: coverage.txt
- codecov/upload:
path: coverage.txt
docs:
executor: go
steps:
- checkout
- run: sudo apt-get install pandoc
- run: go run main.go usage
- store_artifacts:
path: ./docs
destination: docs
- run: ./.circleci/deploy-gh-pages.sh

lint:
docker:
Expand Down Expand Up @@ -55,8 +65,8 @@ jobs:
- run:
name: Tag Repo
command: |
git config --global user.email "[email protected]"
git config --global user.name "Marc O'Morain"
git config --global user.email $GH_EMAIL
git config --global user.name $GH_NAME
git tag -a "v0.1.$CIRCLE_BUILD_NUM" -m "Release v0.1.$CIRCLE_BUILD_NUM"
git push origin "v0.1.$CIRCLE_BUILD_NUM"
- run:
Expand All @@ -81,6 +91,9 @@ workflows:
- test
- coverage
- lint
- docs:
requires:
- deploy
- deploy:
requires:
- test
Expand Down
48 changes: 48 additions & 0 deletions .circleci/deploy-gh-pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
# ideas used from https://gist.github.com/motemen/8595451

# Based on https://github.com/eldarlabs/ghpages-deploy-script/blob/master/scripts/deploy-ghpages.sh
# Used with their MIT license https://github.com/eldarlabs/ghpages-deploy-script/blob/master/LICENSE

# abort the script if there is a non-zero error
set -e

# show where we are on the machine
pwd
remote=$(git config remote.origin.url)

# make a directory to put the gp-pages branch
mkdir gh-pages-branch
cd gh-pages-branch
# now lets setup a new repo so we can update the gh-pages branch
git config --global user.email "$GH_EMAIL" > /dev/null 2>&1
git config --global user.name "$GH_NAME" > /dev/null 2>&1
git init
git remote add --fetch origin "$remote"

# switch into the the gh-pages branch
if git rev-parse --verify origin/gh-pages > /dev/null 2>&1
then
git checkout gh-pages
# delete any old site as we are going to replace it
# Note: this explodes if there aren't any, so moving it here for now
git rm -rf .
else
git checkout --orphan gh-pages
fi

# copy over or recompile the new site
cp -a "../out/." .

# stage any changes and new files
git add -A
# now commit, ignoring branch gh-pages doesn't seem to work, so trying skip
git commit --allow-empty -m "Deploy to GitHub pages [ci skip]"
# and push, but send any output to /dev/null to hide anything sensitive
git push --force --quiet origin gh-pages
# go back to where we started and remove the gh-pages git repo we made and used
# for deployment
cd ..
rm -rf gh-pages-branch

echo "Finished Deployment!"
18 changes: 18 additions & 0 deletions .circleci/generate-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -e

# generate markdown docs
go run main.go usage

# setup output dir
mkdir -p out

# pandoc markdown to html into out dir
for f in docs/*.md; do
pandoc "$f" -s -o "out/$(basename ${f%.md}.html)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

# move index and update links
mv out/circleci.html out/index.html
sed -i -- 's#<a href="circleci.html">#<a href="index.html">#g' out/*.html
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ TODO
circleci-cli
coverage.txt
dist/
docs/
out/
.vscode
Loading