Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Prepare & Deploy a Release

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
WC_DEVELOP_REPO: git@github.com:woocommerce/woocommerce.git
WC_PHPUNIT_REPO: git@github.com:ndigitals/wc-phpunit.git
PHP_VERSION: '7.4'
COMPOSER_VERSION: '2.2'
ACTION_VERSION: 1

jobs:
release:
name: New Release

if: github.repository == 'ndigitals/wc-phpunit-build'

runs-on: ubuntu-latest

steps:
- name: Checkout Code
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
if: ${{ !env.ACT }}
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer dependencies
if: ${{ !env.ACT }}
# https://github.com/marketplace/actions/cache
uses: actions/cache@v2
env:
composer-cache-name: cache-composer
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-${{ env.COMPOSER_VERSION }}-php-${{ env.PHP_VERSION }}-v${{ env.ACTION_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.composer-cache-name }}-wp-${{ matrix.wordpress-version }}-wc-${{ matrix.woocommerce-version }}-v${{ env.ACTION_VERSION }}-

- name: Setup PHP & Composer Environment
# https://github.com/marketplace/actions/setup-php-action
uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.PHP_VERSION }}"
tools: "composer:${{ env.COMPOSER_VERSION }}"

- name: Environment Check
run: php -v && composer --version

- name: Install Composer Dependencies
run: composer install --no-dev --prefer-dist

- name: Build WC PHPUnit Release
run: bin/build

- name: Deploy WC PHPUnit Release
run: bin/deploy

8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
/repos/
/build/*
!/build/.gitkeep
/artifacts/
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# wc-phpunit-build
The project for automating the build of the ndigitals/wc-phpunit package. Builds new WooCommerce releases daily via GitHub Actions.
# WC PHPUnit Build

This repository builds and maintains [`wc-phpunit`](https://github.com/ndigitals/wc-phpunit).
Builds run daily via GitHub Actions to add new WooCommerce releases to the package.

## Credits

This project is modeled directly after the [wp-phpunit](https://github.com/wp-phpunit/build)
build project.
83 changes: 83 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

set -e

# The name that should be used for commits to the package
GIT_NAME=${GIT_NAME-}
# The email that should be used for commits to the package
GIT_EMAIL=${GIT_EMAIL-}
# The git URL to the WooCommerce development repository
WC_DEVELOP_REPO=${WC_DEVELOP_REPO-}
# The git URL to the target WC PHPUnit package
WP_PHPUNIT_REPO=${WC_PHPUNIT_REPO-}

if [ ! -d repos ]; then
echo "This script must be run from the project root."
exit 1
elif [ ! ${WC_DEVELOP_REPO} ]; then
echo "No git path provided for WC_DEVELOP_REPO."
exit 1
elif [ ! ${WC_PHPUNIT_REPO} ]; then
echo "No git path provided for WC_PHPUNIT_REPO."
exit 1
fi

function sync_repo() {
git remote rm origin
git remote add origin ${1}
git remote -v
git fetch origin --tags
git checkout trunk --force
git branch -u origin/trunk
git pull origin trunk
}

if [ ! -d repos/woocommerce/.git ]; then
echo "Cloning ${WP_DEVELOP_REPO} ..."
git clone ${WP_DEVELOP_REPO} repos/woocommerce
else
echo "Repository exists, synchronizing with origin..."
(
cd repos/woocommerce
sync_repo ${WC_DEVELOP_REPO}
)
fi

if [ ! -d repos/package/.git ]; then
echo "Cloning ${WC_PHPUNIT_REPO} ..."
git clone ${WC_PHPUNIT_REPO} repos/package
else
echo "Repository exists, synchronizing with origin..."
(
cd repos/package
sync_repo ${WC_PHPUNIT_REPO}
)
fi

(
cd repos/package

git config core.autocrlf false

if [ ${GIT_NAME} ]; then
git config user.name ${GIT_NAME}
fi
if [ ${GIT_EMAIL} ]; then
git config user.email ${GIT_EMAIL}
fi
)

# Check the validity of the package's composer.json
composer validate --working-dir=template

# Lint all PHP files in the package template
for file in $(find template -name '*.php'); do
php -l ${file}
done

git --git-dir=repos/package/.git tag > build/tags-before

php src/build.php

git --git-dir=repos/package/.git tag > build/tags-after
./bin/diff-tags
7 changes: 7 additions & 0 deletions bin/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e

cd repos/package
git push -u origin --all
git push -u origin --tags
5 changes: 5 additions & 0 deletions bin/diff-tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#/usr/env/bin bash

git diff --no-index build/tags-before build/tags-after

exit 0
Empty file added build/.gitkeep
Empty file.
40 changes: 40 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "ndigitals/wc-phpunit-build",
"description": "The project for building and maintaining the wc-phpunit package.",
"type": "project",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Tim Nolte",
"email": "tim.nolte@ndigitals.com"
}
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"autoload": {
"psr-4": {
"Build\\": "src"
}
},
"scripts": {
"clean": "rm -rf build/* repos/package repos/wordpress",
"build": "bin/build"
},
"require": {
"comodojo/zip": "^3.1",
"composer/semver": "^3.3",
"illuminate/container": "^8.83",
"illuminate/support": "^8.83",
"kzykhys/git": "^0.1.2",
"monolog/monolog": "^1.0",
"symfony/filesystem": "^5.4",
"symfony/finder": "^5.4",
"symfony/options-resolver": "^5.4",
"symfony/process": "^5.4"
},
"require-dev": {
"symfony/var-dumper": "^5.4"
}
}
Loading