Skip to content

Commit

Permalink
Make bump_version script runnable on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
stes committed Oct 27, 2024
1 parent 51f048d commit a08fbbe
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions tools/bump_version.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# Bump the CEBRA version to the specified value.
# Edits all relevant files at once.
#
#
# Usage:
# tools/bump_version.sh 0.3.1rc1

Expand All @@ -10,24 +10,36 @@ if [ -z ${version} ]; then
>&1 echo "Specify a version number."
>&1 echo "Usage:"
>&1 echo "tools/bump_version.sh <semantic version>"
exit 1
fi

# Determine the correct sed command based on the OS
# On macOS, the `sed` command requires an empty string argument after `-i` for in-place editing.
# On Linux and other Unix-like systems, the `sed` command only requires `-i` for in-place editing.
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
SED_CMD="sed -i .bkp -e"
else
# Linux and other Unix-like systems
SED_CMD="sed -i -e"
fi

# python cebra version
sed -i "s/__version__ = .*/__version__ = \"${version}\"/" \
cebra/__init__.py
$SED_CMD "s/__version__ = .*/__version__ = \"${version}\"/" cebra/__init__.py

# reinstall script in root
sed -i "s/VERSION=.*/VERSION=${version}/" \
reinstall.sh
$SED_CMD "s/VERSION=.*/VERSION=${version}/" reinstall.sh

# Makefile
sed -i "s/CEBRA_VERSION := .*/CEBRA_VERSION := ${version}/" \
Makefile
$SED_CMD "s/CEBRA_VERSION := .*/CEBRA_VERSION := ${version}/" Makefile

# Arch linux PKGBUILD
sed -i "s/pkgver=.*/pkgver=${version}/" \
PKGBUILD
# Arch linux PKGBUILD
$SED_CMD "s/pkgver=.*/pkgver=${version}/" PKGBUILD

# Dockerfile
sed -i "s/ENV WHEEL=cebra-.*\.whl/ENV WHEEL=cebra-${version}-py2.py3-none-any.whl/" \
Dockerfile
$SED_CMD "s/ENV WHEEL=cebra-.*\.whl/ENV WHEEL=cebra-${version}-py2.py3-none-any.whl/" Dockerfile

# Remove backup files
if [[ "$OSTYPE" == "darwin"* ]]; then
rm cebra/__init__.py.bkp reinstall.sh.bkp Makefile.bkp PKGBUILD.bkp Dockerfile.bkp
fi

0 comments on commit a08fbbe

Please sign in to comment.