Skip to content

Commit 1f8b986

Browse files
committed
improve release script for macOS and Linux compatibility
1 parent 1088559 commit 1f8b986

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

scripts/prompt_user_exit_or_continue.sh renamed to scripts/functions.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ prompt_user() {
2020
done
2121
}
2222

23+
24+
run_sed() {
25+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
26+
sed --in-place=.bak "$1" "$2"
27+
elif [[ "$OSTYPE" == "darwin"* ]]; then
28+
sed -i .bak "$1" "$2"
29+
else
30+
printf "\nOS could not be detected. Please open report manually!\n"
31+
fi
32+
}
33+
2334
# Example usage
2435
#prompt_user "Do you want to continue?"
2536

@@ -29,4 +40,4 @@ prompt_user() {
2940
#SCRIPT_DIR="$(dirname "$0")"
3041
#
3142
## import user prompt
32-
#source "$SCRIPT_DIR/prompt_user_exit_or_continue.sh"
43+
#source "$SCRIPT_DIR/functions.sh"

scripts/release.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# based on docs here: https://heigit.atlassian.net/wiki/spaces/OQT/pages/3474149/Releases
23
# requires local installation of `gh`, the github CLI: https://cli.github.com
34

@@ -9,14 +10,14 @@ export NEW_VERSION=1.8.1
910

1011

1112
# exit immediately if a command exits with a non-zero status
12-
set -ex
13+
set -e
1314

1415

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

1819
# import user prompt
19-
source "$SCRIPT_DIR/prompt_user_exit_or_continue.sh"
20+
source "$SCRIPT_DIR/functions.sh"
2021

2122

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

2728

2829
# change to main directory
29-
cd ..
30+
cd $SCRIPT_DIR/..
3031

3132

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

5758

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

6364

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

@@ -108,4 +109,12 @@ echo "✅ created new github release and tag for version: $NEW_VERSION"
108109

109110

110111

111-
echo "⚠️ Please start the Jenkins tag build here: https://jenkins.heigit.org/job/OQAPI/view/tags/job/$NEW_VERSION/"
112+
JENKINS_URL="https://jenkins.heigit.org/job/OQAPI/view/tags/job/${NEW_VERSION}/"
113+
echo "⚠️ Please start the Jenkins tag build here: ${JENKINS_URL}"
114+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
115+
xdg-open "$JENKINS_URL"
116+
elif [[ "$OSTYPE" == "darwin"* ]]; then
117+
open "$JENKINS_URL"
118+
else
119+
printf "\nOS could not be detected. Please open report manually!\n"
120+
fi

0 commit comments

Comments
 (0)