- Separate Travis branch deployment and release deployment stages (also makes `deploy.sh` obsolete) - Add `clean.sh` and `release.sh` scripts to allow users to create "release" packages locally - Use `setup/*.sh` scripts to check and install build dependencies (like PHP_CodeSniffer, phpDocumentor and cloc) - Use `create-release.sh` of `picocms/ci-tools` to create release archives - Streamline script usage Use the following to test Pico and to create a "release" package locally: ```sh cd ~/My-Pico-Workspace/Components/pico ln -rs ../ci-tools .build/ci-tools . ./.build/ci-tools/init/local.sh.inc . ./.build/init.sh.inc phpcs --standard=.phpcs.xml "$PICO_PROJECT_DIR" clean.sh release.sh ```pico-3.0-alpha
parent
7bbd8736d1
commit
58f615403e
@ -0,0 +1,25 @@ |
|||||||
|
#!/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,97 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
set -e |
|
||||||
|
|
||||||
export PATH="$PICO_TOOLS_DIR:$PATH" |
|
||||||
. "$PICO_TOOLS_DIR/functions/parse-version.sh.inc" |
|
||||||
|
|
||||||
# parameters |
|
||||||
ARCHIVE_DIR="$1" # directory to create release archives in |
|
||||||
ARCHIVE_FILENAME="$2" # release archive file name (without file extension) |
|
||||||
|
|
||||||
if [ -z "$ARCHIVE_DIR" ] || [ "$(realpath "$ARCHIVE_DIR")" == "$(realpath "$PICO_BUILD_DIR")" ]; then |
|
||||||
echo "Unable to create release archives: Invalid release archive target dir '$ARCHIVE_DIR'" >&2 |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
if [ -z "$ARCHIVE_FILENAME" ]; then |
|
||||||
echo "Unable to create release archives: No release archive file name given" >&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 |
|
||||||
|
|
||||||
# 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 "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 archives |
|
||||||
echo "Creating release archive '$ARCHIVE.tar.gz'..." |
|
||||||
|
|
||||||
if [ -e "$ARCHIVE_DIR/$ARCHIVE.tar.gz" ]; then |
|
||||||
echo "Unable to create release archive: File '$ARCHIVE.tar.gz' exists" >&2 |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
find . -mindepth 1 -maxdepth 1 -printf '%f\0' \ |
|
||||||
| xargs -0 -- tar -czf "$ARCHIVE_DIR/$ARCHIVE.tar.gz" -- |
|
||||||
echo |
|
||||||
|
|
||||||
echo "Creating release archive '$ARCHIVE.zip'..." |
|
||||||
|
|
||||||
if [ -e "$ARCHIVE_DIR/$ARCHIVE.zip" ]; then |
|
||||||
echo "Unable to create release archive: File '$ARCHIVE.zip' exists" >&2 |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
zip -q -r "$ARCHIVE_DIR/$ARCHIVE.zip" . |
|
||||||
echo |
|
@ -1,6 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
if [ -n "$PROJECT_REPO_TAG" ]; then |
|
||||||
exec "$(dirname "$0")/deploy-release.sh" |
|
||||||
else |
|
||||||
exec "$(dirname "$0")/deploy-branch.sh" |
|
||||||
fi |
|
@ -0,0 +1,19 @@ |
|||||||
|
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 |
@ -0,0 +1,86 @@ |
|||||||
|
#!/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 |
||||||
|
|
||||||
|
# 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" |
Loading…
Reference in new issue