Skip to content

Commit

Permalink
Merge pull request #46 from pantheon-systems/release-0.3.0
Browse files Browse the repository at this point in the history
Release 0.3.0
  • Loading branch information
pwtyler authored Dec 20, 2023
2 parents 0d84082 + 77d169e commit 85789eb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 53 deletions.
43 changes: 0 additions & 43 deletions .bin/prepare-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,6 @@ source "${SELF_DIRNAME}/src/functions.sh"
readonly RELEASE_BRANCH="release"
readonly DEVELOP_BRANCH="main"

process_file(){
local FILE="${1:-}"
local OLD_VERSION="${2:-}"
local NEW_VERSION="${3:-}"
if [[ -z "${FILE}" ]] || [[ ! -f "$FILE" ]]; then
echo_info "No File '${FILE}'"
return
fi
echo "Checking file '${FILE}'..."
if [[ "$FILE" == "$BASE_DIR/package-lock.json" || "$FILE" == "$BASE_DIR/package.json" ]];then
echo_info "package and package-lock will be handled later."
return
fi
if [[ "$FILE" == "$BASE_DIR/composer.json" || "$FILE" == "$BASE_DIR/composer.lock" ]];then
echo_info "skip composer."
return
fi

shopt -s nocasematch # make the "if readme" case insensitive
for readme_extension in "txt" "md"; do
if [[ "$file" == "${BASE_DIR}/readme.${readme_extension}" ]]; then
echo_info "skipping readme"
continue
fi
done
shopt -u nocasematch

echo "search-and-replace with sed"
sed -i.tmp -e '/^\s*\* @since/!s/'"${OLD_VERSION}"'/'"${NEW_VERSION}"'/g' "$FILE" && rm "$FILE.tmp"

git add "$FILE"
}

