build_browsh.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. # This is for building a production version of Browsh.
  3. # To build Browsh during development see:
  4. # https://github.com/browsh-org/browsh#contributing
  5. # This script depends on Golang, dep and go-bindata
  6. # See; ./setup_dep.sh for an example `dep` installation
  7. # `go-bindata` can be easily installed with:
  8. # `go get -u gopkg.in/shuLhan/go-bindata.v3/...`
  9. # `dep esnure` must be run in `interfacer/`
  10. set -e
  11. INTERFACER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && cd ../ && pwd )"
  12. cd $INTERFACER_ROOT
  13. # Install `dep` the current defacto dependency manager for Golang
  14. ./contrib/setup_dep.sh
  15. # Install the tool to convert the web extenstion file into a Go-compatible binary
  16. go get -u gopkg.in/shuLhan/go-bindata.v3/...
  17. # Install Golang dependencies
  18. dep ensure
  19. # Get the current Browsh version, in order to find the corresponding web extension release
  20. version_file=$INTERFACER_ROOT/src/browsh/version.go
  21. line=$(grep 'browshVersion' < $version_file)
  22. version=$(echo $line | grep -o '".*"' | sed 's/"//g')
  23. # Build the URI for the webextension file
  24. base='https://github.com/browsh-org/browsh/releases/download'
  25. release_url="$base/v$version/browsh-${version}-an.fx.xpi"
  26. xpi_file=$INTERFACER_ROOT/browsh.xpi
  27. destination=$INTERFACER_ROOT/src/browsh/webextension.go
  28. # Download the web extension
  29. curl -L -o $xpi_file $release_url
  30. # Convert the web extension into binary data that can be compiled into a
  31. # cross-platform Go binary.
  32. XPI_FILE=$xpi_file BIN_FILE=$destination \
  33. $INTERFACER_ROOT/contrib/xpi2bin.sh
  34. # The actual build iteself
  35. go build -o browsh src/main.go