Skip to content

Commit

Permalink
Merge pull request #334 from picocms/pico-1.1
Browse files Browse the repository at this point in the history
Pico 2.0
  • Loading branch information
PhrozenByte authored Jul 1, 2018
2 parents d2055d0 + 25c32de commit 6a7494a
Show file tree
Hide file tree
Showing 56 changed files with 3,132 additions and 2,523 deletions.
77 changes: 77 additions & 0 deletions .build/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -e

export PATH="$PICO_TOOLS_DIR:$PATH"
. "$PICO_TOOLS_DIR/functions/parse-version.sh.inc"

# parameters
ARCHIVE="$1" # release archive file name

if [ -z "$ARCHIVE" ]; then
echo "Unable to create release archive: No file name specified" >&2
exit 1
fi

# parse version
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 "$PICO_BUILD_DIR" "https://github.com/$RELEASE_REPO_SLUG.git" "$RELEASE_REPO_BRANCH"

cd "$PICO_BUILD_DIR"

# force Pico version
echo "Updating composer dependencies..."
composer require --no-update \
"picocms/pico $VERSION_FULL@$VERSION_STABILITY" \
"picocms/pico-theme $VERSION_FULL@$VERSION_STABILITY" \
"picocms/pico-deprecated $VERSION_FULL@$VERSION_STABILITY"
echo

# install dependencies
echo "Running \`composer install\`..."
composer install --no-suggest --prefer-dist --no-dev --optimize-autoloader
echo

# prepare release
echo "Replacing 'index.php'..."
cp vendor/picocms/pico/index.php.dist index.php

echo "Adding 'config/config.yml.template'..."
cp vendor/picocms/pico/config/config.yml.template config/config.yml.template

echo "Adding 'README.md', 'CONTRIBUTING.md', 'CHANGELOG.md'..."
cp vendor/picocms/pico/README.md README.md
cp vendor/picocms/pico/CONTRIBUTING.md CONTRIBUTING.md
cp vendor/picocms/pico/CHANGELOG.md CHANGELOG.md

echo "Preparing 'composer.json' for release..."
composer require --no-update \
"picocms/pico ^$VERSION_MILESTONE" \
"picocms/pico-theme ^$VERSION_MILESTONE" \
"picocms/pico-deprecated ^$VERSION_MILESTONE"

echo "Removing '.git' directory..."
rm -rf .git

echo "Removing '.git' directories of dependencies..."
find vendor/ -type d -path 'vendor/*/*/.git' -print0 | xargs -0 rm -rf
find themes/ -type d -path 'themes/*/.git' -print0 | xargs -0 rm -rf
find plugins/ -type d -path 'plugins/*/.git' -print0 | xargs -0 rm -rf

echo

# create release archive
echo "Creating release archive '$ARCHIVE'..."

if [ -e "$ARCHIVE" ]; then
echo "Unable to create release archive: File exists" >&2
exit 1
fi

find . -mindepth 1 -maxdepth 1 -printf '%f\0' \
| xargs -0 -- tar -czf "$ARCHIVE" --
echo
44 changes: 44 additions & 0 deletions .build/deploy-branch.sh
Original file line number Diff line number Diff line change
@@ -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"
116 changes: 116 additions & 0 deletions .build/deploy-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env bash
set -e

DEPLOY_FULL="true"
if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ]; then
echo "Skipping phpDoc release deployment because it has been disabled"
DEPLOY_FULL="false"
fi
if [ "$DEPLOY_VERSION_BADGE" != "true" ]; then
echo "Skipping version badge deployment because it has been disabled"
DEPLOY_FULL="false"
fi
if [ "$DEPLOY_VERSION_FILE" != "true" ]; then
echo "Skipping version file deployment because it has been disabled"
DEPLOY_FULL="false"
fi
if [ "$DEPLOY_CLOC_STATS" != "true" ]; then
echo "Skipping cloc statistics deployment because it has been disabled"
DEPLOY_FULL="false"
fi

if [ "$DEPLOY_FULL" != "true" ]; then
if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] \
&& [ "$DEPLOY_VERSION_BADGE" != "true" ] \
&& [ "$DEPLOY_VERSION_FILE" != "true" ] \
&& [ "$DEPLOY_CLOC_STATS" != "true" ]
then
# nothing to do
exit 0
fi
echo
fi

export PATH="$PICO_TOOLS_DIR:$PATH"
. "$PICO_TOOLS_DIR/functions/parse-version.sh.inc"

# parse version
if ! parse_version "$PROJECT_REPO_TAG"; then
echo "Invalid version '$PROJECT_REPO_TAG'; aborting..." >&2
exit 1
fi

