2019-09-26 12:45:48 +02:00
|
|
|
#!/bin/bash
|
2019-10-13 21:10:46 +02:00
|
|
|
#set -evx
|
2019-09-26 12:45:48 +02:00
|
|
|
|
|
|
|
# Objective of this script is to be the most vendor agnostic possible
|
|
|
|
# It builds and tests yay independently of hardware
|
|
|
|
|
2019-10-13 21:10:46 +02:00
|
|
|
VERSION="$(git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')"
|
|
|
|
export VERSION
|
2019-09-26 12:45:48 +02:00
|
|
|
export ARCH="x86_64"
|
|
|
|
|
2019-10-13 21:10:46 +02:00
|
|
|
docker build --build-arg BUILD_ARCH=${ARCH} --target builder_env -t yay-builder_env . || exit $?
|
|
|
|
docker build --build-arg BUILD_ARCH=${ARCH} --target builder -t yay-builder . || exit $?
|
2019-09-26 12:45:48 +02:00
|
|
|
|
|
|
|
# Our unit test and packaging container
|
2019-10-16 18:24:59 +02:00
|
|
|
docker run --rm --name yay-go-tests yay-builder_env:latest make test || exit $?
|
2019-09-26 12:45:48 +02:00
|
|
|
|
2019-10-13 21:10:46 +02:00
|
|
|
# Lint project
|
2019-10-16 18:24:59 +02:00
|
|
|
docker run --rm --name yay-go-lint yay-builder_env:latest make lint || exit $?
|
2019-09-26 12:45:48 +02:00
|
|
|
|
2019-10-13 21:10:46 +02:00
|
|
|
# Build image for integration testing
|
|
|
|
# docker build -t yay . || exit $?
|
2019-09-26 12:45:48 +02:00
|
|
|
# Do integration testing
|
|
|
|
# TODO
|
|
|
|
|
|
|
|
# Create a release asset
|
2019-10-13 21:10:46 +02:00
|
|
|
docker run --name artifact_factory yay-builder make release ARCH=${ARCH} VERSION="${VERSION}"
|
|
|
|
rc=$?
|
|
|
|
if [[ $rc != 0 ]]; then
|
|
|
|
docker rm artifact_factory
|
|
|
|
exit $rc
|
|
|
|
fi
|
2019-09-26 12:45:48 +02:00
|
|
|
|
2019-09-29 13:01:17 +02:00
|
|
|
# Copy bin and release to artifacts folder
|
|
|
|
mkdir artifacts
|
2019-10-13 21:10:46 +02:00
|
|
|
docker cp artifact_factory:/app/yay_"${VERSION}"_${ARCH}.tar.gz ./artifacts/
|
2019-09-26 12:45:48 +02:00
|
|
|
|
|
|
|
# Cleanup docker
|
|
|
|
docker rm artifact_factory
|