Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Add version bump helper script #103

Merged
merged 8 commits into from
Jan 14, 2019
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
4 changes: 3 additions & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env sh

yarn && yarn build && zip -r ../benenson.zip . \
yarn \
&& yarn build \
&& zip -r ../benenson.zip . \
-x .\* \
-x CODE_OF_CONDUCT.md \
-x ISSUE_TEMPLATE.md \
Expand Down
53 changes: 53 additions & 0 deletions bin/version-bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env sh

# ./bin/bump.sh [<version>]
# <version> The version release version to increment.
# default: patch
# options: major|minor|patch
#
# Increments the package version by 1 across the following files:
# - /gulp/tasks/styles.js
# - /includes/scripts-and-styles.php
#
# EXAMPLE USAGE:
# ./bin/bump.sh minor

# escape a version number for sed
_v() {
echo "$(echo "$1" | tr -d '\n' | sed 's/\./\\\./g')";
}

# cross-compatible sed in-place
_sedi() {
isGnu=$(sed --version > /dev/null 2>&1)
if [ "$isGnu" ]; then
sed -i -- "$@"
else
sed -i "" "$@";
fi
}

_bump() {
bumptype="${1:-patch}"

# retrieve old version
oldversion=$(grep '^\tVersion: ' "$PWD/gulp/tasks/styles.js" | awk '{print $2}');

# bump it
case "$bumptype" in
major) newversion=$(echo "$oldversion" | awk '{split($NF,v,/[.]/); $NF=++v[1]"."v[2]"."v[3]}1');;
minor) newversion=$(echo "$oldversion" | awk '{split($NF,v,/[.]/); $NF=v[1]"."++v[2]"."v[3]}1');;
patch) newversion=$(echo "$oldversion" | awk '{split($NF,v,/[.]/); $NF=v[1]"."v[2]"."++v[3]}1');;
*) newversion=$(echo "$oldversion" | awk '{split($NF,v,/[.]/); $NF=v[1]"."v[2]"."++v[3]}1');;
esac

# escape versions for use in sed
oldversion=$(_v "$oldversion")
newversion=$(_v "$newversion")

# find/replace old/new versions in required files
_sedi "s/$oldversion/$newversion/g" "$PWD/gulp/tasks/styles.js";
_sedi "s/$oldversion/$newversion/g" "$PWD/includes/scripts-and-styles.php";
}

_bump "$1"
14 changes: 7 additions & 7 deletions includes/scripts-and-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function array_reverse_polyfill() {
return;
}

wp_enqueue_script( 'benenson-array-reverse', get_theme_file_uri( '/array-reverse-polyfill.js' ), [], '1.0.2', false );
wp_enqueue_script( 'benenson-array-reverse', get_theme_file_uri( '/array-reverse-polyfill.js' ), [], '1.0.3', false );
}

add_action( 'admin_enqueue_scripts', 'array_reverse_polyfill' );
Expand All @@ -50,11 +50,11 @@ function array_reverse_polyfill() {
*/
if ( ! function_exists( 'benenson_styles' ) ) {
function benenson_styles() {
wp_enqueue_style( 'global-styles', get_theme_file_uri( '/style.css' ), [], '1.0.2', 'all' );
wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css?family=Lato:300,400,700|Playfair+Display:400,600,700,700i,900,900i', [], '1.0.2' );
wp_enqueue_style( 'global-styles', get_theme_file_uri( '/style.css' ), [], '1.0.3', 'all' );
wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css?family=Lato:300,400,700|Playfair+Display:400,600,700,700i,900,900i', [], '1.0.3' );

if ( is_singular( 'post' ) || ! is_page_template( 'templates/without-sidebar' ) ) {
wp_enqueue_style( 'print-styles', get_theme_file_uri( '/print.css' ), [], '1.0.2', 'print' );
wp_enqueue_style( 'print-styles', get_theme_file_uri( '/print.css' ), [], '1.0.3', 'print' );
}
}
}
Expand All @@ -63,7 +63,7 @@ function benenson_styles() {

if ( ! function_exists( 'benenson_editor_styles' ) ) {
function benenson_editor_styles() {
wp_enqueue_style( 'benenson-blocks-css', get_theme_file_uri( '/style-editor.css' ), [], '1.0.2', 'all' );
wp_enqueue_style( 'benenson-blocks-css', get_theme_file_uri( '/style-editor.css' ), [], '1.0.3', 'all' );
}
}

Expand All @@ -79,10 +79,10 @@ function benenson_editor_styles() {
if ( ! function_exists( 'benenson_scripts' ) ) {
function benenson_scripts() {
if ( defined( 'ENABLE_LIVERELOAD' ) && ENABLE_LIVERELOAD ) {
wp_enqueue_script( 'livereload', 'https://livereload.bigbite.site:35729/livereload.js', [], '1.0.2', true );
wp_enqueue_script( 'livereload', 'https://livereload.bigbite.site:35729/livereload.js', [], '1.0.3', true );
}

wp_enqueue_script( 'global-scripts', get_theme_file_uri( '/bundle.js' ), [], '1.0.2', true );
wp_enqueue_script( 'global-scripts', get_theme_file_uri( '/bundle.js' ), [], '1.0.3', true );

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) && true === apply_filters( 'benenson_comments_enabled', false ) ) {
wp_enqueue_script( 'comment-reply' );
Expand Down