2018-07-26 10:40:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This is for building a production version of Browsh.
|
|
|
|
# To build Browsh during development see:
|
|
|
|
# https://github.com/browsh-org/browsh#contributing
|
|
|
|
|
2018-07-26 10:56:33 +00:00
|
|
|
# This script depends on Golang, dep and go-bindata
|
|
|
|
# See; ./setup_dep.sh for an example `dep` installation
|
|
|
|
# `go-bindata` can be easily installed with:
|
|
|
|
# `go get -u gopkg.in/shuLhan/go-bindata.v3/...`
|
|
|
|
# `dep esnure` must be run in `interfacer/`
|
2018-07-26 10:40:31 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
INTERFACER_ROOT=$(readlink -m "$( cd "$(dirname "$0")" ; pwd -P )"/../)
|
2018-07-26 10:56:33 +00:00
|
|
|
cd $INTERFACER_ROOT
|
|
|
|
|
|
|
|
# Install `dep` the current defacto dependency manager for Golang
|
|
|
|
./contrib/setup_dep.sh
|
|
|
|
|
|
|
|
# Install the tool to convert the web extenstion file into a Go-compatible binary
|
|
|
|
go get -u gopkg.in/shuLhan/go-bindata.v3/...
|
2018-07-26 10:40:31 +00:00
|
|
|
|
2018-07-26 10:56:33 +00:00
|
|
|
# Install Golang dependencies
|
|
|
|
dep ensure
|
|
|
|
|
|
|
|
# Get the current Browsh version, in order to find the corresponding web extension release
|
2018-07-26 10:40:31 +00:00
|
|
|
version_file=$INTERFACER_ROOT/src/browsh/version.go
|
|
|
|
line=$(cat $version_file | grep 'browshVersion')
|
|
|
|
version=$(echo $line | grep -o '".*"' | sed 's/"//g')
|
|
|
|
|
2018-07-26 10:56:33 +00:00
|
|
|
# Build the URI for the webextension file
|
2018-07-26 10:40:31 +00:00
|
|
|
base='https://github.com/browsh-org/browsh/releases/download'
|
|
|
|
release_url="$base/v$version/browsh-${version}-an.fx.xpi"
|
|
|
|
|
|
|
|
xpi_file=$INTERFACER_ROOT/browsh.xpi
|
|
|
|
destination=$INTERFACER_ROOT/src/browsh/webextension.go
|
|
|
|
|
2018-07-26 10:56:33 +00:00
|
|
|
# Download the web extension
|
2018-07-26 10:40:31 +00:00
|
|
|
curl -L -o $xpi_file $release_url
|
|
|
|
|
2018-07-26 10:56:33 +00:00
|
|
|
# Convert the web extension into binary data that can be compiled into a
|
|
|
|
# cross-platform Go binary.
|
2018-07-26 10:40:31 +00:00
|
|
|
XPI_FILE=$xpi_file BIN_FILE=$destination \
|
|
|
|
$INTERFACER_ROOT/contrib/xpi2bin.sh
|
|
|
|
|
2018-07-26 10:56:33 +00:00
|
|
|
# The actual build iteself
|
2018-07-26 10:40:31 +00:00
|
|
|
go build -o browsh src/main.go
|