You can use parameter expansion for this:
${var#pattern}
removes the shortest matching pattern from the beginning of var. Using ## removes the longest matching pattern. % and %% work similarly, but remove from the end of var.
#!/bin/bash
first="foo-bar-1.4.5"
second="foo-bar-baz-1.8.3"
echo ${first%-*}
echo ${first##*-}
echo ${second%-*}
echo ${second##*-}
Output:
foo-bar
1.4.5
foo-bar-baz
1.8.3