Make sed command work on both linux and mac

Bug: 53031
Change-Id: I46bc08bfa7e2254e03aaff8d8811cf4b40fd0cf2
1 file changed
tree: 9c788e17c67ed90776fab3235d7aa044029e55ae
  1. .gitignore
  2. cipd-linux.yaml
  3. cipd-mac.yaml
  4. CONTRIBUTING.md
  5. LICENSE
  6. PATENTS
  7. pyoxidizer.bzl
  8. README.md
README.md

Black package

This contains configuration useful in updating the black package in CIPD.

Build and upload a new version

  1. (one time) Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. (one time) Install PyOxidizer: cargo install pyoxidizer
  3. Build and upload latest version
BLACK_VERSION=$(pip3 install black== 2>&1 | grep versions: | sed -E 's/.*, ([a-z0-9\.]+)\)/\1/')
# We have to specify a back-up to make this work on both Linux and MacOS:
# https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
sed -E -e "s/black==[^\"]+\"/black==${BLACK_VERSION}\"/" -i.bak ./pyoxidizer.bzl
rm ./pyoxidizer.bzl.bak
pyoxidizer build install
OS=$(if [[ $(uname) == 'Darwin' ]]; then echo 'mac'; else echo 'linux'; fi)
cipd create -tag version:${BLACK_VERSION} -pkg-def ./cipd-${OS}.yaml