Automate releases

This commit is contained in:
Thomas Buckley-Houston 2018-01-28 15:26:37 +08:00
parent 6f0a732145
commit 2985774859
11 changed files with 139 additions and 36 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
Dockerfile

1
.gitignore vendored
View file

@ -4,6 +4,7 @@ build/
node_modules
interfacer/target
interfacer/vendor
interfacer/dist
interfacer/interfacer
interfacer/browsh
interfacer/webextension.go

View file

@ -1,19 +1,24 @@
if: tag IS blank # Don't trigger builds if
language: node_js
addons:
firefox: '58.0'
env:
global:
- GOLANG_VERSION=1.9
- GOPATH=$HOME/gopath
- REPO_ROOT=$GOPATH/src
- PATH=$PATH:/$HOME/bin:$GOPATH/bin
- MDN_USER=user:13243312:78
- secure: sKZ1/oBLKNWA0v16d4Yg8V500zIwZwEUpcnW7SMRpeqJMbzlR7GKLpJ/VX6ZAYexokBEEbU+JnI3/aHOmJaO9h2/+b1qwrQqje6totC6/rPhxkdxGxI9jETzPdL0V0XErK4rK2URATEANRnJUFLVuFGaXh6dUZDrbtn8NxDSfZEQGmHlqex5TcqPxmK2v0Lb3l2FcVF2kxGYpKMmjKFQbGBHdjFN5qOrS3jmkHjC6Ie8CaM9ezy55e3sOIrNr/u4kWJAOGE2cT3rjqcmPYaCRRzkiy7q3sYEI6jC9vfOZeyFI6E0e3VPDv+OGq+lnUBbgVjGhiG9LxIJ9Z3JEY9z5OspeczpLiQT2rhstqwDolyhx2liiI9cZe0d+uiLo2YyYKe1RELlClB6cQi9p/J8vJpyVEutIoq8Sdv13vbnJMAmPQi1OD9qtOgBR9cngy5yWIPyizgpcAr6kCYxztwIX4y1wrlHPUdTApDnfJNkNOSBwYBTigmlFZf8BkGXB4JOhcQ8KZM3H2OdOP2rANZIOd1ficgyHgKNt4iomIC/i5d7qnV6OZfzirQgx7yzWqjwoGrPg+OvL9MeY9dMltGsfFL80FLudIzN8sqj3BUYioXWX8GCyVML/XoMPbLpcSLBRMxskUhNSYbaTQ2qML7H5Kv/wce71BXMknzyT0s/mN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HSdJignIjHaV0UtLtFApZl49lzq749r2Sno2ba4JCd0RIgMERjNluXynkJiHrL2tMR8HYhOmoeLMdX0zrguv+136+Jn04gQde3S+FI1/sN0/Xa14xD7SGMUT1MgFnwKgFXOFeUd3VpvbpFg6RWVgpCnaDd2/AKL+mQDEgL4yRg9q95a6Q5ub/c6nla8/E4asEvYGlJPj0OG/MKvJMi0gnKuP4+nil0jgGeKki3k1UxwvldlS+n7HUhQ7c4B9c61KS19i+z5SxBiXjilL+zGlAVVgRcalIoKQrTRDSRKnKZkR5Ant0CLjt44pncHLwlYXD/aPuLNihCa4AqUlpYPYru0pQawXNkVnk6E/cg2DAsp7oDcpcg540="
before_install:
- "./interfacer/contrib/setup_go.sh"
- cd $REPO_ROOT/webext
- ./interfacer/contrib/setup_firefox.sh
- ./interfacer/contrib/setup_go.sh
- cp -rfp $TRAVIS_BUILD_DIR -T $REPO_ROOT
install:
- cd $REPO_ROOT/interfacer
- dep ensure
- cd $REPO_ROOT/webext
- npm run get-gobindata
- npm install
- npm run build
@ -22,19 +27,12 @@ script:
after_failure:
- cat $REPO_ROOT/interfacer/debug.log
- cat $REPO_ROOT/interfacer/spec.log
before_deploy:
- echo "Do I run depending on the condition in `deploy:` ?"
after_success:
- BROWSH_ENV=RELEASE npm run build
- rvm install 2.5.0
- gem install --no-ri --no-rdoc fpm
- apt-get install rpm
- go get github.com/goreleaser/goreleaser
- cd $REPO_ROOT/interfacer
- go build -o browsh *.go
deploy:
provider: releases
api_key:
secure: anJIaL3KQnKjctldcZGK1m+GJ2uut9ErqsEneb0gWlnwg8EjKRxeKhn4Im1ZfFGgw0G+CIFVH0XD7b5oFQzaNrfU759RuqzpsEibfO/DfTKYJmxExiyR5Xng6WEOa0LHP4DVYEnttjL6aDbcefmVUfCwQ1L+gNx8jPocf+3eorM/GSMXg+wCpaDiVRW5NP63GG+dWwVfNVaDf8XxPcSFc1hVUaLMTOXj7Lxscp6S5703qCetNOPDlUDjfIx6Q/sZ8ce1XxA6iJoJL9BbX0X07cvtyz9ThwBHwjXVtkVdI8jwPkS/f9m1u7bE891wfQuXnPxmsMaF5HeQYTGCgPh22NSTgmIyQLzAFyPIz+8ilkTLsFoK3tglJDkMXTRjDXEH3/M8pvfZCj1wIwOypQMDVMLXf0ZU65+YOaiIRNpl6Qw6uVtUjVVWEf4su1yrv5dnAfIIj5kgjlJuCcUmwAaY+cG4D/qVWZQfekxGlt/u0tvyaPJl6sr3HnRj1beDXl/nHdW+n1UblAzZEveET2XwdITNh0N84fRhUzhkxNO6G8RfktUOzoEWNEG5aewOrQekrSt2CcvCxOSNVZXbR2+bcAAQQNYOtpG5cXFdXacSchi7XSMUzLM6E4+JwLxbLd8Ogm8qXc0NA5r7ssGxTYnkVCw7R39r10/Jw5keZ1ak/d8=
file:
- interfacer/browsh
skip_cleanup: true
on:
repo: browsh/browsh
tags: true
- goreleaser

