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
88 changes: 55 additions & 33 deletions .bin/prepare-dev.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash
set -eou pipefail
set -x
IFS=$'\n\t'

if [[ "${DRY_RUN:-}" == 1 ]]; then
echo "Dry Run. Will not Push."
fi

# shellcheck disable=SC2155
readonly SELF_DIRNAME="$(dirname -- "$0")"
readonly BASE_DIR="${SELF_DIRNAME}/.."
Expand Down Expand Up @@ -29,42 +34,42 @@ process_file(){
return
fi
echo "Checking file '${file}'..."
if [[ "$file" = "$BASE_DIR/package-lock.json" ]];then
# skip package-lock and let `npm i` do it when package.json is processed.
echo "skipping sed of package lock"
if [[ "$file" == "$BASE_DIR/package-lock.json" ]];then
echo "package and package-lock will be handled later."
return
fi

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

git add "$file"
}

shopt -s nocasematch # make the "if readme" case insensitive
local file_name=${file#"$BASE_DIR/"}
if [[ "$file_name" == "readme.txt" || "$file_name" == "readme.md" ]]; then
echo "adding new heading"
if [[ "$file_name" == "readme.txt" ]]; then # there's gotta be a better way but whatever
local new_heading="### ${NEW_DEV_VERSION}"
local awk_with_target='/## Changelog/ { print; print ""; print heading; print ""; next } 1'
else
local new_heading="= ${NEW_DEV_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" > tmp.md
mv tmp.md "$file"
git add "$file"
return
git_config(){
git config user.email "${GIT_USER}"
git config user.name "${GIT_NAME}"
}

update_readme(){
FILE_PATH="$1:-"
if [[ -z "${FILE_PATH}" ]]; then
echo "missing file path"
return 1
fi

echo "search-and-replace with sed"
# Use `sed` to perform the search and replace operation in each file
sed -i.tmp -e "s/${CANONICAL_VERSION}/${NEW_DEV_VERSION}/g" "$file" && rm "$file.tmp"
if [[ "$file" == "$BASE_DIR/package.json" ]];then
# TODO: This seems unsafe as we might update dependencies as well.
# Is it safe to just sed package-lock instead? That also seems wrong.
echo "running 'npm i --package-lock-only' to update package-lock.json"
npm i --package-lock-only
git add "$BASE_DIR/package-lock.json"
local EXTENSION=${file#"$BASE_DIR/readme."}

echo "adding new heading to readme.${EXTENSION}"

if [[ "$EXTENSION" == "md" ]]; then # there's gotta be a better way but whatever
local new_heading="### ${NEW_DEV_VERSION}"
local awk_with_target='/## Changelog/ { print; print ""; print heading; print ""; next } 1'
else
local new_heading="= ${NEW_DEV_VERSION} ="
local awk_with_target='/== Changelog ==/ { print; print ""; print heading; print ""; next } 1'
fi
awk -v heading="$new_heading" "$awk_with_target" "$FILE_PATH" > tmp.md
mv tmp.md "$file"

git add "$file"
}
Expand All @@ -74,9 +79,11 @@ main() {
CANONICAL_VERSION="$(grep 'Stable tag:' < "${CANONICAL_FILE}" | awk '{print $3}')"

# fetch all tags and history:
git fetch --tags --unshallow --prune
if ! git rev-parse --is-shallow-repository > /dev/null; then
git fetch --tags --unshallow --prune
fi

if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
if ! git show-ref --quiet refs/heads/main && [[ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]]; then
git branch --track main origin/main
fi

Expand All @@ -94,11 +101,26 @@ main() {
for file in "$BASE_DIR"/*; do
process_file "$file"
done
# Who am I?
git config user.email "${GIT_USER}"
git config user.name "${GIT_NAME}"

git_config

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

git commit -m "Prepare ${NEW_DEV_VERSION}"

if [[ -f "$BASE_DIR/package.json" ]]; then
npm version "${NEW_DEV_VERSION}" --no-git-tag-version
fi

if [[ "${DRY_RUN:-}" == 1 ]]; then
return
fi
git push origin "${DEVELOP_BRANCH}"
}

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.1.3
Stable tag: 0.2.0-dev
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See the robots hard at work.

## Changelog

### 0.2.0-dev
* Set Counter to 4 [[37](https://github.com/pantheon-systems/plugin-pipeline-example/pull/37)]
* Add another counter [[37](https://github.com/pantheon-systems/plugin-pipeline-example/pull/37)]

### 0.1.3 (19 December 2023)
* Set Counter to 3 [[37](https://github.com/pantheon-systems/plugin-pipeline-example/pull/37)]

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugin-pipeline-example",
"version": "0.1.4-dev",
"version": "0.2.0-dev",
"description": "A demo plugin to test and showcase github actions during plugin development and release",
"main": "Gruntfile.js",
"directories": {
Expand Down Expand Up @@ -32,4 +32,4 @@
"grunt-sass": "^3.1.0",
"node-sass": "^9.0.0"
}
}
}
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.1.3
Stable tag: 0.2.0-dev
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.2.0-dev =
* Set Counter to 4 [[37](https://github.com/pantheon-systems/plugin-pipeline-example/pull/37)]
* Add another counter [[37](https://github.com/pantheon-systems/plugin-pipeline-example/pull/37)]

= 0.1.3 (19 December 2023) =
* Set Counter to 3 [[37](https://github.com/pantheon-systems/plugin-pipeline-example/pull/37)]

Expand Down
16 changes: 13 additions & 3 deletions rossums-universal-robots.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author URI: pantheon.io
* Text Domain: rossums-universal-robots
* Domain Path: /languages
* Version: 0.1.4-dev
* Version: 0.2.0-dev
*
* @package Rossums_Universal_Robots
*/
Expand All @@ -16,8 +16,18 @@
* Returns an int. It's a feature.
*
* @return int An integer.
* @since 0.1.4-dev
* @since 0.1.1
*/
function rur_counter() {
return 3;
return 4;
}

/**
* Returns a different int. It's another feature.
*
* @return int An integer.
* @since 0.2.0-dev
*/
function rur_another_counter() {
return 0;
}