🎉 Switch from Travis CI to GitHub Actions for release deployment
Since Travis CI was transformed into a proprietary service we didn't have a CI pipeline. This heavily refactors and simplifies the CI pipeline and uses GitHub Actions to deploy new Pico releases. You can use Pico's Makefile to build new releases locally, too. Pico's build script no longer depends on any external resources (like our `picocms/ci-tools` collection). However, this isn't true for other release deployment steps, like updating phpDoc class docs, version badge, cloc stats, etc., even though the CI scripts are mostly self-containing now.
This commit is contained in:
parent
67408ce935
commit
1aacce829f
14 changed files with 748 additions and 414 deletions
446
.build/build.sh
Executable file
446
.build/build.sh
Executable file
|
@ -0,0 +1,446 @@
|
|||
#!/bin/bash
|
||||
# Pico -- build.sh
|
||||
# Builds a new Pico release and creates release archives.
|
||||
#
|
||||
# This file is part of Pico, a stupidly simple, blazing fast, flat file CMS.
|
||||
# Visit us at https://picocms.org/ for more info.
|
||||
#
|
||||
# Copyright (c) 2017 Daniel Rudolf <https://www.daniel-rudolf.de>
|
||||
#
|
||||
# This work is licensed under the terms of the MIT license.
|
||||
# For a copy, see LICENSE file or <https://opensource.org/licenses/MIT>.
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# License-Filename: LICENSE
|
||||
|
||||
set -eu -o pipefail
|
||||
export LC_ALL=C
|
||||
|
||||
# env variables
|
||||
PHP="${PHP:-php}"
|
||||
export -n PHP
|
||||
|
||||
COMPOSER="${COMPOSER:-composer}"
|
||||
export -n COMPOSER
|
||||
|
||||
if ! which "$PHP" > /dev/null; then
|
||||
echo "Missing script dependency: php" >&2
|
||||
exit 1
|
||||
elif ! which "$COMPOSER" > /dev/null; then
|
||||
echo "Missing script dependency: composer" >&2
|
||||
exit 1
|
||||
elif ! which "git" > /dev/null; then
|
||||
echo "Missing script dependency: git" >&2
|
||||
exit 1
|
||||
elif ! which "rsync" > /dev/null; then
|
||||
echo "Missing script dependency: rsync" >&2
|
||||
exit 1
|
||||
elif ! which "jq" > /dev/null; then
|
||||
echo "Missing script dependency: jq" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# parameters
|
||||
BUILD_NAME="pico"
|
||||
BUILD_PROJECT="picocms/pico"
|
||||
BUILD_VERSION=
|
||||
|
||||
PICO_COMPOSER_NAME="pico-composer"
|
||||
PICO_COMPOSER_PROJECT="picocms/pico-composer"
|
||||
PICO_COMPOSER_DIR=
|
||||
|
||||
PICO_THEME_NAME="pico-theme"
|
||||
PICO_THEME_PROJECT="picocms/pico-theme"
|
||||
PICO_THEME_DIR=
|
||||
|
||||
PICO_DEPRECATED_NAME="pico-deprecated"
|
||||
PICO_DEPRECATED_PROJECT="picocms/pico-deprecated"
|
||||
PICO_DEPRECATED_DIR=
|
||||
|
||||
# options
|
||||
VERSION=
|
||||
NOCHECK=
|
||||
NOCLEAN=
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "$1" == "--help" ]; then
|
||||
echo "Usage:"
|
||||
echo " build.sh [OPTIONS]... [VERSION]"
|
||||
echo
|
||||
echo "Builds a new Pico release and creates release archives."
|
||||
echo
|
||||
echo "Help options:"
|
||||
echo " --help display this help and exit"
|
||||
echo
|
||||
echo "Application options:"
|
||||
echo " --pico-composer PATH path to a local copy of '$PICO_COMPOSER_PROJECT'"
|
||||
echo " --pico-theme PATH path to a local copy of '$PICO_THEME_PROJECT'"
|
||||
echo " --pico-deprecated PATH path to a local copy of '$PICO_DEPRECATED_PROJECT'"
|
||||
echo " --no-check skip version checks for dev builds"
|
||||
echo " --no-clean don't remove build dir on exit"
|
||||
echo
|
||||
echo "You must run this script from within Pico's source directory. Please note"
|
||||
echo "that this script will perform a large number of strict sanity checks before"
|
||||
echo "building a new non-development version of Pico. VERSION must start with 'v'."
|
||||
exit 0
|
||||
elif [ "$1" == "--no-check" ]; then
|
||||
NOCHECK="y"
|
||||
shift
|
||||
elif [ "$1" == "--no-clean" ]; then
|
||||
NOCLEAN="y"
|
||||
shift
|
||||
elif [ "$1" == "--pico-composer" ] && [ $# -ge 2 ]; then
|
||||
PICO_COMPOSER_DIR="$2"
|
||||
shift 2
|
||||
elif [ "$1" == "--pico-theme" ] && [ $# -ge 2 ]; then
|
||||
PICO_THEME_DIR="$2"
|
||||
shift 2
|
||||
elif [ "$1" == "--pico-deprecated" ] && [ $# -ge 2 ]; then
|
||||
PICO_DEPRECATED_DIR="$2"
|
||||
shift 2
|
||||
elif [ -z "$VERSION" ] && [ "${1:0:1}" == "v" ]; then
|
||||
VERSION="$1"
|
||||
shift
|
||||
else
|
||||
echo "Unknown option: $1" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# check options and current working dir
|
||||
if [ ! -f "./composer.json" ] || [ ! -f "./lib/Pico.php" ]; then
|
||||
echo "You must run this from within Pico's source directory" >&2
|
||||
exit 1
|
||||
elif [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
|
||||
echo "You must run this from within a non-bare Git repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$PICO_COMPOSER_DIR" ]; then
|
||||
if [ ! -f "$PICO_COMPOSER_DIR/composer.json" ] || [ ! -f "$PICO_COMPOSER_DIR/index.php" ]; then
|
||||
echo "You must pass a source directory of '$PICO_COMPOSER_PROJECT' as '--pico-composer': $PICO_COMPOSER_DIR" >&2
|
||||
exit 1
|
||||
elif [ "$(git -C "$PICO_COMPOSER_DIR" rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
|
||||
echo "You must pass a non-bare Git repository as '--pico-composer': $PICO_COMPOSER_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$PICO_THEME_DIR" ]; then
|
||||
if [ ! -f "$PICO_THEME_DIR/composer.json" ] || [ ! -f "$PICO_THEME_DIR/pico-theme.yml" ]; then
|
||||
echo "You must pass a source directory of '$PICO_THEME_PROJECT' as '--pico-theme': $PICO_THEME_DIR" >&2
|
||||
exit 1
|
||||
elif [ "$(git -C "$PICO_THEME_DIR" rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
|
||||
echo "You must pass a non-bare Git repository as '--pico-theme': $PICO_THEME_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$PICO_DEPRECATED_DIR" ]; then
|
||||
if [ ! -f "$PICO_DEPRECATED_DIR/composer.json" ] || [ ! -f "$PICO_DEPRECATED_DIR/PicoDeprecated.php" ]; then
|
||||
echo "You must pass a source directory of '$PICO_DEPRECATED_PROJECT' as '--pico-deprecated': $PICO_DEPRECATED_DIR" >&2
|
||||
exit 1
|
||||
elif [ "$(git -C "$PICO_DEPRECATED_DIR" rev-parse --is-inside-work-tree 2> /dev/null)" != "true" ]; then
|
||||
echo "You must pass a non-bare Git repository as '--pico-deprecated': $PICO_DEPRECATED_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# parse version
|
||||
function parse_version {
|
||||
VERSION_FULL="${1#v}"
|
||||
|
||||
if ! [[ "$VERSION_FULL" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z\.\-]+))?(\+([0-9A-Za-z\.\-]+))?$ ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
VERSION_MAJOR="${BASH_REMATCH[1]}"
|
||||
VERSION_MINOR="${BASH_REMATCH[2]}"
|
||||
VERSION_PATCH="${BASH_REMATCH[3]}"
|
||||
VERSION_SUFFIX="${BASH_REMATCH[5]}"
|
||||
|
||||
VERSION_STABILITY="stable"
|
||||
if [[ "$VERSION_SUFFIX" =~ ^(dev|a|alpha|b|beta|rc)?([.-]?[0-9]+)?([.-](dev))?$ ]]; then
|
||||
if [ "${BASH_REMATCH[1]}" == "dev" ] || [ "${BASH_REMATCH[4]}" == "dev" ]; then
|
||||
VERSION_STABILITY="dev"
|
||||
elif [ "${BASH_REMATCH[1]}" == "a" ] || [ "${BASH_REMATCH[1]}" == "alpha" ]; then
|
||||
VERSION_STABILITY="alpha"
|
||||
elif [ "${BASH_REMATCH[1]}" == "b" ] || [ "${BASH_REMATCH[1]}" == "beta" ]; then
|
||||
VERSION_STABILITY="beta"
|
||||
elif [ "${BASH_REMATCH[1]}" == "rc" ]; then
|
||||
VERSION_STABILITY="rc"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
BUILD_VERSION="v$("$PHP" -r 'require("./lib/Pico.php"); echo Pico::VERSION;')"
|
||||
|
||||
if ! parse_version "$BUILD_VERSION"; then
|
||||
echo "Unable to build Pico: Invalid Pico version '$BUILD_VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
GIT_LOCAL_HEAD="$(git rev-parse HEAD)"
|
||||
GIT_LOCAL_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
||||
DATETIME="$(date -u +'%Y%m%dT%H%M%SZ')"
|
||||
|
||||
VERSION="v$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
|
||||
[ -z "$VERSION_SUFFIX" ] || VERSION+="-$VERSION_SUFFIX"
|
||||
[ "$VERSION_STABILITY" == "dev" ] || VERSION+="-dev"
|
||||
VERSION+="+git.$GIT_LOCAL_HEAD.$DATETIME"
|
||||
|
||||
if ! parse_version "$VERSION"; then
|
||||
echo "Unable to build Pico: Invalid build version '$VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEPENDENCY_VERSION="dev-$GIT_LOCAL_BRANCH"
|
||||
else
|
||||
if ! parse_version "$VERSION"; then
|
||||
echo "Unable to build Pico: Invalid build version '$VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEPENDENCY_VERSION=
|
||||
if [ "$VERSION_STABILITY" == "dev" ]; then
|
||||
DEPENDENCY_VERSION="$(jq -r --arg ALIAS "$VERSION_MAJOR.$VERSION_MINOR.x-dev" \
|
||||
'.extra."branch-alias"|to_entries|map(select(.value==$ALIAS).key)[0]//empty' \
|
||||
"composer.json")"
|
||||
fi
|
||||
|
||||
if [ -z "$DEPENDENCY_VERSION" ]; then
|
||||
DEPENDENCY_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
|
||||
[ -z "$VERSION_SUFFIX" ] || DEPENDENCY_VERSION+="-$VERSION_SUFFIX"
|
||||
[ "$VERSION_STABILITY" == "stable" ] || DEPENDENCY_VERSION+="@$VERSION_STABILITY"
|
||||
fi
|
||||
fi
|
||||
|
||||
# build checks
|
||||
if [ "$VERSION_STABILITY" != "dev" ]; then
|
||||
GIT_LOCAL_CLEAN="$(git status --porcelain)"
|
||||
GIT_LOCAL_HEAD="$(git rev-parse HEAD)"
|
||||
GIT_LOCAL_TAG="$(git rev-parse --verify "refs/tags/$VERSION" 2> /dev/null || true)"
|
||||
GIT_REMOTE="$(git 'for-each-ref' --format='%(upstream:remotename)' "$(git symbolic-ref -q HEAD)")"
|
||||
GIT_REMOTE_TAG="$(git ls-remote "${GIT_REMOTE:-origin}" "refs/tags/$VERSION" 2> /dev/null | cut -f 1 || true)"
|
||||
|
||||
if [ "$VERSION" != "$BUILD_VERSION" ]; then
|
||||
echo "Unable to build Pico: Building $VERSION, but Pico indicates $BUILD_VERSION" >&2
|
||||
exit 1
|
||||
elif [ -n "$GIT_LOCAL_CLEAN" ]; then
|
||||
echo "Unable to build Pico: Building $VERSION, but the working tree is not clean" >&2
|
||||
exit 1
|
||||
elif [ -z "$GIT_LOCAL_TAG" ]; then
|
||||
echo "Unable to build Pico: Building $VERSION, but no matching local Git tag was found" >&2
|
||||
exit 1
|
||||
elif [ "$GIT_LOCAL_HEAD" != "$GIT_LOCAL_TAG" ]; then
|
||||
echo "Unable to build Pico: Building $VERSION, but the matching Git tag is not checked out" >&2
|
||||
exit 1
|
||||
elif [ -z "$GIT_REMOTE_TAG" ]; then
|
||||
echo "Unable to build Pico: Building $VERSION, but no matching remote Git tag was found" >&2
|
||||
exit 1
|
||||
elif [ "$GIT_LOCAL_TAG" != "$GIT_REMOTE_TAG" ]; then
|
||||
echo "Unable to build Pico: Building $VERSION, but the matching local and remote Git tags differ" >&2
|
||||
exit 1
|
||||
elif [ -n "$PICO_COMPOSER_DIR" ] || [ -n "$PICO_THEME_DIR" ] || [ -n "$PICO_DEPRECATED_DIR" ]; then
|
||||
echo "Unable to build Pico: Refusing to build a non-dev version with local dependencies" >&2
|
||||
exit 1
|
||||
fi
|
||||
elif [ -z "$NOCHECK" ]; then
|
||||
if [[ "$VERSION" != "$BUILD_VERSION"* ]]; then
|
||||
echo "Unable to build Pico: Building $VERSION, but Pico indicates $BUILD_VERSION" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# build in progress...
|
||||
APP_DIR="$PWD"
|
||||
|
||||
BUILD_DIR="$(mktemp -d)"
|
||||
[ -n "$NOCLEAN" ] || trap "rm -rf ${BUILD_DIR@Q}" ERR EXIT
|
||||
|
||||
echo "Building Pico $BUILD_VERSION ($VERSION)..."
|
||||
[ -z "$NOCLEAN" ] || echo "Build directory: $BUILD_DIR"
|
||||
echo
|
||||
|
||||
if [ "$VERSION_STABILITY" == "dev" ]; then
|
||||
# copy dev version of Pico
|
||||
echo "Creating clean working tree copy of '$BUILD_PROJECT'..."
|
||||
rsync -a \
|
||||
--exclude="/.build" \
|
||||
--exclude="/.git" \
|
||||
--exclude="/.github" \
|
||||
--exclude="/assets/.gitignore" \
|
||||
--exclude="/config/.gitignore" \
|
||||
--exclude="/content/.gitignore" \
|
||||
--exclude="/plugins/.gitignore" \
|
||||
--exclude="/themes/.gitignore" \
|
||||
--exclude="/.gitattributes" \
|
||||
--exclude="/.gitignore" \
|
||||
--exclude="/.phpcs.xml" \
|
||||
--exclude="/.phpdoc.xml" \
|
||||
--exclude-from=<(git ls-files --exclude-standard -oi --directory) \
|
||||
./ "$BUILD_DIR/$BUILD_NAME/"
|
||||
|
||||
# copy dev version of Composer starter project
|
||||
if [ -n "$PICO_COMPOSER_DIR" ]; then
|
||||
echo "Creating clean working tree copy of '$PICO_COMPOSER_PROJECT'..."
|
||||
rsync -a \
|
||||
--exclude="/.git" \
|
||||
--exclude="/assets/.gitignore" \
|
||||
--exclude="/config/.gitignore" \
|
||||
--exclude="/content/.gitignore" \
|
||||
--exclude="/plugins/.gitignore" \
|
||||
--exclude="/themes/.gitignore" \
|
||||
--exclude="/.gitattributes" \
|
||||
--exclude="/.gitignore" \
|
||||
--exclude-from=<(git -C "$PICO_COMPOSER_DIR" ls-files --exclude-standard -oi --directory) \
|
||||
"$PICO_COMPOSER_DIR/" "$BUILD_DIR/$PICO_COMPOSER_NAME/"
|
||||
fi
|
||||
|
||||
# copy dev version of default theme
|
||||
if [ -n "$PICO_THEME_DIR" ]; then
|
||||
echo "Creating clean working tree copy of '$PICO_THEME_PROJECT'..."
|
||||
rsync -a \
|
||||
--exclude="/.git" \
|
||||
--exclude="/.github" \
|
||||
--exclude="/.gitattributes" \
|
||||
--exclude="/.gitignore" \
|
||||
--exclude-from=<(git -C "$PICO_THEME_DIR" ls-files --exclude-standard -oi --directory) \
|
||||
"$PICO_THEME_DIR/" "$BUILD_DIR/$PICO_THEME_NAME/"
|
||||
fi
|
||||
|
||||
# copy dev version of PicoDeprecated
|
||||
if [ -n "$PICO_DEPRECATED_DIR" ]; then
|
||||
echo "Creating clean working tree copy of '$PICO_DEPRECATED_PROJECT'..."
|
||||
rsync -a \
|
||||
--exclude="/.build" \
|
||||
--exclude="/.git" \
|
||||
--exclude="/.github" \
|
||||
--exclude="/.gitattributes" \
|
||||
--exclude="/.gitignore" \
|
||||
--exclude="/.phpcs.xml" \
|
||||
--exclude-from=<(git -C "$PICO_DEPRECATED_DIR" ls-files --exclude-standard -oi --directory) \
|
||||
"$PICO_DEPRECATED_DIR/" "$BUILD_DIR/$PICO_DEPRECATED_NAME/"
|
||||
fi
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ "$VERSION_STABILITY" != "dev" ] || [ -z "$PICO_COMPOSER_DIR" ]; then
|
||||
PICO_COMPOSER_VERSION="$DEPENDENCY_VERSION"
|
||||
[[ "$PICO_COMPOSER_VERSION" == "dev-"* ]] || PICO_COMPOSER_VERSION="$VERSION_MAJOR.$VERSION_MINOR"
|
||||
|
||||
# download Composer starter project
|
||||
echo "Setting up Pico's Composer starter project (version '$PICO_COMPOSER_VERSION')..."
|
||||
"$COMPOSER" create-project --no-install "$PICO_COMPOSER_PROJECT" \
|
||||
"$BUILD_DIR/$PICO_COMPOSER_NAME" \
|
||||
"$PICO_COMPOSER_VERSION"
|
||||
echo
|
||||
fi
|
||||
|
||||
# switch to build dir...
|
||||
cd "$BUILD_DIR/$PICO_COMPOSER_NAME"
|
||||
|
||||
# inject local copy of Pico
|
||||
if [ "$VERSION_STABILITY" == "dev" ]; then
|
||||
function composer_repo_config {
|
||||
jq -nc --arg PACKAGE "$1" --arg VERSION "$2" --arg URL "$3" \
|
||||
'{"type": "path", "url": $URL, options: {"symlink": false, "versions": {($PACKAGE): $VERSION}}}'
|
||||
}
|
||||
|
||||
echo "Adding Composer repository for '$BUILD_PROJECT'..."
|
||||
"$COMPOSER" config repositories."$BUILD_NAME" \
|
||||
"$(composer_repo_config "$BUILD_PROJECT" "$DEPENDENCY_VERSION" "$BUILD_DIR/$BUILD_NAME")"
|
||||
|
||||
if [ -n "$PICO_THEME_DIR" ]; then
|
||||
echo "Adding Composer repository for '$PICO_THEME_PROJECT'..."
|
||||
"$COMPOSER" config repositories."$PICO_THEME_NAME" \
|
||||
"$(composer_repo_config "$PICO_THEME_PROJECT" "$DEPENDENCY_VERSION" "$BUILD_DIR/$PICO_THEME_NAME")"
|
||||
fi
|
||||
|
||||
if [ -n "$PICO_DEPRECATED_DIR" ]; then
|
||||
echo "Adding Composer repository for '$PICO_DEPRECATED_PROJECT'..."
|
||||
"$COMPOSER" config repositories."$PICO_DEPRECATED_NAME" \
|
||||
"$(composer_repo_config "$PICO_DEPRECATED_PROJECT" "$DEPENDENCY_VERSION" "$BUILD_DIR/$PICO_DEPRECATED_NAME")"
|
||||
fi
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
# update build version constraints
|
||||
echo "Updating Composer dependency version constraints..."
|
||||
"$COMPOSER" require --no-update \
|
||||
"$BUILD_PROJECT $DEPENDENCY_VERSION" \
|
||||
"$PICO_THEME_PROJECT $DEPENDENCY_VERSION" \
|
||||
"$PICO_DEPRECATED_PROJECT $DEPENDENCY_VERSION"
|
||||
echo
|
||||
|
||||
# set minimum stability
|
||||
if [ "$VERSION_STABILITY" != "stable" ]; then
|
||||
echo "Setting minimum stability to '$VERSION_STABILITY'..."
|
||||
"$COMPOSER" config "minimum-stability" "$VERSION_STABILITY"
|
||||
"$COMPOSER" config "prefer-stable" "true"
|
||||
echo
|
||||
fi
|
||||
|
||||
# install dependencies
|
||||
echo "Installing Composer dependencies..."
|
||||
"$COMPOSER" install --no-dev --optimize-autoloader
|
||||
echo
|
||||
|
||||
# prepare release
|
||||
echo "Replacing 'index.php'..."
|
||||
cp "vendor/$BUILD_PROJECT/index.php.dist" index.php
|
||||
|
||||
echo "Adding 'README.md', 'CONTRIBUTING.md', 'CHANGELOG.md', 'SECURITY.md'..."
|
||||
cp "vendor/$BUILD_PROJECT/README.md" README.md
|
||||
cp "vendor/$BUILD_PROJECT/CONTRIBUTING.md" CONTRIBUTING.md
|
||||
cp "vendor/$BUILD_PROJECT/CHANGELOG.md" CHANGELOG.md
|
||||
cp "vendor/$BUILD_PROJECT/SECURITY.md" SECURITY.md
|
||||
|
||||
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
|
||||
|
||||
echo "Removing '.git' directories of plugins and themes..."
|
||||
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 "Removing 'index.php' and 'index.php.dist' from 'vendor/$BUILD_PROJECT'"
|
||||
rm -f "vendor/$BUILD_PROJECT/index.php"
|
||||
rm -f "vendor/$BUILD_PROJECT/index.php.dist"
|
||||
echo
|
||||
|
||||
# restore composer.json
|
||||
echo "Restoring Composer dependency version constraints..."
|
||||
"$COMPOSER" require --no-update \
|
||||
"$BUILD_PROJECT ^$VERSION_MAJOR.$VERSION_MINOR" \
|
||||
"$PICO_THEME_PROJECT ^$VERSION_MAJOR.$VERSION_MINOR" \
|
||||
"$PICO_DEPRECATED_PROJECT ^$VERSION_MAJOR.$VERSION_MINOR"
|
||||
|
||||
if [ "$VERSION_STABILITY" == "dev" ]; then
|
||||
echo "Removing Composer repositories..."
|
||||
"$COMPOSER" config --unset repositories."$BUILD_NAME"
|
||||
|
||||
if [ -n "$PICO_THEME_DIR" ]; then
|
||||
"$COMPOSER" config --unset repositories."$PICO_THEME_NAME"
|
||||
fi
|
||||
if [ -n "$PICO_DEPRECATED_DIR" ]; then
|
||||
"$COMPOSER" config --unset repositories."$PICO_DEPRECATED_NAME"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
# create release archives
|
||||
ARCHIVE_FILENAME="$BUILD_NAME-release-$VERSION"
|
||||
|
||||
echo "Creating release archive '$ARCHIVE_FILENAME.tar.gz'..."
|
||||
find . -mindepth 1 -maxdepth 1 -printf '%f\0' \
|
||||
| xargs -0 -- tar -czf "$APP_DIR/$ARCHIVE_FILENAME.tar.gz" --
|
||||
|
||||
echo "Creating release archive '$ARCHIVE_FILENAME.zip'..."
|
||||
zip -q -r "$APP_DIR/$ARCHIVE_FILENAME.zip" .
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; }
|
||||
|
||||
# parameters
|
||||
ARCHIVE_DIR="${1:-$PICO_PROJECT_DIR}" # directory to create release archives in
|
||||
|
||||
# print parameters
|
||||
echo "Cleaning up build environment..."
|
||||
printf 'PICO_DEPLOY_DIR="%s"\n' "$PICO_DEPLOY_DIR"
|
||||
printf 'PICO_BUILD_DIR="%s"\n' "$PICO_BUILD_DIR"
|
||||
printf 'ARCHIVE_DIR="%s"\n' "$ARCHIVE_DIR"
|
||||
echo
|
||||
|
||||
echo "Removing deployment directory..."
|
||||
[ ! -d "$PICO_DEPLOY_DIR" ] || rm -rf "$PICO_DEPLOY_DIR"
|
||||
|
||||
echo "Removing build directory..."
|
||||
[ ! -d "$PICO_BUILD_DIR" ] || rm -rf "$PICO_BUILD_DIR"
|
||||
|
||||
echo "Removing release archives..."
|
||||
find "$ARCHIVE_DIR" -mindepth 1 -maxdepth 1 \
|
||||
\( -name 'pico-release-*.tar.gz' -o -name 'pico-release-*.zip' \) \
|
||||
-delete
|
|
@ -1,44 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; }
|
||||
|
||||
# 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"
|
|
@ -1,119 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; }
|
||||
|
||||
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
|
||||
|
||||
# parse version
|
||||
. "$PICO_TOOLS_DIR/functions/parse-version.sh.inc"
|
||||
|
||||
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_PROJECT_DIR" \
|
||||
"$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"
|
|
@ -1,19 +0,0 @@
|
|||
if [ -z "$PICO_BUILD_ENV" ]; then
|
||||
echo "No Pico build environment specified" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# add project build dir to $PATH
|
||||
export PATH="$PICO_PROJECT_DIR/.build:$PATH"
|
||||
|
||||
# set environment variables
|
||||
__picocms_cmd export RELEASE_REPO_SLUG="${RELEASE_REPO_SLUG:-picocms/pico-composer}"
|
||||
__picocms_cmd export RELEASE_REPO_BRANCH="${RELEASE_REPO_BRANCH:-master}"
|
||||
|
||||
if [ "$PROJECT_REPO_SLUG" != "picocms/Pico" ]; then
|
||||
__picocms_cmd export DEPLOY_REPO_SLUG="${DEPLOY_REPO_SLUG:-$PROJECT_REPO_SLUG}"
|
||||
__picocms_cmd export DEPLOY_REPO_BRANCH="${DEPLOY_REPO_BRANCH:-gh-pages}"
|
||||
else
|
||||
__picocms_cmd export DEPLOY_REPO_SLUG="${DEPLOY_REPO_SLUG:-picocms.github.io}"
|
||||
__picocms_cmd export DEPLOY_REPO_BRANCH="${DEPLOY_REPO_BRANCH:-master}"
|
||||
fi
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; }
|
||||
|
||||
# setup build system
|
||||
BUILD_REQUIREMENTS=( --phpcs )
|
||||
[ "$1" != "--deploy" ] || BUILD_REQUIREMENTS+=( --cloc --phpdoc3 )
|
||||
"$PICO_TOOLS_DIR/setup/$PICO_BUILD_ENV.sh" "${BUILD_REQUIREMENTS[@]}"
|
||||
|
||||
# set COMPOSER_ROOT_VERSION when necessary
|
||||
if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PROJECT_REPO_BRANCH" ]; then
|
||||
echo "Setting up Composer..."
|
||||
|
||||
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
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
# install dependencies
|
||||
echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..."
|
||||
composer install --no-suggest
|
|
@ -1,91 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; }
|
||||
|
||||
# parameters
|
||||
VERSION="${1:-$PROJECT_REPO_TAG}" # version to create a release for
|
||||
ARCHIVE_DIR="${2:-$PICO_PROJECT_DIR}" # directory to create release archives in
|
||||
|
||||
# print parameters
|
||||
echo "Creating new release..."
|
||||
printf 'VERSION="%s"\n' "$VERSION"
|
||||
echo
|
||||
|
||||
# guess version string
|
||||
if [ -z "$VERSION" ]; then
|
||||
PICO_VERSION="$(php -r "
|
||||
require_once('$PICO_PROJECT_DIR/lib/Pico.php');
|
||||
echo preg_replace('/-(?:dev|n|nightly)(?:[.-]?[0-9]+)?(?:[.-]dev)?$/', '', Pico::VERSION);
|
||||
")"
|
||||
|
||||
VERSION="v$PICO_VERSION-dev+${PROJECT_REPO_BRANCH:-master}"
|
||||
echo "Creating development release of Pico v$PICO_VERSION ($VERSION)..."
|
||||
echo
|
||||
fi
|
||||
|
||||
# parse version
|
||||
. "$PICO_TOOLS_DIR/functions/parse-version.sh.inc"
|
||||
|
||||
if ! parse_version "$VERSION"; then
|
||||
echo "Unable to create release archive: Invalid version '$VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEPENDENCY_VERSION="$VERSION_FULL@$VERSION_STABILITY"
|
||||
if [ "$VERSION_STABILITY" == "dev" ] && [ -n "$VERSION_BUILD" ]; then
|
||||
DEPENDENCY_VERSION="dev-$VERSION_BUILD"
|
||||
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 $DEPENDENCY_VERSION" \
|
||||
"picocms/pico-theme $DEPENDENCY_VERSION" \
|
||||
"picocms/pico-deprecated $DEPENDENCY_VERSION"
|
||||
echo
|
||||
|
||||
# force minimum stability <= beta due to Parsedown 1.8 currently being in beta
|
||||
if [ "$VERSION_STABILITY" == "stable" ] || [ "$VERSION_STABILITY" == "rc" ]; then
|
||||
VERSION_STABILITY="beta"
|
||||
fi
|
||||
|
||||
# set minimum stability
|
||||
if [ "$VERSION_STABILITY" != "stable" ]; then
|
||||
echo "Setting minimum stability to '$VERSION_STABILITY'..."
|
||||
composer config "minimum-stability" "$VERSION_STABILITY"
|
||||
composer config "prefer-stable" "true"
|
||||
echo
|
||||
fi
|
||||
|
||||
# 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 '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 "Removing '.git' directories of plugins and themes..."
|
||||
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 "Preparing 'composer.json' for release..."
|
||||
composer require --no-update \
|
||||
"picocms/pico ^$VERSION_MILESTONE" \
|
||||
"picocms/pico-theme ^$VERSION_MILESTONE" \
|
||||
"picocms/pico-deprecated ^$VERSION_MILESTONE"
|
||||
|
||||
# create release archives
|
||||
create-release.sh "$PICO_BUILD_DIR" "$ARCHIVE_DIR" "pico-release-v$VERSION_FULL"
|
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -9,4 +9,3 @@
|
|||
/.gitignore export-ignore
|
||||
/.phpcs.xml export-ignore
|
||||
/.phpdoc.xml export-ignore
|
||||
/.travis.yml export-ignore
|
||||
|
|
248
.github/workflows/deploy-release.yml
vendored
Normal file
248
.github/workflows/deploy-release.yml
vendored
Normal file
|
@ -0,0 +1,248 @@
|
|||
name: Git tag deployment
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: [ 'v*.*.*' ]
|
||||
|
||||
env:
|
||||
WEBSITE_REPO_SLUG: picocms/picocms.github.io
|
||||
WEBSITE_REPO_BRANCH: master
|
||||
CI_TOOLS_SETUP: https://raw.githubusercontent.com/picocms/ci-tools/master/setup.sh
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test Pico CMS
|
||||
uses: ./.github/workflows/test.yml
|
||||
|
||||
website:
|
||||
name: Update website for new releases
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
needs: test
|
||||
|
||||
env:
|
||||
PHP_VERSION: '7.4'
|
||||
BUILD_DIR: ./build
|
||||
WEBSITE_DIR: ./website
|
||||
CLOC_SOURCE: https://github.com/AlDanial/cloc/releases/download/1.92/cloc-1.92.pl
|
||||
|
||||
steps:
|
||||
- name: Setup CI tools
|
||||
run: |
|
||||
. <(curl -fsS -L "$CI_TOOLS_SETUP")
|
||||
echo "CI_TOOLS_PATH=$CI_TOOLS_PATH" | tee -a "$GITHUB_ENV"
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: ${{ env.BUILD_DIR }}
|
||||
|
||||
- name: Install Pico CMS
|
||||
uses: ./build/.github/actions/install
|
||||
with:
|
||||
path: ${{ env.BUILD_DIR }}
|
||||
php-version: ${{ env.PHP_VERSION }}
|
||||
php-tools: phpdoc
|
||||
|
||||
- name: Parse Pico version
|
||||
run: |
|
||||
. "$CI_TOOLS_PATH/parse_version.inc.sh"
|
||||
|
||||
if ! parse_version "$GITHUB_REF_NAME"; then
|
||||
echo "Invalid version string: $GITHUB_REF_NAME" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf '%s=%s\n' \
|
||||
"PICO_VERSION_FULL" "$VERSION_FULL" \
|
||||
"PICO_VERSION_STABILITY" "$VERSION_STABILITY" \
|
||||
"PICO_VERSION_MILESTONE" "$VERSION_MILESTONE" \
|
||||
| tee -a "$GITHUB_ENV"
|
||||
|
||||
- name: Checkout website repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ env.WEBSITE_REPO_SLUG }}
|
||||
ref: ${{ env.WEBSITE_REPO_BRANCH }}
|
||||
path: ${{ env.WEBSITE_DIR }}
|
||||
|
||||
#
|
||||
# Update phpDoc class docs
|
||||
#
|
||||
|
||||
- name: Update phpDoc class docs
|
||||
run: |
|
||||
"$CI_TOOLS_PATH/generate-phpdoc.sh" \
|
||||
"$BUILD_DIR/.phpdoc.xml" \
|
||||
"$WEBSITE_DIR/phpDoc/$GITHUB_REF_NAME" \
|
||||
"$WEBSITE_DIR/phpDoc/$GITHUB_REF_NAME/cache" \
|
||||
"Pico $PICO_VERSION_MILESTONE API Documentation ($GITHUB_REF_NAME)"
|
||||
|
||||
- name: Update phpDoc class docs list
|
||||
run: |
|
||||
"$CI_TOOLS_PATH/update-phpdoc-list.sh" \
|
||||
"$WEBSITE_DIR/_data/phpDoc.yml" \
|
||||
"$GITHUB_REF_NAME" "version" \
|
||||
"Pico $PICO_VERSION_FULL" "$(date +%s)"
|
||||
|
||||
- name: Commit phpDoc class docs updates
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
repository: ${{ env.WEBSITE_DIR }}
|
||||
file_pattern: >-
|
||||
phpDoc/${{ github.ref_name }}
|
||||
_data/phpDoc.yml
|
||||
commit_user_name: Pico CMS Bot
|
||||
commit_user_email: bot@picocms.org
|
||||
commit_message: >-
|
||||
Update phpDocumentor class docs
|
||||
for ${{ github.ref_name }}
|
||||
|
||||
#
|
||||
# Update version badge
|
||||
#
|
||||
|
||||
- name: Generate version badge
|
||||
if: ${{ env.PICO_VERSION_STABILITY == 'stable' }}
|
||||
run: |
|
||||
"$CI_TOOLS_PATH/generate-badge.sh" \
|
||||
"$WEBSITE_DIR/badges/pico-version.svg" \
|
||||
"release" "$PICO_VERSION_FULL" "blue"
|
||||
|
||||
- name: Commit version badge
|
||||
if: ${{ env.PICO_VERSION_STABILITY == 'stable' }}
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
repository: ${{ env.WEBSITE_DIR }}
|
||||
file_pattern: >-
|
||||
badges/pico-version.svg
|
||||
commit_user_name: Pico CMS Bot
|
||||
commit_user_email: bot@picocms.org
|
||||
commit_message: >-
|
||||
Update version badge for ${{ github.ref_name }}
|
||||
|
||||
#
|
||||
# Update version file
|
||||
#
|
||||
|
||||
- name: Update version file
|
||||
if: ${{ env.PICO_VERSION_STABILITY == 'stable' }}
|
||||
run: |
|
||||
"$CI_TOOLS_PATH/update-version-file.sh" \
|
||||
"$WEBSITE_DIR/_data/version.yml" \
|
||||
"$PICO_VERSION_FULL"
|
||||
|
||||
- name: Commit version file
|
||||
if: ${{ env.PICO_VERSION_STABILITY == 'stable' }}
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
repository: ${{ env.WEBSITE_DIR }}
|
||||
file_pattern: >-
|
||||
_data/version.yml
|
||||
commit_user_name: Pico CMS Bot
|
||||
commit_user_email: bot@picocms.org
|
||||
commit_message: >-
|
||||
Update version file for ${{ github.ref_name }}
|
||||
|
||||
#
|
||||
# Update cloc statistics
|
||||
#
|
||||
|
||||
- name: Install cloc
|
||||
if: ${{ env.PICO_VERSION_STABILITY == 'stable' }}
|
||||
run: |
|
||||
sudo curl -fsS -L -o "/usr/local/bin/cloc" "$CLOC_SOURCE"
|
||||
sudo chmod +x "/usr/local/bin/cloc"
|
||||
|
||||
- name: Update cloc statistics
|
||||
if: ${{ env.PICO_VERSION_STABILITY == 'stable' }}
|
||||
run: |
|
||||
"$CI_TOOLS_PATH/update-cloc-stats.sh" \
|
||||
"$WEBSITE_DIR/_data/cloc.yml" \
|
||||
"$BUILD_DIR/lib" \
|
||||
"$BUILD_DIR/index.php"
|
||||
|
||||
- name: Commit cloc statistics
|
||||
if: ${{ env.PICO_VERSION_STABILITY == 'stable' }}
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
repository: ${{ env.WEBSITE_DIR }}
|
||||
file_pattern: >-
|
||||
_data/cloc.yml
|
||||
commit_user_name: Pico CMS Bot
|
||||
commit_user_email: bot@picocms.org
|
||||
commit_message: >-
|
||||
Update cloc statistics for ${{ github.ref_name }}
|
||||
|
||||
deploy:
|
||||
name: Create Pico release
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
needs: test
|
||||
|
||||
env:
|
||||
PHP_VERSION: '7.2'
|
||||
|
||||
steps:
|
||||
- name: Setup CI tools
|
||||
run: |
|
||||
. <(curl -fsS -L "$CI_TOOLS_SETUP")
|
||||
echo "CI_TOOLS_PATH=$CI_TOOLS_PATH" | tee -a "$GITHUB_ENV"
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP ${{ env.PHP_VERSION }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ env.PHP_VERSION }}
|
||||
tools: composer
|
||||
|
||||
- name: Get Composer cache directory
|
||||
run: |
|
||||
COMPOSER_CACHE_DIR="$(composer config --global cache-dir)"
|
||||
echo "COMPOSER_CACHE_DIR=$COMPOSER_CACHE_DIR" | tee -a "$GITHUB_ENV"
|
||||
|
||||
- name: Restore Composer cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ env.COMPOSER_CACHE_DIR }}
|
||||
key: ${{ runner.os }}-composer-php${{ env.PHP_VERSION }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Parse Pico version
|
||||
run: |
|
||||
. "$CI_TOOLS_PATH/parse_version.inc.sh"
|
||||
|
||||
if ! parse_version "$GITHUB_REF_NAME"; then
|
||||
echo "Invalid version string: $GITHUB_REF_NAME" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf '%s=%s\n' \
|
||||
"PICO_VERSION_FULL" "$VERSION_FULL" \
|
||||
"PICO_VERSION_STABILITY" "$VERSION_STABILITY" \
|
||||
| tee -a "$GITHUB_ENV"
|
||||
|
||||
- name: Build Pico and create release archives
|
||||
run: |
|
||||
make build version="$GITHUB_REF_NAME"
|
||||
|
||||
- name: Create GitHub release and upload release archives
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: Version ${{ env.PICO_VERSION_FULL }}
|
||||
body: >-
|
||||
Pico ${{ github.ref_name }}
|
||||
prerelease: ${{ env.PICO_VERSION_STABILITY != 'stable' }}
|
||||
draft: true
|
||||
files: |
|
||||
pico-release-${{ github.ref_name }}.tar.gz
|
||||
pico-release-${{ github.ref_name }}.zip
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -3,8 +3,8 @@ name: Test Pico CMS
|
|||
on:
|
||||
push:
|
||||
branches: [ 'master' ]
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request: {}
|
||||
workflow_call: {}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,9 +15,6 @@ desktop.ini
|
|||
/vendor
|
||||
|
||||
# Build system
|
||||
/.build/build
|
||||
/.build/deploy
|
||||
/.build/ci-tools
|
||||
/pico-release-*.tar.gz
|
||||
/pico-release-*.zip
|
||||
|
||||
|
|
69
.travis.yml
69
.travis.yml
|
@ -1,69 +0,0 @@
|
|||
os: linux
|
||||
dist: bionic
|
||||
sudo: false
|
||||
|
||||
language: php
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache/files
|
||||
|
||||
jobs:
|
||||
include:
|
||||
# Test stage
|
||||
- php: 7.2
|
||||
- php: 7.3
|
||||
- php: 7.4
|
||||
- php: 8.0
|
||||
- php: 8.1
|
||||
- php: nightly
|
||||
|
||||
# Branch deployment stage
|
||||
- stage: deploy-branch
|
||||
if: type == "push" && tag IS blank
|
||||
php: 7.2
|
||||
install:
|
||||
- '[[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] || travis_terminate 0'
|
||||
- install.sh --deploy
|
||||
script:
|
||||
- deploy-branch.sh
|
||||
|
||||
# Release deployment stage
|
||||
- stage: deploy-release
|
||||
if: tag IS present
|
||||
php: 7.2
|
||||
install:
|
||||
- install.sh --deploy
|
||||
script:
|
||||
- '[ "$PROJECT_REPO_TAG" == "v$(php -r "require_once(\"lib/Pico.php\"); echo Pico::VERSION;")" ]'
|
||||
- deploy-release.sh
|
||||
before_deploy:
|
||||
- release.sh "$PROJECT_REPO_TAG"
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key: ${GITHUB_OAUTH_TOKEN}
|
||||
file:
|
||||
- pico-release-$PROJECT_REPO_TAG.tar.gz
|
||||
- pico-release-$PROJECT_REPO_TAG.zip
|
||||
skip_cleanup: true
|
||||
name: Version ${PROJECT_REPO_TAG:1}
|
||||
draft: true
|
||||
on:
|
||||
tags: true
|
||||
|
||||
# Ignore nightly build failures
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
fast_finish: true
|
||||
|
||||
before_install:
|
||||
- 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"
|
||||
- . "$PICO_PROJECT_DIR/.build/init.sh.inc"
|
||||
|
||||
install:
|
||||
- install.sh
|
||||
|
||||
script:
|
||||
- phpcs --standard=.phpcs.xml "$PICO_PROJECT_DIR"
|
|
@ -153,7 +153,7 @@ As soon as development reaches a point where feedback is appreciated, a pull req
|
|||
Build & Release process
|
||||
-----------------------
|
||||
|
||||
We're using [Travis CI](https://travis-ci.com) to automate the build & release process of Pico. It generates and deploys a [PHP class documentation](https://picocms.org/phpDoc/) (powered by [phpDoc](https://phpdoc.org)) for new releases and on every commit to the `master` branch. Travis also prepares new releases by generating Pico's pre-built release packages, a version badge, code statistics (powered by [cloc](https://github.com/AlDanial/cloc)) and updates our website (the [`picocms.github.io` repo](https://github.com/picocms/picocms.github.io)). Please refer to our [`.travis.yml`](https://github.com/picocms/Pico/blob/master/.travis.yml), the [`picocms/ci-tools` repo](https://github.com/picocms/ci-tools) and the [`.build` directory](https://github.com/picocms/Pico/tree/master/.build) for details.
|
||||
We use [GitHub Actions](https://github.com/picocms/Pico/actions) to automate the build & release process of Pico - also called [continous integration](https://en.wikipedia.org/wiki/Continuous_integration), or CI. With our CI pipeline we generate and deploy a [PHP class documentation](https://picocms.org/phpDoc/) (powered by [phpDoc](https://phpdoc.org)) for new releases and on every commit to the `master` branch. Our CI pipeline also prepares new releases by generating Pico's pre-built release packages, a version badge, code statistics (powered by [cloc](https://github.com/AlDanial/cloc)) and updates our website (the [`picocms.github.io` repo](https://github.com/picocms/picocms.github.io)). Please refer to the [`deploy-branch.yml` workflow](https://github.com/picocms/Pico/blob/master/.github/workflows/deploy-branch.yml), the [`deploy-release.yml` workflow](https://github.com/picocms/Pico/blob/master/.github/workflows/deploy-release.yml), the [`picocms/ci-tools` repo](https://github.com/picocms/ci-tools) and Pico's [`.build/build.sh` script](https://github.com/picocms/Pico/blob/master/.build/build.sh) for details.
|
||||
|
||||
As insinuated above, it is important that each commit to `master` is deployable. Once development of a new Pico release is finished, trigger Pico's build & release process by pushing a new Git tag. This tag should reference a (usually empty) commit on `master`, which message should adhere to the following template:
|
||||
|
||||
|
@ -171,7 +171,7 @@ Before pushing a new Git tag, make sure to update the `Pico::VERSION` and `Pico:
|
|||
|
||||
If you're pushing a new major or minor release of Pico, you should also update Pico's `composer.json` to require the latest minor releases of Pico's dependencies. Besides, don't forget to update the `@version` tags in the PHP class docs.
|
||||
|
||||
Travis CI will draft the new [release on GitHub](https://github.com/picocms/Pico/releases) automatically, but will require you to manually amend the descriptions formatting. The latest Pico version is always available at https://github.com/picocms/Pico/releases/latest, so please make sure to publish this URL rather than version-specific URLs. [Packagist](https://packagist.org/packages/picocms/pico) will be updated automatically.
|
||||
Our CI pipeline will draft the new [release on GitHub](https://github.com/picocms/Pico/releases) automatically, but will require you to manually amend the descriptions formatting. The latest Pico version is always available at https://github.com/picocms/Pico/releases/latest, so please make sure to publish this URL rather than version-specific URLs. [Packagist](https://packagist.org/packages/picocms/pico) will be updated automatically.
|
||||
|
||||
Labeling of Issues & Pull Requests
|
||||
----------------------------------
|
||||
|
|
51
Makefile
Normal file
51
Makefile
Normal file
|
@ -0,0 +1,51 @@
|
|||
# Pico -- Makefile
|
||||
# Makefile to build new Pico releases using './.build/build.sh'.
|
||||
#
|
||||
# This file is part of Pico, a stupidly simple, blazing fast, flat file CMS.
|
||||
# Visit us at https://picocms.org/ for more info.
|
||||
#
|
||||
# Copyright (c) 2022 Daniel Rudolf <https://www.daniel-rudolf.de>
|
||||
#
|
||||
# This work is licensed under the terms of the MIT license.
|
||||
# For a copy, see LICENSE file or <https://opensource.org/licenses/MIT>.
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# License-Filename: LICENSE
|
||||
|
||||
version?=
|
||||
nocheck?=false
|
||||
|
||||
php?=php
|
||||
composer?=composer
|
||||
|
||||
app_name=pico
|
||||
archive_tar=$(app_name)-release-*.tar.gz
|
||||
archive_zip=$(app_name)-release-*.zip
|
||||
export=$(app_name)-export.tar.gz
|
||||
|
||||
all: clean build
|
||||
|
||||
clean: clean-build clean-export
|
||||
|
||||
clean-build:
|
||||
find "." -name "$(archive_tar)" -exec rm -f {} \;
|
||||
find "." -name "$(archive_zip)" -exec rm -f {} \;
|
||||
|
||||
clean-export:
|
||||
rm -f "./$(export)"
|
||||
|
||||
build: export PHP=$(php)
|
||||
build: export COMPOSER=$(composer)
|
||||
build:
|
||||
./.build/build.sh$(if $(filter true,$(nocheck)), --no-check,)$(if $(version), "$(version)",)
|
||||
|
||||
export:
|
||||
git archive --prefix "$(app_name)/" -o "./$(export)" HEAD
|
||||
|
||||
composer:
|
||||
$(composer) install --optimize-autoloader --no-dev
|
||||
|
||||
.PHONY: all \
|
||||
clean clean-build clean-export \
|
||||
build export \
|
||||
composer
|
Loading…
Add table
Reference in a new issue