travis.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. #set -evx
  3. # Objective of this script is to be the most vendor agnostic possible
  4. # It builds and tests yay independently of hardware
  5. VERSION="$(git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')"
  6. export VERSION
  7. export ARCH="x86_64"
  8. docker build --build-arg BUILD_ARCH=${ARCH} --target builder_env -t yay-builder_env . || exit $?
  9. docker build --build-arg BUILD_ARCH=${ARCH} --target builder -t yay-builder . || exit $?
  10. # Our unit test and packaging container
  11. docker run --name yay-go-tests yay-builder_env:latest make test
  12. rc=$?
  13. docker rm yay-go-tests
  14. if [[ $rc != 0 ]]; then
  15. exit $rc
  16. fi
  17. # Lint project
  18. docker run --name yay-go-lint yay-builder_env:latest make lint
  19. rc=$?
  20. docker rm yay-go-lint
  21. if [[ $rc != 0 ]]; then
  22. exit $rc
  23. fi
  24. # Build image for integration testing
  25. # docker build -t yay . || exit $?
  26. # Do integration testing
  27. # TODO
  28. # Create a release asset
  29. docker run --name artifact_factory yay-builder make release ARCH=${ARCH} VERSION="${VERSION}"
  30. rc=$?
  31. if [[ $rc != 0 ]]; then
  32. docker rm artifact_factory
  33. exit $rc
  34. fi
  35. # Copy bin and release to artifacts folder
  36. mkdir artifacts
  37. docker cp artifact_factory:/app/yay_"${VERSION}"_${ARCH}.tar.gz ./artifacts/
  38. # Cleanup docker
  39. docker rm artifact_factory