View file

@ -1,17 +1,14 @@
FROM phusion/baseimage
RUN apt-get update
RUN apt-get -y install xvfb libgtk-3-0
FROM bitnami/minideb:stretch
RUN install_packages xvfb libgtk-3-0
RUN useradd user
RUN su user
WORKDIR /home/user
RUN curl -L -o firefox.tar.bz2 https://ftp.mozilla.org/pub/firefox/releases/58.0b16/linux-x86_64/en-US/firefox-58.0b16.tar.bz2
RUN apt-get -y install bzip2
RUN bzip2 -d firefox.tar.bz2
RUN tar xf firefox.tar
ADD ./interfacer/contrib/setup_firefox.sh .
RUN ./setup_firefox.sh
RUN rm ./setup_firefox.sh
ENV PATH="/home/user/firefox:${PATH}"
ADD interfacer/browsh .
ADD ./interfacer/contrib/setup_browsh.sh .
RUN ./setup_browsh.sh
CMD ["/home/user/browsh"]

View file

@ -0,0 +1,21 @@
#!/bin/bash
set -e
PROJECT_ROOT=$(git rev-parse --show-toplevel)
manifest=$PROJECT_ROOT/webext/manifest.json
line=$(cat $manifest | grep '"version"')
manifest_version=$(echo $line | grep -o '".*"' | cut -d " " -f 2 | sed 's/"//g')
latest_tagged_version=$(git tag --list 'v*.*.*' | head -n1 | sed -e "s/^v//")
if [[ "$manifest_version" != "$latest_tagged_version" ]]; then
cd $PROJECT_ROOT/interfacer
goreleaser
git config --global user.email "builds@travis-ci.com"
git config --global user.name "Travis CI"
# `/dev/null` needed to prevent Github token appearing in logs
git push --tags --quiet https://$GITHUB_TOKEN@github.com/tombh/texttop > /dev/null 2>&1
fi

