-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/release scripts #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" = "y" ] || [ "$use_env" = "Y" ]; 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth documenting that git flow (and git flow setup / config) are dependencies. |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presume this is the environment variable to use to get the user's default editor? |
||
| 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." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also update the version for other reasons e.g. for the changelog, and for model changes. Apart from static pages, I don't do many releases without bumping the version. It also serves to tell the servers that the package is updated. |
||
| 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 "" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" = "y" ] || [ "$use_env" = "Y" ]; 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 "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might only work if there are only fast-forward merges (i.e. non-interactive) on pull.