Build system: Refactor scripts to use picocms/ci-tools
This commit is contained in:
parent
0c83f360a8
commit
722de2a1e5
9 changed files with 84 additions and 103 deletions
|
@ -2,13 +2,7 @@
|
|||
set -e
|
||||
|
||||
. "$(dirname "$0")/tools/functions/parse-version.sh.inc"
|
||||
export PATH="$(dirname "$0")/tools:$PATH"
|
||||
|
||||
DEPLOYMENT_ID="${TRAVIS_TAG//\//_}"
|
||||
DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/release-$DEPLOYMENT_ID.git"
|
||||
|
||||
[ -n "$RELEASE_REPO_SLUG" ] || export RELEASE_REPO_SLUG="$TRAVIS_REPO_SLUG"
|
||||
[ -n "$RELEASE_REPO_BRANCH" ] || export RELEASE_REPO_BRANCH="master"
|
||||
export PATH="$PICO_TOOLS_DIR:$PATH"
|
||||
|
||||
# parameters
|
||||
ARCHIVE="$1" # release archive file name
|
||||
|
@ -19,15 +13,15 @@ if [ -z "$ARCHIVE" ]; then
|
|||
fi
|
||||
|
||||
# parse version
|
||||
if ! parse_version "$TRAVIS_TAG"; then
|
||||
echo "Unable to create release archive: Invalid version '$TRAVIS_TAG'" >&2
|
||||
if ! parse_version "$PROJECT_REPO_TAG"; then
|
||||
echo "Unable to create release archive: Invalid version '$PROJECT_REPO_TAG'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# clone repo
|
||||
github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$RELEASE_REPO_SLUG.git" "$RELEASE_REPO_BRANCH"
|
||||
github-clone.sh "$PICO_BUILD_DIR" "https://github.com/$RELEASE_REPO_SLUG.git" "$RELEASE_REPO_BRANCH"
|
||||
|
||||
cd "$DEPLOYMENT_DIR"
|
||||
cd "$PICO_BUILD_DIR"
|
||||
|
||||
# force Pico version
|
||||
echo "Updating composer dependencies..."
|
44
.build/deploy-branch.sh
Executable file
44
.build/deploy-branch.sh
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
export PATH="$PICO_TOOLS_DIR:$PATH"
|
||||
|
||||
# get current Pico milestone
|
||||
VERSION="$(php -r "require_once('$PICO_PROJECT_DIR/lib/Pico.php'); echo Pico::VERSION;")"
|
||||
MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATCH[1]}")"
|
||||
|
||||
echo "Deploying $PROJECT_REPO_BRANCH branch ($MILESTONE)..."
|
||||
echo
|
||||
|
||||
# clone repo
|
||||
github-clone.sh "$PICO_DEPLOY_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
|
||||
|
||||
cd "$PICO_DEPLOY_DIR"
|
||||
|
||||
# setup repo
|
||||
github-setup.sh
|
||||
|
||||
# generate phpDocs
|
||||
generate-phpdoc.sh \
|
||||
"$PICO_PROJECT_DIR/.phpdoc.xml" \
|
||||
"$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT.cache" "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" \
|
||||
"$MILESTONE API Documentation ($PROJECT_REPO_BRANCH branch)"
|
||||
|
||||
if [ -z "$(git status --porcelain "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT.cache")" ]; then
|
||||
# nothing to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# update phpDoc list
|
||||
update-phpdoc-list.sh \
|
||||
"$PICO_DEPLOY_DIR/_data/phpDoc.yml" \
|
||||
"$PICO_DEPLOYMENT" "branch" "<code>$PROJECT_REPO_BRANCH</code> branch" "$(date +%s)"
|
||||
|
||||
# commit phpDocs
|
||||
github-commit.sh \
|
||||
"Update phpDocumentor class docs for $PROJECT_REPO_BRANCH branch @ $PROJECT_REPO_COMMIT" \
|
||||
"$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT.cache" "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" \
|
||||
"$PICO_DEPLOY_DIR/_data/phpDoc.yml"
|
||||
|
||||
# deploy phpDocs
|
||||
github-deploy.sh "$PROJECT_REPO_SLUG" "heads/$PROJECT_REPO_BRANCH" "$PROJECT_REPO_COMMIT"
|
|
@ -32,17 +32,11 @@ if [ "$DEPLOY_FULL" != "true" ]; then
|
|||
fi
|
||||
|
||||
. "$(dirname "$0")/tools/functions/parse-version.sh.inc"
|
||||
export PATH="$(dirname "$0")/tools:$PATH"
|
||||
|
||||
DEPLOYMENT_ID="${TRAVIS_TAG//\//_}"
|
||||
DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git"
|
||||
|
||||
[ -n "$DEPLOY_REPO_SLUG" ] || export DEPLOY_REPO_SLUG="$TRAVIS_REPO_SLUG"
|
||||
[ -n "$DEPLOY_REPO_BRANCH" ] || export DEPLOY_REPO_BRANCH="gh-pages"
|
||||
export PATH="$PICO_TOOLS_DIR:$PATH"
|
||||
|
||||
# parse version
|
||||
if ! parse_version "$TRAVIS_TAG"; then
|
||||
echo "Invalid version '$TRAVIS_TAG'; aborting..." >&2
|
||||
if ! parse_version "$PROJECT_REPO_TAG"; then
|
||||
echo "Invalid version '$PROJECT_REPO_TAG'; aborting..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -53,9 +47,9 @@ printf 'VERSION_ID="%s"\n' "$VERSION_ID"
|
|||
echo
|
||||
|
||||
# clone repo
|
||||
github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
|
||||
github-clone.sh "$PICO_DEPLOY_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
|
||||
|
||||
cd "$DEPLOYMENT_DIR"
|
||||
cd "$PICO_DEPLOY_DIR"
|
||||
|
||||
# setup repo
|
||||
github-setup.sh
|
||||
|
@ -64,20 +58,20 @@ github-setup.sh
|
|||
if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
|
||||
# generate phpDocs
|
||||
generate-phpdoc.sh \
|
||||
"$TRAVIS_BUILD_DIR/.phpdoc.xml" \
|
||||
"-" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
|
||||
"Pico $VERSION_MILESTONE API Documentation ($TRAVIS_TAG)"
|
||||
"$PICO_PROJECT_DIR/.phpdoc.xml" \
|
||||
"-" "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" \
|
||||
"Pico $VERSION_MILESTONE API Documentation (v$VERSION_FULL)"
|
||||
|
||||
if [ -n "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID")" ]; then
|
||||
if [ -n "$(git status --porcelain "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT")" ]; then
|
||||
# update phpDoc list
|
||||
update-phpdoc-list.sh \
|
||||
"$DEPLOYMENT_DIR/_data/phpDoc.yml" \
|
||||
"$TRAVIS_TAG" "version" "Pico ${TRAVIS_TAG#v}" "$(date +%s)"
|
||||
"$PICO_DEPLOY_DIR/_data/phpDoc.yml" \
|
||||
"$PICO_DEPLOYMENT" "version" "Pico $VERSION_FULL" "$(date +%s)"
|
||||
|
||||
# commit phpDocs
|
||||
github-commit.sh \
|
||||
"Update phpDocumentor class docs for $TRAVIS_TAG" \
|
||||
"$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml"
|
||||
"Update phpDocumentor class docs for v$VERSION_FULL" \
|
||||
"$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" "$PICO_DEPLOY_DIR/_data/phpDoc.yml"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -86,37 +80,37 @@ if [ "$VERSION_STABILITY" == "stable" ]; then
|
|||
# update version badge
|
||||
if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
|
||||
generate-badge.sh \
|
||||
"$DEPLOYMENT_DIR/badges/pico-version.svg" \
|
||||
"release" "$TRAVIS_TAG" "blue"
|
||||
"$PICO_DEPLOY_DIR/badges/pico-version.svg" \
|
||||
"release" "$VERSION_FULL" "blue"
|
||||
|
||||
# commit version badge
|
||||
github-commit.sh \
|
||||
"Update version badge for $TRAVIS_TAG" \
|
||||
"$DEPLOYMENT_DIR/badges/pico-version.svg"
|
||||
"Update version badge for v$VERSION_FULL" \
|
||||
"$PICO_DEPLOY_DIR/badges/pico-version.svg"
|
||||
fi
|
||||
|
||||
# update version file
|
||||
if [ "$DEPLOY_VERSION_FILE" == "true" ]; then
|
||||
update-version-file.sh \
|
||||
"$DEPLOYMENT_DIR/_data/version.yml" \
|
||||
"$PICO_DEPLOY_DIR/_data/version.yml" \
|
||||
"$VERSION_FULL"
|
||||
|
||||
# commit version file
|
||||
github-commit.sh \
|
||||
"Update version file for $TRAVIS_TAG" \
|
||||
"$DEPLOYMENT_DIR/_data/version.yml"
|
||||
"Update version file for v$VERSION_FULL" \
|
||||
"$PICO_DEPLOY_DIR/_data/version.yml"
|
||||
fi
|
||||
|
||||
# update cloc statistics
|
||||
if [ "$DEPLOY_CLOC_STATS" == "true" ]; then
|
||||
update-cloc-stats.sh "$DEPLOYMENT_DIR/_data/cloc.yml"
|
||||
update-cloc-stats.sh "$PICO_DEPLOY_DIR/_data/cloc.yml"
|
||||
|
||||
# commit cloc statistics
|
||||
github-commit.sh \
|
||||
"Update cloc statistics for $TRAVIS_TAG" \
|
||||
"$DEPLOYMENT_DIR/_data/cloc.yml"
|
||||
"Update cloc statistics for v$VERSION_FULL" \
|
||||
"$PICO_DEPLOY_DIR/_data/cloc.yml"
|
||||
fi
|
||||
fi
|
||||
|
||||
# deploy
|
||||
github-deploy.sh "$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_COMMIT"
|
||||
github-deploy.sh "$PROJECT_REPO_SLUG" "tags/$PROJECT_REPO_TAG" "$PROJECT_REPO_COMMIT"
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
if [ -n "$TRAVIS_TAG" ]; then
|
||||
if [ -n "$PROJECT_REPO_TAG" ]; then
|
||||
exec "$(dirname "$0")/deploy-release.sh"
|
||||
else
|
||||
exec "$(dirname "$0")/deploy-branch.sh"
|
|
@ -21,19 +21,19 @@ if [ -n "$GITHUB_OAUTH_TOKEN" ]; then
|
|||
fi
|
||||
|
||||
# set COMPOSER_ROOT_VERSION when necessary
|
||||
if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PROJECT_REPO_BRANCH" ]; then
|
||||
PICO_VERSION_PATTERN="$(php -r "
|
||||
\$json = json_decode(file_get_contents('$TRAVIS_BUILD_DIR/composer.json'), true);
|
||||
\$json = json_decode(file_get_contents('$PICO_PROJECT_DIR/composer.json'), true);
|
||||
if (\$json !== null) {
|
||||
if (isset(\$json['extra']['branch-alias']['dev-$TRAVIS_BRANCH'])) {
|
||||
echo 'dev-$TRAVIS_BRANCH';
|
||||
if (isset(\$json['extra']['branch-alias']['dev-$PROJECT_REPO_BRANCH'])) {
|
||||
echo 'dev-$PROJECT_REPO_BRANCH';
|
||||
}
|
||||
}
|
||||
")"
|
||||
|
||||
if [ -z "$PICO_VERSION_PATTERN" ]; then
|
||||
PICO_VERSION_PATTERN="$(php -r "
|
||||
require_once('$TRAVIS_BUILD_DIR/lib/Pico.php');
|
||||
require_once('$PICO_PROJECT_DIR/lib/Pico.php');
|
||||
echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', Pico::VERSION);
|
||||
")"
|
||||
fi
|
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -1,4 +1,4 @@
|
|||
/_build export-ignore
|
||||
/.build export-ignore
|
||||
/assets/.gitignore export-ignore
|
||||
/config/.gitignore export-ignore
|
||||
/content/.gitignore export-ignore
|
||||
|
|
|
@ -49,7 +49,10 @@ jobs:
|
|||
fast-finish: true
|
||||
|
||||
before_install:
|
||||
- export PATH="$TRAVIS_BUILD_DIR/_build:$PATH"
|
||||
- export PATH="$TRAVIS_BUILD_DIR/.build:$PATH"
|
||||
- export PICO_TOOLS_DIR="$HOME/__picocms_tools"
|
||||
- git clone --branch="$TOOLS_REPO_BRANCH" "https://github.com/$TOOLS_REPO_SLUG.git" "$PICO_TOOLS_DIR"
|
||||
- . "$PICO_TOOLS_DIR/init/travis.sh.inc"
|
||||
|
||||
install:
|
||||
- install.sh
|
||||
|
|
4
_build/.gitignore
vendored
4
_build/.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
# Ignore temporary directories created while building/deploying Pico
|
||||
/phpdoc
|
||||
/phpdoc.cache
|
||||
/deploy-*.git
|
|
@ -1,50 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
export PATH="$(dirname "$0")/tools:$PATH"
|
||||
|
||||
DEPLOYMENT_ID="${TRAVIS_BRANCH//\//_}"
|
||||
DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git"
|
||||
|
||||
[ -n "$DEPLOY_REPO_SLUG" ] || export DEPLOY_REPO_SLUG="$TRAVIS_REPO_SLUG"
|
||||
[ -n "$DEPLOY_REPO_BRANCH" ] || export DEPLOY_REPO_BRANCH="gh-pages"
|
||||
|
||||
# get current Pico milestone
|
||||
VERSION="$(php -r 'require_once(__DIR__ . "/lib/Pico.php"); echo Pico::VERSION;')"
|
||||
MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATCH[1]}")"
|
||||
|
||||
echo "Deploying $TRAVIS_BRANCH branch ($MILESTONE)..."
|
||||
echo
|
||||
|
||||
# clone repo
|
||||
github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
|
||||
|
||||
cd "$DEPLOYMENT_DIR"
|
||||
|
||||
# setup repo
|
||||
github-setup.sh
|
||||
|
||||
# generate phpDocs
|
||||
generate-phpdoc.sh \
|
||||
"$TRAVIS_BUILD_DIR/.phpdoc.xml" \
|
||||
"$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
|
||||
"$MILESTONE API Documentation ($TRAVIS_BRANCH branch)"
|
||||
|
||||
if [ -z "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache")" ]; then
|
||||
# nothing to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# update phpDoc list
|
||||
update-phpdoc-list.sh \
|
||||
"$DEPLOYMENT_DIR/_data/phpDoc.yml" \
|
||||
"$TRAVIS_BRANCH" "branch" "<code>$TRAVIS_BRANCH</code> branch" "$(date +%s)"
|
||||
|
||||
# commit phpDocs
|
||||
github-commit.sh \
|
||||
"Update phpDocumentor class docs for $TRAVIS_BRANCH branch @ $TRAVIS_COMMIT" \
|
||||
"$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
|
||||
"$DEPLOYMENT_DIR/_data/phpDoc.yml"
|
||||
|
||||
# deploy phpDocs
|
||||
github-deploy.sh "$TRAVIS_REPO_SLUG" "heads/$TRAVIS_BRANCH" "$TRAVIS_COMMIT"
|
Loading…
Reference in a new issue