Fix #773 - preparing the new update channel

This commit is contained in:
Andrey Meshkov 2019-06-06 03:00:15 +03:00
parent 86ba6d4332
commit 3958330560
5 changed files with 48 additions and 34 deletions

View File

@ -4,6 +4,7 @@ NATIVE_GOARCH = $(shell unset GOARCH; go env GOARCH)
GOPATH := $(shell go env GOPATH)
JSFILES = $(shell find client -path client/node_modules -prune -o -type f -name '*.js')
STATIC = build/static/index.html
CHANNEL ?= release
TARGET=AdGuardHome
@ -22,7 +23,7 @@ $(STATIC): $(JSFILES) client/node_modules
$(TARGET): $(STATIC) *.go dhcpd/*.go dnsfilter/*.go dnsforward/*.go
GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) GO111MODULE=off go get -v github.com/gobuffalo/packr/...
PATH=$(GOPATH)/bin:$(PATH) packr -z
CGO_ENABLED=0 go build -ldflags="-s -w -X main.VersionString=$(GIT_VERSION)" -asmflags="-trimpath=$(PWD)" -gcflags="-trimpath=$(PWD)"
CGO_ENABLED=0 go build -ldflags="-s -w -X main.VersionString=$(GIT_VERSION) -X main.updateChannel=$(CHANNEL)" -asmflags="-trimpath=$(PWD)" -gcflags="-trimpath=$(PWD)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
clean:

10
app.go
View File

@ -18,6 +18,7 @@ import (
"strings"
"sync"
"syscall"
"time"
"github.com/AdguardTeam/golibs/log"
"github.com/NYTimes/gziphandler"
@ -26,6 +27,13 @@ import (
// VersionString will be set through ldflags, contains current version
var VersionString = "undefined"
// updateChannel can be set via ldflags
var updateChannel = "release"
var versionCheckURL = "https://static.adguard.com/adguardhome/" + updateChannel + "/version.json"
const versionCheckPeriod = time.Hour * 8
var httpServer *http.Server
var httpsServer struct {
server *http.Server
@ -73,7 +81,7 @@ func run(args options) {
enableTLS13()
// print the first message after logger is configured
log.Printf("AdGuard Home, version %s\n", VersionString)
log.Printf("AdGuard Home, version %s, channel %s\n", VersionString, updateChannel)
log.Debug("Current working directory is %s", config.ourWorkingDir)
if args.runningAsService {
log.Info("AdGuard Home is running as a service")

View File

@ -31,9 +31,6 @@ var versionCheckLastTime time.Time
var protocols = []string{"tls://", "https://", "tcp://", "sdns://"}
const versionCheckURL = "https://adguardteam.github.io/AdGuardHome/version.json"
const versionCheckPeriod = time.Hour * 8
var transport = &http.Transport{
DialContext: customDialContext,
}

View File

@ -4,20 +4,23 @@ set -eE
set -o pipefail
set -x
channel=${1:-release}
baseUrl="https://static.adguard.com/adguardhome/$channel"
dst=dist
version=`git describe --abbrev=4 --dirty --always --tags`
f() {
make cleanfast; CGO_DISABLED=1 make
if [[ $GOOS == darwin ]]; then
zip dist/AdGuardHome_"$version"_MacOS.zip AdGuardHome README.md LICENSE.txt
zip $dst/AdGuardHome_MacOS.zip AdGuardHome README.md LICENSE.txt
elif [[ $GOOS == windows ]]; then
zip dist/AdGuardHome_"$version"_Windows_"$GOARCH".zip AdGuardHome.exe README.md LICENSE.txt
zip $dst/AdGuardHome_Windows_"$GOARCH".zip AdGuardHome.exe README.md LICENSE.txt
else
rm -rf dist/AdguardHome
mkdir -p dist/AdGuardHome
cp -pv {AdGuardHome,LICENSE.txt,README.md} dist/AdGuardHome/
pushd dist
tar zcvf AdGuardHome_"$version"_"$GOOS"_"$GOARCH".tar.gz AdGuardHome/{AdGuardHome,LICENSE.txt,README.md}
tar zcvf AdGuardHome_"$GOOS"_"$GOARCH".tar.gz AdGuardHome/{AdGuardHome,LICENSE.txt,README.md}
popd
rm -rf dist/AdguardHome
fi
@ -25,18 +28,38 @@ f() {
# Clean dist and build
make clean
rm -rf dist
rm -rf $dst
# Prepare the dist folder
mkdir -p dist
mkdir -p $dst
# Prepare releases
GOOS=darwin GOARCH=amd64 f
GOOS=linux GOARCH=amd64 f
GOOS=linux GOARCH=386 f
GOOS=linux GOARCH=arm GOARM=6 f
GOOS=linux GOARCH=arm64 GOARM=6 f
GOOS=windows GOARCH=amd64 f
GOOS=windows GOARCH=386 f
GOOS=linux GOARCH=mipsle GOMIPS=softfloat f
GOOS=linux GOARCH=mips GOMIPS=softfloat f
CHANNEL=$channel GOOS=darwin GOARCH=amd64 f
CHANNEL=$channel GOOS=linux GOARCH=amd64 f
CHANNEL=$channel GOOS=linux GOARCH=386 f
CHANNEL=$channel GOOS=linux GOARCH=arm GOARM=6 f
CHANNEL=$channel GOOS=linux GOARCH=arm64 GOARM=6 f
CHANNEL=$channel GOOS=windows GOARCH=amd64 f
CHANNEL=$channel GOOS=windows GOARCH=386 f
CHANNEL=$channel GOOS=linux GOARCH=mipsle GOMIPS=softfloat f
CHANNEL=$channel GOOS=linux GOARCH=mips GOMIPS=softfloat f
# Variables for CI
echo "version=$version" > $dst/version.txt
# Prepare the version.json file
echo "{" >> $dst/version.json
echo " \"version\": \"$version\"," >> $dst/version.json
echo " \"announcement\": \"AdGuard Home $version is now available!\"," >> $dst/version.json
echo " \"announcement_url\": \"https://github.com/AdguardTeam/AdGuardHome/releases\"," >> $dst/version.json
echo " \"download_windows_amd64\": \"$baseUrl/AdGuardHome_Windows_amd64.zip\"," >> $dst/version.json
echo " \"download_windows_386\": \"$baseUrl/AdGuardHome_Windows_386.zip\"," >> $dst/version.json
echo " \"download_darwin_amd64\": \"$baseUrl/AdGuardHome_MacOS.zip\"," >> $dst/version.json
echo " \"download_linux_amd64\": \"$baseUrl/AdGuardHome_linux_amd64.tar.gz\"," >> $dst/version.json
echo " \"download_linux_386\": \"$baseUrl/AdGuardHome_linux_386.tar.gz\"," >> $dst/version.json
echo " \"download_linux_arm\": \"$baseUrl/AdGuardHome_linux_arm.tar.gz\"," >> $dst/version.json
echo " \"download_linux_arm64\": \"$baseUrl/AdGuardHome_linux_arm64.tar.gz\"," >> $dst/version.json
echo " \"download_linux_mips\": \"$baseUrl/AdGuardHome_linux_mips.tar.gz\"," >> $dst/version.json
echo " \"download_linux_mipsle\": \"$baseUrl/AdGuardHome_linux_mipsle.tar.gz\"," >> $dst/version.json
echo " \"selfupdate_min_version\": \"v0.0\"" >> $dst/version.json
echo "}" >> $dst/version.json

View File

@ -1,15 +0,0 @@
{
"version": "v0.95-hotfix",
"announcement": "AdGuard Home v0.95-hotfix is now available!",
"announcement_url": "https://github.com/AdguardTeam/AdGuardHome/releases/tag/v0.95-hotfix",
"download_windows_amd64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_Windows_amd64.zip",
"download_windows_386": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_Windows_386.zip",
"download_darwin_amd64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_MacOS.zip",
"download_linux_amd64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_linux_amd64.tar.gz",
"download_linux_386": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_linux_386.tar.gz",
"download_linux_arm": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_linux_arm.tar.gz",
"download_linux_arm64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_linux_arm64.tar.gz",
"download_linux_mips": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_linux_mips.tar.gz",
"download_linux_mipsle": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95-hotfix/AdGuardHome_v0.95-hotfix_linux_mipsle.tar.gz",
"selfupdate_min_version": "v0.0"
}