*: added snapcraft build configuration
This commit is contained in:
parent
7f224658e0
commit
0cb876a71c
16
.travis.yml
16
.travis.yml
@ -118,4 +118,18 @@ matrix:
|
||||
- docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD"
|
||||
- ./build_docker.sh
|
||||
after_script:
|
||||
- docker images
|
||||
- docker images
|
||||
|
||||
# Snapcraft build configuration
|
||||
- if: repo = AdguardTeam/AdGuardHome
|
||||
- name: snapcraft
|
||||
# if: type != pull_request AND (branch = master OR tag IS present) AND repo = AdguardTeam/AdGuardHome
|
||||
if: branch = snapcraft
|
||||
go:
|
||||
- 1.14.x
|
||||
os:
|
||||
- linux
|
||||
services:
|
||||
- docker
|
||||
script:
|
||||
- ./build_snap.sh
|
||||
|
81
build_snap.sh
Executable file
81
build_snap.sh
Executable file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eE
|
||||
set -o pipefail
|
||||
set -x
|
||||
|
||||
BUILDER_IMAGE="adguard/snapcraft:1.0"
|
||||
SNAPCRAFT_TMPL="packaging/snap/snapcraft.yaml"
|
||||
SNAP_NAME="adguardhometest"
|
||||
VERSION=`git describe --abbrev=4 --dirty --always --tags`
|
||||
|
||||
if [[ "${TRAVIS_BRANCH}" == "master" ]]
|
||||
then
|
||||
CHANNEL="edge"
|
||||
else
|
||||
CHANNEL="release"
|
||||
fi
|
||||
|
||||
# Launchpad oauth tokens data is necessary to run snapcraft remote-build
|
||||
#
|
||||
# Here's an instruction on how to generate launchpad OAuth tokens:
|
||||
# https://uci.readthedocs.io/en/latest/oauth.html
|
||||
#
|
||||
# Launchpad credentials are necessary to run snapcraft remote-build command
|
||||
echo "[1]
|
||||
consumer_key = ${LAUNCHPAD_KEY}
|
||||
consumer_secret =
|
||||
access_token = ${LAUNCHPAD_ACCESS_TOKEN}
|
||||
access_secret = ${LAUNCHPAD_ACCESS_SECRET}
|
||||
" > launchpad_credentials
|
||||
|
||||
# Snapcraft login data
|
||||
# It can be exported using snapcraft export-login command
|
||||
echo "[login.ubuntu.com]
|
||||
macaroon = ${SNAPCRAFT_MACAROON}
|
||||
unbound_discharge = ${SNAPCRAFT_UBUNTU_DISCHARGE}
|
||||
email = ${SNAPCRAFT_EMAIL}" > snapcraft_login
|
||||
|
||||
# Prepare the snap configuration
|
||||
cp ${SNAPCRAFT_TMPL} ./snapcraft.yaml
|
||||
sed -i.bak 's/dev_version/'"${VERSION}"'/g' ./snapcraft.yaml
|
||||
|
||||
build_snap() {
|
||||
# Run the build
|
||||
docker run -it -v $(pwd):/build \
|
||||
-v $(pwd)/launchpad_credentials:/root/.local/share/snapcraft/provider/launchpad/credentials:ro \
|
||||
${BUILDER_IMAGE} \
|
||||
snapcraft remote-build --build-on=${ARCH} --launchpad-accept-public-upload
|
||||
}
|
||||
|
||||
publish_snap() {
|
||||
# Check that the snap file exists
|
||||
snapFile="${SNAP_NAME}_${VERSION}_${ARCH}.snap"
|
||||
if [ ! -f ${snapFile} ]; then
|
||||
echo "Snap file ${snapFile} not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Login and publish the snap
|
||||
docker run -it -v $(pwd):/build \
|
||||
${BUILDER_IMAGE} \
|
||||
sh -c "snapcraft login --with=/build/snapcraft_login && snapcraft push --release=${CHANNEL} /build/${snapFile}"
|
||||
}
|
||||
|
||||
# Build snaps
|
||||
ARCH=i386 build_snap
|
||||
ARCH=arm64 build_snap
|
||||
ARCH=armhf build_snap
|
||||
ARCH=amd64 build_snap
|
||||
|
||||
# Publish snaps
|
||||
ARCH=i386 publish_snap
|
||||
ARCH=arm64 publish_snap
|
||||
ARCH=armhf publish_snap
|
||||
ARCH=amd64 publish_snap
|
||||
|
||||
# Clean up
|
||||
rm launchpad_credentials
|
||||
rm snapcraft.yaml
|
||||
rm snapcraft.yaml.bak
|
||||
rm snapcraft_login
|
5
packaging/snap/README.md
Normal file
5
packaging/snap/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
## Snapcraft
|
||||
|
||||
Configuration for our snap.
|
||||
|
||||
Check out `build_snap.sh` for more details.
|
31
packaging/snap/snapcraft.yaml
Normal file
31
packaging/snap/snapcraft.yaml
Normal file
@ -0,0 +1,31 @@
|
||||
name: adguardhometest
|
||||
base: core18
|
||||
version: 'dev_version'
|
||||
summary: Network-wide ads & trackers blocking DNS server
|
||||
description: |
|
||||
AdGuard Home is a network-wide software for blocking ads & tracking. After
|
||||
you set it up, it'll cover ALL your home devices, and you don't need any
|
||||
client-side software for that.
|
||||
It operates as a DNS server that re-routes tracking domains to a "black hole,"
|
||||
thus preventing your devices from connecting to those servers. It's based
|
||||
on software we use for our public AdGuard DNS servers -- both share a lot
|
||||
of common code.
|
||||
grade: stable
|
||||
confinement: strict
|
||||
|
||||
parts:
|
||||
adguard-home:
|
||||
plugin: make
|
||||
source: .
|
||||
build-snaps: [ node/13/stable, go ]
|
||||
build-packages: [ git, build-essential ]
|
||||
override-build: |
|
||||
make clean
|
||||
make
|
||||
cp AdGuardHome ${SNAPCRAFT_PART_INSTALL}/
|
||||
apps:
|
||||
adguard-home:
|
||||
command: AdGuardHome -c ${SNAP_COMMON}/AdGuardHome.yaml -w ${SNAP_DATA} --no-check-update
|
||||
plugs: [ network-bind ]
|
||||
daemon: simple
|
||||
restart-condition: always
|
Loading…
Reference in New Issue
Block a user