Skip to content
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

improve release script for macOS and Linux compatibility #859

Merged
merged 2 commits into from
Dec 10, 2024
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
23 changes: 22 additions & 1 deletion scripts/prompt_user_exit_or_continue.sh → scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ prompt_user() {
done
}


run_sed() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sed --in-place=.bak "$1" "$2"
elif [[ "$OSTYPE" == "darwin"* ]]; then
sed -i .bak "$1" "$2"
else
printf "\nOS could not be detected. Please open report manually!\n"
fi
}

run_open() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
xdg-open "$1"
elif [[ "$OSTYPE" == "darwin"* ]]; then
open "$1"
else
printf "\nOS could not be detected. Please open URL manually!\n"
fi
}

# Example usage
#prompt_user "Do you want to continue?"

Expand All @@ -29,4 +50,4 @@ prompt_user() {
#SCRIPT_DIR="$(dirname "$0")"
#
## import user prompt
#source "$SCRIPT_DIR/prompt_user_exit_or_continue.sh"
#source "$SCRIPT_DIR/functions.sh"
15 changes: 9 additions & 6 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# based on docs here: https://heigit.atlassian.net/wiki/spaces/OQT/pages/3474149/Releases
# requires local installation of `gh`, the github CLI: https://cli.github.com

Expand All @@ -9,14 +10,14 @@ export NEW_VERSION=1.8.1


# exit immediately if a command exits with a non-zero status
set -ex
set -e


# get the directory of the current script
SCRIPT_DIR="$(dirname "$0")"

# import user prompt
source "$SCRIPT_DIR/prompt_user_exit_or_continue.sh"
source "$SCRIPT_DIR/functions.sh"


prompt_user "👉 did you adjust the values for old and new versions in the release script?"
Expand All @@ -26,7 +27,7 @@ prompt_user "👉 do you run this script in an active python env? if not run 'po


# change to main directory
cd ..
cd $SCRIPT_DIR/..


# get latest version of main and create new branch
Expand Down Expand Up @@ -56,14 +57,14 @@ export NEW="__version__ = \"$NEW_VERSION\""


# might not work like this on linux
sed -i .bak "s/$OLD/$NEW/g" ohsome_quality_api/__init__.py
run_sed "s/$OLD/$NEW/g" ohsome_quality_api/__init__.py
rm -rf ohsome_quality_api/__init__.py.bak
echo "✅ updated __init__.py to $NEW_VERSION"


# insert new sub-headline for new release
prompt_user "👉 update CHANGELOG.md?"
sed -i .bak "s/## Current Main/## Current Main \n\n## Release $NEW_VERSION/g" CHANGELOG.md
run_sed "s/## Current Main/## Current Main\n\n## Release $NEW_VERSION/g" CHANGELOG.md
rm -rf CHANGELOG.md.bak
echo "✅ updated CHANGELOG.md"

Expand Down Expand Up @@ -108,4 +109,6 @@ echo "✅ created new github release and tag for version: $NEW_VERSION"



echo "⚠️ Please start the Jenkins tag build here: https://jenkins.heigit.org/job/OQAPI/view/tags/job/$NEW_VERSION/"
JENKINS_URL="https://jenkins.heigit.org/job/OQAPI/view/tags/job/${NEW_VERSION}/"
echo "⚠️ Please start the Jenkins tag build here: ${JENKINS_URL}"
run_open "$JENKINS_URL"