/ci/before_deploy.sh

https://github.com/freedomlayer/offst · Shell · 57 lines · 28 code · 12 blank · 17 comment · 1 complexity · eb004ab227c88db4a695e7104cb548cc MD5 · raw file

  1. #!/bin/bash
  2. # package the build artifacts
  3. # Based on https://github.com/BurntSushi/ripgrep/blob/master/.travis.yml
  4. # See: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
  5. set -eux -o pipefail
  6. # Generate artifacts for release
  7. mk_artifacts() {
  8. cargo build --target "$TARGET" --release
  9. }
  10. mk_tarball() {
  11. # Create a temporary dir that contains our staging area.
  12. # $tmpdir/$name is what eventually ends up as the deployed archive.
  13. local tmpdir="$(mktemp -d)"
  14. local name="${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}"
  15. local staging="$tmpdir/$name"
  16. mkdir -p "$staging"/bin
  17. # The deployment directory is where the final archive will reside.
  18. # This path is known by the .travis.yml configuration.
  19. local out_dir="$HOME/deployment"
  20. mkdir -p "$out_dir"
  21. # Find the correct (most recent) Cargo "out" directory. The out directory
  22. # contains shell completion files and the man page.
  23. local cargo_out_dir="$(cargo_out_dir "target/$TARGET")"
  24. # TODO: Strip binaries?
  25. # Copy the binaries:
  26. cp "target/$TARGET/release/stmgr" "$staging/bin/stmgr"
  27. cp "target/$TARGET/release/strelay" "$staging/bin/strelay"
  28. cp "target/$TARGET/release/stindex" "$staging/bin/stindex"
  29. cp "target/$TARGET/release/stnode" "$staging/bin/stnode"
  30. cp "target/$TARGET/release/stctrl" "$staging/bin/stctrl"
  31. cp "target/$TARGET/release/stcompact" "$staging/bin/stcompact"
  32. # Copy README file:
  33. cp README.md "$staging/"
  34. # Copy all licenses:
  35. cp LICENSE-* "$staging/"
  36. # TODO: Copy man pages?
  37. # TODO: Copy shell completion files.
  38. (cd "$tmpdir" && tar czf "$out_dir/$name.tar.gz" "$name")
  39. rm -rf "$tmpdir"
  40. }
  41. main() {
  42. mk_artifacts
  43. mk_tarball
  44. }
  45. main