main() {
local README_MD="${1:-}"
if [[ -z "$README_MD" ]]; then
Expand Down Expand Up @@ -86,21 +53,11 @@ main() {
echo "Updating ${CURRENT_VERSION} to ${NEW_DEV_VERSION}"
# Iterate through each file in the top-level directory
for file in "$BASE_DIR"/*; do
if [[ "$file" == "$README_MD" || "$file" == "$README_TXT" ]]; then
echo_info "Don't process readme [${file}]."
continue
fi
process_file "$file" "${CURRENT_VERSION}" "${NEW_DEV_VERSION}"
done

git_config

for readme in "$README_MD" "$README_TXT"; do
if [[ -f "${BASE_DIR}/${readme}" ]]; then
update_readme "${BASE_DIR}/${readme}" "${CURRENT_VERSION}" "${NEW_DEV_VERSION}"
fi
done

git commit -m "Prepare ${NEW_DEV_VERSION}"

if [[ -f "$BASE_DIR/package.json" ]]; then
Expand Down
44 changes: 38 additions & 6 deletions .bin/src/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,40 @@ git_config(){
git config user.name "${GIT_NAME}"
}


process_file(){
local FILE="${1:-}"
local OLD_VERSION="${2:-}"
local NEW_VERSION="${3:-}"
if [[ -z "${FILE}" ]] || [[ ! -f "$FILE" ]]; then
echo_info "No File '${FILE}'"
return
fi
# Convert the filename to lowercase for case-insensitive comparison
LC_FILE_PATH=$(echo "$FILE_PATH" | tr '[:upper:]' '[:lower:]')

echo "Processing file '${FILE}'..."
if [[ "$LC_FILE_PATH" == "$BASE_DIR/package-lock.json" || "$LC_FILE_PATH" == "$BASE_DIR/package.json" ]];then
echo_info "package and package-lock will be handled later [${FILE}]."
return
fi
if [[ "$LC_FILE_PATH" == "$BASE_DIR/composer.json" || "$LC_FILE_PATH" == "$BASE_DIR/composer.lock" ]];then
echo_info "skip composer [${FILE}]."
return
fi
if [[ "$LC_FILE_PATH" == *readme.* ]]; then
echo_info "Alternative readme Processing [${FILE}]."
update_readme "${FILE}" "${OLD_VERSION}" "${NEW_VERSION}"
echo_info "Skip futher readme sed"
return
fi

echo "search-and-replace with sed"
sed -i.tmp -e '/^\s*\* @since/!s/'"${OLD_VERSION}"'/'"${NEW_VERSION}"'/g' "$FILE" && rm "$FILE.tmp"

git add "$FILE"
}

update_readme(){
local FILE_PATH="${1:-}"
local OLD_VERSION="${2:-}"
Expand All @@ -43,12 +77,11 @@ update_readme(){
echo_error "usage: update_readme FILE_PATH OLD_VERSION NEW_VERSION"
return 1
fi

local EXTENSION=${FILE_PATH#"$BASE_DIR/readme."}

echo_info "adding new heading to readme.${EXTENSION}"
shopt -s nocasematch # make the "if" case insensitive
if [[ "$EXTENSION" == "md" ]]; then # there's gotta be a better way but whatever
# Convert the filename to lowercase for case-insensitive comparison
LC_FILE_PATH=$(echo "$FILE_PATH" | tr '[:upper:]' '[:lower:]')

if [[ "$LC_FILE_PATH" == *.md ]]; then
echo_info "markdown search-replace"
local new_heading="### ${NEW_VERSION}"
local awk_with_target='/## Changelog/ { print; print ""; print heading; print ""; next } 1'
Expand All @@ -57,7 +90,6 @@ update_readme(){
local new_heading="= ${NEW_VERSION} ="
local awk_with_target='/== Changelog ==/ { print; print ""; print heading; print ""; next } 1'
fi
shopt -u nocasematch

awk -v heading="$new_heading" "$awk_with_target" "$FILE_PATH" > tmp.md
mv tmp.md "$FILE_PATH"
Expand Down
6 changes: 5 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ Tags: comments, spam
Requires at least: 4.5
Tested up to: 6.2.1
Requires PHP: 5.6
Stable tag: 0.2.2
Stable tag: 0.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See the robots hard at work.

## Changelog

### 0.3.0 (20 December 2023)
* Set Second Counter to 2 [[#](https://github.com/pantheon-systems/plugin-pipeline-example/pull/#)]
* Add RUR_VERSION Constant [[#](https://github.com/pantheon-systems/plugin-pipeline-example/pull/#)]

### 0.2.2 (20 December 2023)
* Set Second Counter to 1 [[44](https://github.com/pantheon-systems/plugin-pipeline-example/pull/44)]

Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: comments, spam
Requires at least: 4.5
Tested up to: 6.2.1
Requires PHP: 5.6
Stable tag: 0.2.2
Stable tag: 0.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -68,6 +68,10 @@ directory take precedence. For example, `/assets/screenshot-1.png` would win ove

== Changelog ==

= 0.3.0 (20 December 2023) =
* Set Second Counter to 2 [[#](https://github.com/pantheon-systems/plugin-pipeline-example/pull/#)]
* Add RUR_VERSION Constant [[#](https://github.com/pantheon-systems/plugin-pipeline-example/pull/#)]

= 0.2.2 (20 December 2023) =
* Set Second Counter to 1 [[44](https://github.com/pantheon-systems/plugin-pipeline-example/pull/44)]

Expand Down
11 changes: 9 additions & 2 deletions rossums-universal-robots.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
* Author URI: pantheon.io
* Text Domain: rossums-universal-robots
* Domain Path: /languages
* Version: 0.2.2
* Version: 0.3.0
*
* @package Rossums_Universal_Robots
*/

/**
* This plugin's latest version.
*
* @since 0.3.0
*/
define( 'RUR_VERSION', '0.3.0' );

/**
* Returns an int. It's a feature.
*
Expand All @@ -29,5 +36,5 @@ function rur_counter() {
* @since 0.2.0
*/
function rur_another_counter() {
return 1;
return 2;
}

0 comments on commit 85789eb

Please sign in to comment.