Skip to content

Commit 92e801b

Browse files
committed
Make bump_version script runnable on MacOS
1 parent 7a4d3fc commit 92e801b

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

tools/bump_version.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# Bump the CEBRA version to the specified value.
33
# Edits all relevant files at once.
4-
#
4+
#
55
# Usage:
66
# tools/bump_version.sh 0.3.1rc1
77

@@ -10,24 +10,36 @@ if [ -z ${version} ]; then
1010
>&1 echo "Specify a version number."
1111
>&1 echo "Usage:"
1212
>&1 echo "tools/bump_version.sh <semantic version>"
13+
exit 1
14+
fi
15+
16+
# Determine the correct sed command based on the OS
17+
# On macOS, the `sed` command requires an empty string argument after `-i` for in-place editing.
18+
# On Linux and other Unix-like systems, the `sed` command only requires `-i` for in-place editing.
19+
if [[ "$OSTYPE" == "darwin"* ]]; then
20+
# macOS
21+
SED_CMD="sed -i .bkp -e"
22+
else
23+
# Linux and other Unix-like systems
24+
SED_CMD="sed -i -e"
1325
fi
1426

1527
# python cebra version
16-
sed -i "s/__version__ = .*/__version__ = \"${version}\"/" \
17-
cebra/__init__.py
28+
$SED_CMD "s/__version__ = .*/__version__ = \"${version}\"/" cebra/__init__.py
1829

1930
# reinstall script in root
20-
sed -i "s/VERSION=.*/VERSION=${version}/" \
21-
reinstall.sh
31+
$SED_CMD "s/VERSION=.*/VERSION=${version}/" reinstall.sh
2232

2333
# Makefile
24-
sed -i "s/CEBRA_VERSION := .*/CEBRA_VERSION := ${version}/" \
25-
Makefile
34+
$SED_CMD "s/CEBRA_VERSION := .*/CEBRA_VERSION := ${version}/" Makefile
2635

27-
# Arch linux PKGBUILD
28-
sed -i "s/pkgver=.*/pkgver=${version}/" \
29-
PKGBUILD
36+
# Arch linux PKGBUILD
37+
$SED_CMD "s/pkgver=.*/pkgver=${version}/" PKGBUILD
3038

3139
# Dockerfile
32-
sed -i "s/ENV WHEEL=cebra-.*\.whl/ENV WHEEL=cebra-${version}-py2.py3-none-any.whl/" \
33-
Dockerfile
40+
$SED_CMD "s/ENV WHEEL=cebra-.*\.whl/ENV WHEEL=cebra-${version}-py2.py3-none-any.whl/" Dockerfile
41+
42+
# Remove backup files
43+
if [[ "$OSTYPE" == "darwin"* ]]; then
44+
rm cebra/__init__.py.bkp reinstall.sh.bkp Makefile.bkp PKGBUILD.bkp Dockerfile.bkp
45+
fi

0 commit comments

Comments
 (0)