Add static shields.io badge generator
This commit is contained in:
parent
73078a3dc3
commit
92026a3bd0
4 changed files with 103 additions and 26 deletions
|
@ -33,8 +33,13 @@ generate-phpdoc.sh \
|
|||
"Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
||||
# deploy phpDocs
|
||||
deploy-phpdoc.sh \
|
||||
"Update phpDocumentor class docs for $TRAVIS_BRANCH branch @ $TRAVIS_COMMIT" \
|
||||
"$TRAVIS_REPO_SLUG" "heads/$TRAVIS_BRANCH" "$TRAVIS_COMMIT"
|
||||
# commit phpDocs
|
||||
git add "$PHPDOC_GIT_DIR/phpDoc/$PHPDOC_ID"
|
||||
git commit \
|
||||
--message="Update phpDocumentor class docs for $TRAVIS_BRANCH branch @ $TRAVIS_COMMIT" \
|
||||
"$PHPDOC_GIT_DIR/phpDoc/$PHPDOC_ID"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
||||
# deploy phpDocs
|
||||
github-deploy.sh "$TRAVIS_REPO_SLUG" "heads/$TRAVIS_BRANCH" "$TRAVIS_COMMIT"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
|
|
@ -3,25 +3,41 @@
|
|||
[ "$DEPLOY_PHPDOC_RELEASES" == "true" ] || exit
|
||||
|
||||
PHPDOC_ID="${TRAVIS_BRANCH//\//_}"
|
||||
PHPDOC_GIT_DIR="$TRAVIS_BUILD_DIR/_build/phpdoc-$PHPDOC_ID.git"
|
||||
GIT_DIR="$TRAVIS_BUILD_DIR/_build/phpdoc-$PHPDOC_ID.git"
|
||||
|
||||
# clone repo
|
||||
echo "Cloning repo..."
|
||||
git clone --branch="gh-pages" "https://github.com/$TRAVIS_REPO_SLUG.git" "$PHPDOC_GIT_DIR"
|
||||
git clone --branch="gh-pages" "https://github.com/$TRAVIS_REPO_SLUG.git" "$GIT_DIR"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
||||
cd "$PHPDOC_GIT_DIR"
|
||||
cd "$GIT_DIR"
|
||||
echo
|
||||
|
||||
# generate phpDocs
|
||||
generate-phpdoc.sh \
|
||||
"$TRAVIS_BUILD_DIR/.phpdoc.xml" \
|
||||
"-" "$PHPDOC_GIT_DIR/phpDoc/$PHPDOC_ID" \
|
||||
"-" "$GIT_DIR/phpDoc/$PHPDOC_ID" \
|
||||
"Pico 1.0 API Documentation ($TRAVIS_TAG)"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
||||
# deploy phpDocs
|
||||
deploy-phpdoc.sh \
|
||||
"Update phpDocumentor class docs for $TRAVIS_TAG" \
|
||||
"$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_COMMIT"
|
||||
# commit phpDocs
|
||||
git add "$GIT_DIR/phpDoc/$PHPDOC_ID"
|
||||
git commit \
|
||||
--message="Update phpDocumentor class docs for $TRAVIS_TAG" \
|
||||
"$GIT_DIR/phpDoc/$PHPDOC_ID"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
||||
# update version badge
|
||||
gnerate-badge.sh \
|
||||
"$GIT_DIR/badges/pico-version.svg" \
|
||||
"release" "v$TRAVIS_TAG" "blue"
|
||||
|
||||
# commit version badge
|
||||
git add "$GIT_DIR/badges/pico-version.svg"
|
||||
git commit \
|
||||
--message="Update version badge for $TRAVIS_TAG" \
|
||||
"$GIT_DIR/badges/pico-version.svg"
|
||||
|
||||
# deploy
|
||||
github-deploy.sh "$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_COMMIT"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
|
55
_build/generate-badge.sh
Executable file
55
_build/generate-badge.sh
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##
|
||||
# Downloads a custom badge from shields.io
|
||||
#
|
||||
# All credit goes to the awesome guys at shields.io!
|
||||
#
|
||||
# @see http://shields.io/
|
||||
#
|
||||
# @author Daniel Rudolf
|
||||
# @link http://picocms.org
|
||||
# @license http://opensource.org/licenses/MIT
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# parameters
|
||||
BADGE_FILE_PATH="$1"
|
||||
BADGE_SUBJECT="$2"
|
||||
BADGE_STATUS="$3"
|
||||
BADGE_COLOR="$4"
|
||||
|
||||
# print parameters
|
||||
echo "Generating badge..."
|
||||
printf 'BADGE_FILE_PATH="%s"\n' "$BADGE_FILE_PATH"
|
||||
printf 'BADGE_SUBJECT="%s"\n' "$BADGE_SUBJECT"
|
||||
printf 'BADGE_STATUS="%s"\n' "$BADGE_STATUS"
|
||||
printf 'BADGE_COLOR="%s"\n' "$BADGE_COLOR"
|
||||
echo
|
||||
|
||||
# download badge from shields.io
|
||||
printf 'Downloading badge...\n'
|
||||
TMP_BADGE="$(mktemp -u)"
|
||||
|
||||
wget -O "$TMP_BADGE" \
|
||||
"https://img.shields.io/badge/$BADGE_SUBJECT-$BADGE_STATUS-$BADGE_COLOR.svg"
|
||||
|
||||
# validate badge
|
||||
if [ ! -f "$TMP_BADGE" ]; then
|
||||
echo "Unable to generate badge; aborting...\n" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# MIME type image/svg+xml isn't supported at the moment
|
||||
#
|
||||
#TMP_BADGE_MIME="$(file --mime-type "$TMP_BADGE" | cut -d ' ' -f 2)"
|
||||
#if [ "$TMP_BADGE_MIME" != "image/svg+xml" ]; then
|
||||
# echo "Generated badge should be of type 'image/svg+xml', '$TMP_BADGE_MIME' given; aborting...\n" >&2
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
# deploy badge
|
||||
mv "$TMP_BADGE" "$BADGE_FILE_PATH"
|
||||
|
||||
echo
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##
|
||||
# Deploys phpDoc class documentation
|
||||
# Pushes commits to a GitHub repo
|
||||
#
|
||||
# @author Daniel Rudolf
|
||||
# @link http://picocms.org
|
||||
|
@ -14,22 +14,26 @@ set -e
|
|||
# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens
|
||||
|
||||
# parameters
|
||||
COMMIT_MESSAGE="$1" # commit message
|
||||
CHECK_REPO_SLUG="$2" # optional GitHub repo (e.g. picocms/Pico) to check
|
||||
CHECK_REPO_SLUG="$1" # optional GitHub repo (e.g. picocms/Pico) to check
|
||||
# its latest commit as basic race condition protection
|
||||
CHECK_REMOTE_REF="$3" # optional remote Git reference (e.g. heads/master)
|
||||
CHECK_LOCAL_COMMIT="$4" # optional local commit SHA1
|
||||
CHECK_REMOTE_REF="$2" # optional remote Git reference (e.g. heads/master)
|
||||
CHECK_LOCAL_COMMIT="$3" # optional local commit SHA1
|
||||
|
||||
# print parameters
|
||||
echo "Deploying phpDocs..."
|
||||
printf 'COMMIT_MESSAGE="%s"\n' "$COMMIT_MESSAGE"
|
||||
echo "Deploying repo..."
|
||||
printf 'CHECK_REPO_SLUG="%s"\n' "$CHECK_REPO_SLUG"
|
||||
printf 'CHECK_REMOTE_REF="%s"\n' "$CHECK_REMOTE_REF"
|
||||
printf 'CHECK_LOCAL_COMMIT="%s"\n' "$CHECK_LOCAL_COMMIT"
|
||||
echo
|
||||
|
||||
# check for git repo
|
||||
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
printf 'Not a git repo; aborting...\n\n'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check for changes
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
if [ -z "$(git log --oneline '@{upstream}..')" ]; then
|
||||
printf 'Nothing to deploy; skipping...\n\n'
|
||||
exit 0
|
||||
fi
|
||||
|
@ -45,11 +49,6 @@ if [ -n "$GITHUB_OAUTH_TOKEN" ]; then
|
|||
(umask 077 && echo "https://GitHub:$GITHUB_OAUTH_TOKEN@github.com" > .git/credentials)
|
||||
fi
|
||||
|
||||
# commit changes
|
||||
printf '\nCommiting changes...\n'
|
||||
git add --all
|
||||
git commit --message="$COMMIT_MESSAGE"
|
||||
|
||||
# race condition protection for concurrent Travis builds
|
||||
# this is no definite protection (race conditions are still possible during `git push`),
|
||||
# but it should give a basic protection without disabling concurrent builds completely
|
||||
|
@ -84,6 +83,8 @@ fi
|
|||
|
||||
# push changes
|
||||
printf '\nPushing changes...\n'
|
||||
git push origin
|
||||
git push
|
||||
EXIT_CODE=$?
|
||||
|
||||
echo
|
||||
exit $EXIT_CODE
|
Loading…
Add table
Reference in a new issue