setup for managing releases and updates

This commit is contained in:
Evan Mullins 2023-04-28 15:18:10 -04:00
parent 38dee18ffb
commit 186be74555
9 changed files with 366 additions and 6 deletions

22
.distignore Normal file
View file

@ -0,0 +1,22 @@
# Directories
.git
.github
/bin
node_modules
/src
tests
# Files
.distignore
.gitattributes
.gitignore
.nvm
# File Types
*.lock
*.log
*.sql
*.tar.gz
*.xml
*.yml
*.zip

84
.github/workflows/build-on-release.yml vendored Normal file
View file

@ -0,0 +1,84 @@
name: Package Pluginon Release
on:
release:
types:
- published
env:
VERSION: ${GITHUB_REF#refs/tags/*}
jobs:
build:
name: On Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Validate version number
if: ${{ (github.repository == 'circlecube/wasmo-theme') }}
run: |
taggedVersion=${{ env.VERSION }}
themeVersion=`grep "Version:" style.css | grep -Eo "[0-9\.]*"`
echo "Tagged version: $taggedVersion"
echo "Code version: $themeVersion"
[[ "$taggedVersion" == "$themeVersion" ]] || exit 1
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none
tools: composer, cs2pr
- name: Setup workflow context
id: workflow
working-directory: ${{ runner.temp }}
env:
REPO: ${{ github.repository }}
run: |
mkdir dist
echo "DIST=${PWD}/dist" >> $GITHUB_OUTPUT
echo "PACKAGE=${REPO##*/}" >> $GITHUB_OUTPUT
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer vendor directory
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Show versions
run: |
php --version
composer --version
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install PHP Dependencies
run: composer install --no-progress --no-dev --optimize-autoloader --prefer-dist
- name: Create Distribution Copy
run: rsync -r --exclude-from=.distignore . ${{ steps.workflow.outputs.DIST }}/${{ steps.workflow.outputs.PACKAGE }}
- name: List Distribution Files
working-directory: ${{ steps.workflow.outputs.DIST }}
run: find .
- name: Create Zip
working-directory: ${{ steps.workflow.outputs.DIST }}
run: zip -r ${{ steps.workflow.outputs.PACKAGE }}.zip .
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ github.event.release.tag_name }}" ${{ steps.workflow.outputs.DIST }}/${{ steps.workflow.outputs.PACKAGE }}.zip

5
.gitignore vendored
View file

@ -17,3 +17,8 @@ wp-content/plugins/hello.php
/sitemap.xml
/sitemap.xml.gz
# Composer
/vendor
#node_modules
/node_modules

20
composer.json Normal file
View file

@ -0,0 +1,20 @@
{
"name": "circlecube/wasmo-theme",
"description": "Theme for wasmormon.org",
"type": "wordpress-theme",
"require": {
"wp-forge/wp-update-handler": "^1.0"
},
"license": "GPL-2.0-or-later",
"autoload": {
"psr-4": {
"Circlecube\\WasmoTheme\\": "src/"
}
},
"authors": [
{
"name": "Evan Mullins",
"homepage": "https://evanmullins.com"
}
]
}

202
composer.lock generated Normal file
View file

