Multi OS before_deploy

I want to build Rust binaries for linux, osx and windows and deploy them to github.
In order to prevent overwriting the binary with the same name I rename the binary

before_deploy:

  • mv target/release/tacho target/release/tacho-$TRAVIS_TAG-$TRAVIS_OS_NAME

This works fine for linux and osx, however windows does not provide the mv command.

How can I specify OS specific commands, i.e. rename for windows and mv for linux and macos.

Repository URL: https://github.com/qrider71/tacho

Commands are run in Git Bash environment which does provide mv.

if [ "$TRAVIS_OS_NAME" == "windows" ]; then <do something>; done

Doesn’t work:

“The command “if [ “$TRAVIS_OS_NAME” == “windows” ]; then rename target/release/tacho.exe target/release/tacho-$TRAVIS_TAG-$TRAVIS_OS_NAME.exe; fi” failed and exited with 127 during .”

Linux and OSX build were working fine. Obviously the if statement cannot be interpreted under Windows since it is Unix specific. I need to specify in Travis syntax what to execute for each OS.

I configured

before_deploy:

  • if [ “$TRAVIS_OS_NAME” == “linux” ]; then mv target/release/tacho target/release/tacho-$TRAVIS_TAG-$TRAVIS_OS_NAME; fi
  • if [ “$TRAVIS_OS_NAME” == “osx” ]; then mv target/release/tacho target/release/tacho-$TRAVIS_TAG-$TRAVIS_OS_NAME; fi
  • if [ “$TRAVIS_OS_NAME” == “windows” ]; then rename target/release/tacho.exe target/release/tacho-$TRAVIS_TAG-$TRAVIS_OS_NAME.exe; fi

You can use a script language of your choice to accomplish this. For example:

$ export EXT=.txt
$ ls foo*
ls: foo*: No such file or directory
$ touch foo
$ ruby -rfileutils -e 'FileUtils.mv("foo","foo#{ENV["EXT"]}")'
$ ls foo*
foo.txt
1 Like

Not true. We use bash for the execution, so if statement is interpreted correctly. Your failure is:

/c/Users/travis/.travis/functions: line 109: rename: command not found