echo "Deploying Pico $VERSION_MILESTONE ($VERSION_STABILITY)..."
printf 'VERSION_FULL="%s"\n' "$VERSION_FULL"
printf 'VERSION_NAME="%s"\n' "$VERSION_NAME"
printf 'VERSION_ID="%s"\n' "$VERSION_ID"
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
if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
# generate phpDocs
generate-phpdoc.sh \
"$PICO_PROJECT_DIR/.phpdoc.xml" \
"-" "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" \
"Pico $VERSION_MILESTONE API Documentation (v$VERSION_FULL)"

if [ -n "$(git status --porcelain "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT")" ]; then
# update phpDoc list
update-phpdoc-list.sh \
"$PICO_DEPLOY_DIR/_data/phpDoc.yml" \
"$PICO_DEPLOYMENT" "version" "Pico $VERSION_FULL" "$(date +%s)"

# commit phpDocs
github-commit.sh \
"Update phpDocumentor class docs for v$VERSION_FULL" \
"$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" "$PICO_DEPLOY_DIR/_data/phpDoc.yml"
fi
fi

# don't update version badge, version file and cloc statistics for pre-releases
if [ "$VERSION_STABILITY" == "stable" ]; then
# update version badge
if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
generate-badge.sh \
"$PICO_DEPLOY_DIR/badges/pico-version.svg" \
"release" "$VERSION_FULL" "blue"

# commit version badge
github-commit.sh \
"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 \
"$PICO_DEPLOY_DIR/_data/version.yml" \
"$VERSION_FULL"

# commit version file
github-commit.sh \
"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 "$PICO_DEPLOY_DIR/_data/cloc.yml"

# commit cloc statistics
github-commit.sh \
"Update cloc statistics for v$VERSION_FULL" \
"$PICO_DEPLOY_DIR/_data/cloc.yml"
fi
fi

# deploy
github-deploy.sh "$PROJECT_REPO_SLUG" "tags/$PROJECT_REPO_TAG" "$PROJECT_REPO_COMMIT"
6 changes: 6 additions & 0 deletions .build/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
if [ -n "$PROJECT_REPO_TAG" ]; then
exec "$(dirname "$0")/deploy-release.sh"
else
exec "$(dirname "$0")/deploy-branch.sh"
fi
54 changes: 54 additions & 0 deletions .build/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
set -e

# setup build system
echo "Installing build dependencies..."

case "$1" in
"--deploy")
echo "Synchronizing package index files..."
sudo apt-get update

echo "Installing packages..."
sudo apt-get install -y cloc
;;
esac

echo

# setup composer
echo "Setup Composer..."

# let composer use our GITHUB_OAUTH_TOKEN
if [ -n "$GITHUB_OAUTH_TOKEN" ]; then
composer config --global github-oauth.github.com "$GITHUB_OAUTH_TOKEN"
fi

# set COMPOSER_ROOT_VERSION when necessary
if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PROJECT_REPO_BRANCH" ]; then
PICO_VERSION_PATTERN="$(php -r "
\$json = json_decode(file_get_contents('$PICO_PROJECT_DIR/composer.json'), true);
if (\$json !== null) {
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('$PICO_PROJECT_DIR/lib/Pico.php');
echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', Pico::VERSION);
")"
fi

if [ -n "$PICO_VERSION_PATTERN" ]; then
export COMPOSER_ROOT_VERSION="$PICO_VERSION_PATTERN"
fi
fi

echo

# install dependencies
echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..."
composer install --no-suggest
20 changes: 12 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/.github export-ignore
/_build export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpcs.xml export-ignore
/.phpdoc.xml export-ignore
/.travis.yml export-ignore
/index.php.dist export-ignore
/.github export-ignore
/.build export-ignore
/assets/.gitignore export-ignore
/config/.gitignore export-ignore
/content/.gitignore export-ignore
/plugins/.gitignore export-ignore
/themes/.gitignore export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpcs.xml export-ignore
/.phpdoc.xml export-ignore
/.travis.yml export-ignore
48 changes: 48 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
Developer Certificate of Origin
===============================
By contributing to Pico, you accept and agree to the following terms and conditions (the *Developer Certificate of Origin*) for your present and future contributions submitted to Pico. Please refer to the *Developer Certificate of Origin* section in Pico's [`CONTRIBUTING.md`](https://github.com/picocms/Pico/blob/master/CONTRIBUTING.md#developer-certificate-of-origin) for details.
```
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```
-->
Loading

0 comments on commit 6a7494a

Please sign in to comment.