@ -0,0 +1,202 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0778425a55b9b1d2200043269369964c",
"packages": [
{
"name": "doctrine/inflector",
"version": "1.4.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
"reference": "4bd5c1cdfcd00e9e2d8c484f79150f67e5d355d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/4bd5c1cdfcd00e9e2d8c484f79150f67e5d355d9",
"reference": "4bd5c1cdfcd00e9e2d8c484f79150f67e5d355d9",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^8.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Inflector\\": "lib/Doctrine/Inflector",
"Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.",
"homepage": "https://www.doctrine-project.org/projects/inflector.html",
"keywords": [
"inflection",
"inflector",
"lowercase",
"manipulation",
"php",
"plural",
"singular",
"strings",
"uppercase",
"words"
],
"support": {
"issues": "https://github.com/doctrine/inflector/issues",
"source": "https://github.com/doctrine/inflector/tree/1.4.4"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector",
"type": "tidelift"
}
],
"time": "2021-04-16T17:34:40+00:00"
},
{
"name": "wp-forge/helpers",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/wp-forge/helpers.git",
"reference": "59e97eeeba51f195f8f7478efb6820295ae218e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-forge/helpers/zipball/59e97eeeba51f195f8f7478efb6820295ae218e4",
"reference": "59e97eeeba51f195f8f7478efb6820295ae218e4",
"shasum": ""
},
"require": {
"doctrine/inflector": "^1.3",
"ext-mbstring": "*"
},
"type": "library",
"autoload": {
"files": [
"includes/functions.php"
],
"psr-4": {
"WP_Forge\\Helpers\\": "includes"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Micah Wood",
"email": "micah@wpscholar.com"
}
],
"description": "A collection of helpers for WordPress and PHP development.",
"support": {
"issues": "https://github.com/wp-forge/helpers/issues",
"source": "https://github.com/wp-forge/helpers/tree/1.1.1"
},
"time": "2021-07-15T11:41:27+00:00"
},
{
"name": "wp-forge/wp-update-handler",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/wp-forge/wp-update-handler.git",
"reference": "deb2beae787381158dc8c60b1cdcd241333a8784"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-forge/wp-update-handler/zipball/deb2beae787381158dc8c60b1cdcd241333a8784",
"reference": "deb2beae787381158dc8c60b1cdcd241333a8784",
"shasum": ""
},
"require": {
"wp-forge/helpers": "^1.1"
},
"require-dev": {
"wpscholar/phpcs-standards-wpscholar": "^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"WP_Forge\\WPUpdateHandler\\": "includes/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Micah Wood",
"email": "micah@wpscholar.com"
}
],
"description": "A WordPress package for updating custom plugins and themes based on an API response from a custom update server.",
"support": {
"issues": "https://github.com/wp-forge/wp-update-handler/issues",
"source": "https://github.com/wp-forge/wp-update-handler/tree/1.0.1"
},
"time": "2022-08-26T17:36:12+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
}

View file

@ -1,7 +1,9 @@
<?php
require __DIR__ . '/vendor/autoload.php';
require_once( get_stylesheet_directory() . '/includes/wasmo-directory-widget.php' );
require_once( get_stylesheet_directory() . '/includes/wasmo-posts-widget.php' );
require_once( get_stylesheet_directory() . '/includes/updates.php' );
// register Foo_Widget widget
function register_wasmo_widgets() {
@ -1650,4 +1652,5 @@ function wasmo_get_icon_svg( $icon, $size = 24, $styles = '' ) {
return null;
}
remove_filter('term_description','wpautop');
remove_filter('term_description','wpautop');

24
includes/updates.php Normal file
View file

@ -0,0 +1,24 @@
<?php
use WP_Forge\WPUpdateHandler\ThemeUpdater;
// Updater
$theme = wp_get_theme( 'wasmo-theme' );
$url = 'https://api.github.com/repos/circlecube/wasmo-theme/releases/latest';
// Handle plugin updates
$wasmoThemeUpdater = new ThemeUpdater( $theme, $url );
$wasmoThemeUpdater->setDataMap(
array(
'version' => 'tag_name',
'download_link' => 'zipball_url',
'last_updated' => 'published_at',
)
);
$wasmoThemeUpdater->setDataOverrides(
array(
'requires' => '6.2',
'requires_php' => '8.0',
'tested' => '6.2',
)
);

View file

@ -1,11 +1,11 @@
/*!
Theme Name: wasmormon.org
Theme Name: wasmo-theme
Theme URI: https://wasmormon.org
Description: Theme for the wasmormon.org profile site
Author: Evan Mullins
Author URI: https://circlecube.com
Template: twentynineteen
Version: 1.13.5
Version: 1.14.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wasmo

View file

@ -2,9 +2,9 @@
// Get vars from query
$context = get_query_var( 'context' );
$max_profiles = get_query_var( 'max_profiles' );
$tax = get_query_var('tax');
$termid = get_query_var('termid');
$paged = get_query_var('paged');
$tax = get_query_var( 'tax' );
$termid = get_query_var( 'termid' );
$paged = get_query_var( 'paged' );
// Initialize the remaining vars
$offset = 0;
if ( empty( $context ) ) {