From aafedc075e00a0fc3512dccc4b2437e81fd5a1e3 Mon Sep 17 00:00:00 2001 From: Ramakrishna Sakhamuru Date: Wed, 24 Jun 2026 19:02:16 +0530 Subject: [PATCH 1/2] scripts to make releases --- release_scripts/release_develop_branch.sh | 135 +++++++++++++++++++ release_scripts/release_hotfix_branch.sh | 139 ++++++++++++++++++++ release_scripts/release_static_pages.sh | 153 ++++++++++++++++++++++ 3 files changed, 427 insertions(+) create mode 100755 release_scripts/release_develop_branch.sh create mode 100755 release_scripts/release_hotfix_branch.sh create mode 100755 release_scripts/release_static_pages.sh diff --git a/release_scripts/release_develop_branch.sh b/release_scripts/release_develop_branch.sh new file mode 100755 index 0000000..8c9b193 --- /dev/null +++ b/release_scripts/release_develop_branch.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +# Release script for updated develop branch +# For every step, takes confirmation from the user before executing + +set -e + +confirm() { + local msg="$1" + echo "" + echo ">>> $msg" + read -p "Proceed? (y/n): " choice + case "$choice" in + y|Y ) return 0 ;; + * ) echo "Skipped."; return 1 ;; + esac +} + +# Determine the repository directory +if [ -n "$RELEASE_REPO_LOCATION" ]; then + echo "Found RELEASE_REPO_LOCATION environment variable: $RELEASE_REPO_LOCATION" + read -p "Use this location? (y/n): " use_env + if [[ "$use_env" =~ ^[yY]$ ]]; then + REPO_DIR="$RELEASE_REPO_LOCATION" + else + read -p "Enter the repository directory path: " REPO_DIR + fi +else + read -p "Enter the repository directory path: " REPO_DIR +fi +if [ ! -d "$REPO_DIR" ]; then + echo "Error: Directory '$REPO_DIR' does not exist." + exit 1 +fi + +# Ask for the release branch name +read -p "Enter the release branch name (e.g. 2015-02-03_1702_release_name): " RELEASE_NAME +if [ -z "$RELEASE_NAME" ]; then + echo "Error: release branch name cannot be empty." + exit 1 +fi + +# cd to repository directory +if confirm "cd to repository directory: $REPO_DIR"; then + cd "$REPO_DIR" + echo "Changed to $(pwd)" +fi + +# Checkout develop and pull +if confirm "git checkout develop"; then + git checkout develop +fi + +if confirm "git pull (develop)"; then + git pull +fi + +# Checkout master and pull +if confirm "git checkout master"; then + git checkout master +fi + +if confirm "git pull (master)"; then + git pull +fi + +# Create release branch +if confirm "git flow release start $RELEASE_NAME"; then + git flow release start $RELEASE_NAME +fi + +# Review latest commits +if confirm "Review latest commits in the release (git log -p release/branch -5)"; then + git log -p release/$RELEASE_NAME -5 +fi + +# Show diff of files changed +if confirm "Show files changed: git diff master release/$RELEASE_NAME --name-only"; then + git diff master "release/$RELEASE_NAME" --name-only +fi + +# Check for JS/CSS changes and optionally update version +echo "" +echo ">>> Checking for JS or CSS file changes..." +JS_CSS_CHANGES=$(git diff master "release/$RELEASE_NAME" --name-only | grep -E '\.(js|css)$' || true) + +if [ -n "$JS_CSS_CHANGES" ]; then + echo "JS/CSS changes detected:" + echo "$JS_CSS_CHANGES" + echo "" + echo "You need to update the version in setup.py and portality/settings.py" + + if confirm "Edit setup.py to update DOAJ_VERSION"; then + ${EDITOR:-vi} setup.py + fi + + if confirm "Edit portality/settings.py to update version"; then + ${EDITOR:-vi} portality/settings.py + fi + + if confirm "Commit version changes"; then + git add setup.py portality/settings.py + git commit -m "Update DOAJ_VERSION for release" + fi +else + echo "No JS/CSS changes detected. Version update not required." +fi + +# Finish release +if confirm "git flow release finish $RELEASE_NAME"; then + git flow release finish "$RELEASE_NAME" +fi + +# Push develop +if confirm "git push (current branch)"; then + git push +fi + +# Checkout master and push +if confirm "git checkout master && git push"; then + git checkout master + git push +fi + +# Push tags +if confirm "git push --tags"; then + git push --tags +fi + +echo "" +echo "=== develop release complete! ===" +echo "" +echo "#### from the doaj folder in the 'sysadmin' repo, run the command:" +echo "#### ansible-playbook -i doaj-hosts.ini update-site.yml" +echo "" diff --git a/release_scripts/release_hotfix_branch.sh b/release_scripts/release_hotfix_branch.sh new file mode 100755 index 0000000..c84b4c0 --- /dev/null +++ b/release_scripts/release_hotfix_branch.sh @@ -0,0 +1,139 @@ +#!/bin/bash + +# Release script for updated hotfix branch +# For every step, takes confirmation from the user before executing + +set -e + +confirm() { + local msg="$1" + echo "" + echo ">>> $msg" + read -p "Proceed? (y/n): " choice + case "$choice" in + y|Y ) return 0 ;; + * ) echo "Skipped."; return 1 ;; + esac +} + +# Determine the repository directory +if [ -n "$RELEASE_REPO_LOCATION" ]; then + echo "Found RELEASE_REPO_LOCATION environment variable: $RELEASE_REPO_LOCATION" + read -p "Use this location? (y/n): " use_env + if [[ "$use_env" =~ ^[yY]$ ]]; then + REPO_DIR="$RELEASE_REPO_LOCATION" + else + read -p "Enter the repository directory path: " REPO_DIR + fi +else + read -p "Enter the repository directory path: " REPO_DIR +fi +if [ ! -d "$REPO_DIR" ]; then + echo "Error: Directory '$REPO_DIR' does not exist." + exit 1 +fi + +# Ask for the hotfix branch name +read -p "Enter the hotfix branch name (e.g. 2015-02-03_1702_hotfix_name): " HOTFIX_NAME +if [ -z "$HOTFIX_NAME" ]; then + echo "Error: Hotfix branch name cannot be empty." + exit 1 +fi + +# cd to repository directory +if confirm "cd to repository directory: $REPO_DIR"; then + cd "$REPO_DIR" + echo "Changed to $(pwd)" +fi + +# Checkout develop and pull +if confirm "git checkout develop"; then + git checkout develop +fi + +if confirm "git pull (develop)"; then + git pull +fi + +# Checkout master and pull +if confirm "git checkout master"; then + git checkout master +fi + +if confirm "git pull (master)"; then + git pull +fi + +# Checkout hotfix branch and merge static_pages +if confirm "git checkout hotfix/$HOTFIX_NAME"; then + git checkout "hotfix/$HOTFIX_NAME" +fi + +if confirm "git pull"; then + git pull +fi + +# Review latest commits +if confirm "Review latest commits in the hotfix (git log -p hotfix/branch -5)"; then + git log -p hotfix/$HOTFIX_NAME -5 +fi + +# Show diff of files changed +if confirm "Show files changed: git diff master hotfix/$HOTFIX_NAME --name-only"; then + git diff master "hotfix/$HOTFIX_NAME" --name-only +fi + +# Check for JS/CSS changes and optionally update version +echo "" +echo ">>> Checking for JS or CSS file changes..." +JS_CSS_CHANGES=$(git diff master "hotfix/$HOTFIX_NAME" --name-only | grep -E '\.(js|css)$' || true) + +if [ -n "$JS_CSS_CHANGES" ]; then + echo "JS/CSS changes detected:" + echo "$JS_CSS_CHANGES" + echo "" + echo "You need to update the version in setup.py and portality/settings.py" + + if confirm "Edit setup.py to update DOAJ_VERSION"; then + ${EDITOR:-vi} setup.py + fi + + if confirm "Edit portality/settings.py to update version"; then + ${EDITOR:-vi} portality/settings.py + fi + + if confirm "Commit version changes"; then + git add setup.py portality/settings.py + git commit -m "Update DOAJ_VERSION for hotfix" + fi +else + echo "No JS/CSS changes detected. Version update not required." +fi + +# Finish hotfix +if confirm "git flow hotfix finish $HOTFIX_NAME"; then + git flow hotfix finish "$HOTFIX_NAME" +fi + +# Push develop +if confirm "git push (current branch)"; then + git push +fi + +# Checkout master and push +if confirm "git checkout master && git push"; then + git checkout master + git push +fi + +# Push tags +if confirm "git push --tags"; then + git push --tags +fi + +echo "" +echo "=== hotfix release complete! ===" +echo "" +echo "#### from the doaj folder in the 'sysadmin' repo, run the command:" +echo "#### ansible-playbook -i doaj-hosts.ini update-site.yml" +echo "" diff --git a/release_scripts/release_static_pages.sh b/release_scripts/release_static_pages.sh new file mode 100755 index 0000000..31461c2 --- /dev/null +++ b/release_scripts/release_static_pages.sh @@ -0,0 +1,153 @@ +#!/bin/bash + +# Release script for updated static_pages +# For every step, takes confirmation from the user before executing + +set -e + +confirm() { + local msg="$1" + echo "" + echo ">>> $msg" + read -p "Proceed? (y/n): " choice + case "$choice" in + y|Y ) return 0 ;; + * ) echo "Skipped."; return 1 ;; + esac +} + +# Determine the repository directory +if [ -n "$RELEASE_REPO_LOCATION" ]; then + echo "Found RELEASE_REPO_LOCATION environment variable: $RELEASE_REPO_LOCATION" + read -p "Use this location? (y/n): " use_env + if [[ "$use_env" =~ ^[yY]$ ]]; then + REPO_DIR="$RELEASE_REPO_LOCATION" + else + read -p "Enter the repository directory path: " REPO_DIR + fi +else + read -p "Enter the repository directory path: " REPO_DIR +fi +if [ ! -d "$REPO_DIR" ]; then + echo "Error: Directory '$REPO_DIR' does not exist." + exit 1 +fi + +# Ask for the hotfix branch name +read -p "Enter the hotfix branch name (e.g. 2015-02-03_1702_static_pages): " HOTFIX_NAME +if [ -z "$HOTFIX_NAME" ]; then + echo "Error: Hotfix branch name cannot be empty." + exit 1 +fi + +# cd to repository directory +if confirm "cd to repository directory: $REPO_DIR"; then + cd "$REPO_DIR" + echo "Changed to $(pwd)" +fi + +# Checkout develop and pull +if confirm "git checkout develop"; then + git checkout develop +fi + +if confirm "git pull (develop)"; then + git pull +fi + +# Checkout master and pull +if confirm "git checkout master"; then + git checkout master +fi + +if confirm "git pull (master)"; then + git pull +fi + +# Start hotfix +if confirm "git flow hotfix start $HOTFIX_NAME"; then + git flow hotfix start "$HOTFIX_NAME" +fi + +# Checkout static_pages and pull +if confirm "git checkout static_pages"; then + git checkout static_pages +fi + +if confirm "git pull (static_pages)"; then + git pull +fi + +# Checkout hotfix branch and merge static_pages +if confirm "git checkout hotfix/$HOTFIX_NAME"; then + git checkout "hotfix/$HOTFIX_NAME" +fi + +if confirm "git merge static_pages into hotfix/$HOTFIX_NAME"; then + git merge static_pages +fi + +# Review latest commits +if confirm "Review latest commits in static_pages (git log -p static_pages -5)"; then + git log -p static_pages -5 +fi + +# Show diff of files changed +if confirm "Show files changed: git diff master hotfix/$HOTFIX_NAME --name-only"; then + git diff master "hotfix/$HOTFIX_NAME" --name-only +fi + +# Check for JS/CSS changes and optionally update version +echo "" +echo ">>> Checking for JS or CSS file changes..." +JS_CSS_CHANGES=$(git diff master "hotfix/$HOTFIX_NAME" --name-only | grep -E '\.(js|css)$' || true) + +if [ -n "$JS_CSS_CHANGES" ]; then + echo "JS/CSS changes detected:" + echo "$JS_CSS_CHANGES" + echo "" + echo "You need to update the version in setup.py and portality/settings.py" + + if confirm "Edit setup.py to update DOAJ_VERSION"; then + ${EDITOR:-vi} setup.py + fi + + if confirm "Edit portality/settings.py to update version"; then + ${EDITOR:-vi} portality/settings.py + fi + + if confirm "Commit version changes"; then + git add setup.py portality/settings.py + git commit -m "Update DOAJ_VERSION for static_pages hotfix" + fi +else + echo "No JS/CSS changes detected. Version update not required." +fi + +# Finish hotfix +if confirm "git flow hotfix finish $HOTFIX_NAME"; then + git flow hotfix finish "$HOTFIX_NAME" +fi + +# Push develop +if confirm "git push (current branch)"; then + git push +fi + +# Checkout master and push +if confirm "git checkout master && git push"; then + git checkout master + git push +fi + +# Push tags +if confirm "git push --tags"; then + git push --tags +fi + +echo "" +echo "=== Static pages hotfix release complete! ===" +echo "" +echo "#### from the doaj folder in the 'sysadmin' repo, run the command:" +echo "#### ansible-playbook -i doaj-hosts.ini update-site.yml" +echo "" From ef5a8feaf7f44f7e55a60b5a0aecfbb84d405768 Mon Sep 17 00:00:00 2001 From: Ramakrishna Sakhamuru Date: Thu, 2 Jul 2026 17:06:44 +0530 Subject: [PATCH 2/2] Fixes syntax error --- release_scripts/release_develop_branch.sh | 2 +- release_scripts/release_hotfix_branch.sh | 2 +- release_scripts/release_static_pages.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release_scripts/release_develop_branch.sh b/release_scripts/release_develop_branch.sh index 8c9b193..42ce271 100755 --- a/release_scripts/release_develop_branch.sh +++ b/release_scripts/release_develop_branch.sh @@ -20,7 +20,7 @@ confirm() { if [ -n "$RELEASE_REPO_LOCATION" ]; then echo "Found RELEASE_REPO_LOCATION environment variable: $RELEASE_REPO_LOCATION" read -p "Use this location? (y/n): " use_env - if [[ "$use_env" =~ ^[yY]$ ]]; then + if [ "$use_env" = "y" ] || [ "$use_env" = "Y" ]; then REPO_DIR="$RELEASE_REPO_LOCATION" else read -p "Enter the repository directory path: " REPO_DIR diff --git a/release_scripts/release_hotfix_branch.sh b/release_scripts/release_hotfix_branch.sh index c84b4c0..6e1295a 100755 --- a/release_scripts/release_hotfix_branch.sh +++ b/release_scripts/release_hotfix_branch.sh @@ -20,7 +20,7 @@ confirm() { if [ -n "$RELEASE_REPO_LOCATION" ]; then echo "Found RELEASE_REPO_LOCATION environment variable: $RELEASE_REPO_LOCATION" read -p "Use this location? (y/n): " use_env - if [[ "$use_env" =~ ^[yY]$ ]]; then + if [ "$use_env" = "y" ] || [ "$use_env" = "Y" ]; then REPO_DIR="$RELEASE_REPO_LOCATION" else read -p "Enter the repository directory path: " REPO_DIR diff --git a/release_scripts/release_static_pages.sh b/release_scripts/release_static_pages.sh index 31461c2..413a608 100755 --- a/release_scripts/release_static_pages.sh +++ b/release_scripts/release_static_pages.sh @@ -20,7 +20,7 @@ confirm() { if [ -n "$RELEASE_REPO_LOCATION" ]; then echo "Found RELEASE_REPO_LOCATION environment variable: $RELEASE_REPO_LOCATION" read -p "Use this location? (y/n): " use_env - if [[ "$use_env" =~ ^[yY]$ ]]; then + if [ "$use_env" = "y" ] || [ "$use_env" = "Y" ]; then REPO_DIR="$RELEASE_REPO_LOCATION" else read -p "Enter the repository directory path: " REPO_DIR