If `$X` is the parameter where the new version is stored,

 ed file << EOF
 g/^version =/s/.*/version = '$X'/
 g/^release =/s/.*/release = '$X'/
 w
 q
 EOF

This assumes `$X` has a reasonable value, like `1.2.3-foo`, and no characters that are special to the `ed` command interpreter.