View file

@ -0,0 +1,30 @@
project_name: browsh
builds:
- main: .
binary: browsh
goos:
- windows
- darwin
- linux
goarch:
- amd64
ldflags: -s -w
hooks:
post: ./contrib/upx_compress_binary.sh
archive:
format: binary
fpm:
vendor: Browsh
homepage: https://brow.sh
maintainer: Thomas Buckley-Houston <tom@tombh.co.uk>
description: A fully interactive, realtime and modern browser rendered to TTY
license: GPL v3
formats:
- deb
- rpm
- pacman
dependencies:
- firefox

View file

@ -0,0 +1,25 @@
#!/bin/bash
# I suspect this will be mostly used by automated CI.
# For example; in creating the Browsh Docker image. We don't actually build
# Browsh in the Dockerfile because that would require signing the webextension
# again, which can't be done as only one canonical release of a webextension is
# allowed by MDN per semantic version. It's actually quite good to not have to
# repeat the build process (after having done so in Travis after successfully
# passing tests). So we simply just download the already built binary :)
PROJECT_ROOT=$(git rev-parse --show-toplevel)
if [ $? -eq 0 ]; then
manifest=$PROJECT_ROOT/webext/manifest.json
else
manifest=./manifest.json
fi
line=$(cat $manifest | grep '"version"')
version=$(echo $line | grep -o '".*"' | cut -d " " -f 2 | sed 's/"//g')
base='https://github.com/browsh-org/browsh/releases/download'
release_url="$base/browsh-$version/browsh-linux-amd64-$version"
curl -L -o browsh $release_url
chmod a+x browsh

View file

@ -0,0 +1,11 @@
#!/bin/bash
FIREFOX_VERSION=58.0b16
mkdir -p $HOME/bin
pushd $HOME/bin
curl -L -o firefox.tar.bz2 https://ftp.mozilla.org/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2
apt-get -y install bzip2
bzip2 -d firefox.tar.bz2
tar xf firefox.tar
popd

View file

@ -1,5 +1,11 @@
#!/bin/bash
set -e
GOLANG_VERSION=1.9.3
GOLANG_DEP_VERSION=0.3.2
export GOPATH=$HOME/gopath
export PATH=$PATH:/$HOME/bin:$GOPATH/bin
dep_url=https://github.com/golang/dep/releases/download/v$GOLANG_DEP_VERSION/dep-linux-amd64
golang_archive=go$GOLANG_VERSION.linux-amd64.tar.gz
golang_url=https://dl.google.com/go/$golang_archive
@ -15,8 +21,3 @@ tar -C $HOME/bin -xzf $golang_archive
curl -L -o $GOPATH/bin/dep $dep_url
chmod +x $GOPATH/bin/dep
cp -rfp $TRAVIS_BUILD_DIR -T $REPO_ROOT
cd $REPO_ROOT/interfacer
dep ensure

View file

@ -0,0 +1,10 @@
#!/bin/bash
set -ex
pushd dist
curl -sL -o upx.txz https://github.com/upx/upx/releases/download/v3.94/upx-3.94-amd64_linux.tar.xz
tar -xvf upx.txz
cp upx-3.94-amd64_linux/upx .
rm -rf upx-3.94-amd64_linux
./upx */*
popd

8
webext/contrib/setup_node.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
# See `/.nvmrc` for current Node version
NVM_VERSION=0.33.8
curl -o- https://raw.githubusercontent.com/creationix/nvm/v$NVM_VERSION/install.sh | bash
source $HOME/.nvm/nvm.sh
nvm install