Makefile 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. APP := miniflux
  2. DOCKER_IMAGE := miniflux/miniflux
  3. VERSION := $(shell git rev-parse --short HEAD)
  4. BUILD_DATE := `date +%FT%T%z`
  5. LD_FLAGS := "-s -w -X 'miniflux.app/version.Version=$(VERSION)' -X 'miniflux.app/version.BuildDate=$(BUILD_DATE)'"
  6. PKG_LIST := $(shell go list ./... | grep -v /vendor/)
  7. DB_URL := postgres://postgres:postgres@localhost/miniflux_test?sslmode=disable
  8. export GO111MODULE=on
  9. .PHONY: generate \
  10. miniflux \
  11. linux-amd64 \
  12. linux-armv8 \
  13. linux-armv7 \
  14. linux-armv6 \
  15. linux-armv5 \
  16. linux-x86 \
  17. darwin-amd64 \
  18. freebsd-amd64 \
  19. freebsd-x86 \
  20. openbsd-amd64 \
  21. openbsd-x86 \
  22. netbsd-x86 \
  23. netbsd-amd64 \
  24. windows-amd64 \
  25. windows-x86 \
  26. build \
  27. run \
  28. clean \
  29. test \
  30. lint \
  31. integration-test \
  32. clean-integration-test \
  33. docker-images \
  34. docker-manifest
  35. generate:
  36. @ go generate -mod=vendor
  37. miniflux: generate
  38. @ go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP) main.go
  39. linux-amd64: generate
  40. @ GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-amd64 main.go
  41. linux-armv8: generate
  42. @ GOOS=linux GOARCH=arm64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv8 main.go
  43. linux-armv7: generate
  44. @ GOOS=linux GOARCH=arm GOARM=7 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv7 main.go
  45. linux-armv6: generate
  46. @ GOOS=linux GOARCH=arm GOARM=6 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv6 main.go
  47. linux-armv5: generate
  48. @ GOOS=linux GOARCH=arm GOARM=5 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv5 main.go
  49. darwin-amd64: generate
  50. @ GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-darwin-amd64 main.go
  51. freebsd-amd64: generate
  52. @ GOOS=freebsd GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-freebsd-amd64 main.go
  53. openbsd-amd64: generate
  54. @ GOOS=openbsd GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-openbsd-amd64 main.go
  55. windows-amd64: generate
  56. @ GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-windows-amd64 main.go
  57. build: linux-amd64 linux-armv8 linux-armv7 linux-armv6 linux-armv5 darwin-amd64 freebsd-amd64 openbsd-amd64 windows-amd64
  58. # NOTE: unsupported targets
  59. netbsd-amd64: generate
  60. @ GOOS=netbsd GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-netbsd-amd64 main.go
  61. linux-x86: generate
  62. @ GOOS=linux GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-x86 main.go
  63. freebsd-x86: generate
  64. @ GOOS=freebsd GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-freebsd-x86 main.go
  65. netbsd-x86: generate
  66. @ GOOS=netbsd GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-netbsd-x86 main.go
  67. openbsd-x86: generate
  68. @ GOOS=openbsd GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-freebsd-x86 main.go
  69. windows-x86: generate
  70. @ GOOS=windows GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-windows-x86 main.go
  71. run: generate
  72. @ go run -mod=vendor main.go -debug
  73. clean:
  74. @ rm -f $(APP)-* $(APP)
  75. test:
  76. go test -mod=vendor -cover -race -count=1 ./...
  77. lint:
  78. @ golint -set_exit_status ${PKG_LIST}
  79. integration-test:
  80. psql -U postgres -c 'drop database if exists miniflux_test;'
  81. psql -U postgres -c 'create database miniflux_test;'
  82. DATABASE_URL=$(DB_URL) go run -mod=vendor main.go -migrate
  83. DATABASE_URL=$(DB_URL) ADMIN_USERNAME=admin ADMIN_PASSWORD=test123 go run -mod=vendor main.go -create-admin
  84. go build -mod=vendor -o miniflux-test main.go
  85. DATABASE_URL=$(DB_URL) ./miniflux-test -debug >/tmp/miniflux.log 2>&1 & echo "$$!" > "/tmp/miniflux.pid"
  86. while ! echo exit | nc localhost 8080; do sleep 1; done >/dev/null
  87. go test -mod=vendor -v -tags=integration -count=1 miniflux.app/tests || cat /tmp/miniflux.log
  88. clean-integration-test:
  89. @ kill -9 `cat /tmp/miniflux.pid`
  90. @ rm -f /tmp/miniflux.pid /tmp/miniflux.log
  91. @ rm miniflux-test
  92. @ psql -U postgres -c 'drop database if exists miniflux_test;'
  93. docker-images:
  94. for arch in amd64 arm32v6 arm64v8; do \
  95. case $${arch} in \
  96. amd64 ) miniflux_arch="amd64";; \
  97. arm32v6 ) miniflux_arch="armv6";; \
  98. arm64v8 ) miniflux_arch="armv8";; \
  99. esac ;\
  100. cp Dockerfile Dockerfile.$${arch} && \
  101. sed -i"" -e "s|__BASEIMAGE_ARCH__|$${arch}|g" Dockerfile.$${arch} && \
  102. sed -i"" -e "s|__MINIFLUX_VERSION__|$(VERSION)|g" Dockerfile.$${arch} && \
  103. sed -i"" -e "s|__MINIFLUX_ARCH__|$${miniflux_arch}|g" Dockerfile.$${arch} && \
  104. docker build --pull -f Dockerfile.$${arch} -t $(DOCKER_IMAGE):$${arch}-$(VERSION) . && \
  105. docker tag $(DOCKER_IMAGE):$${arch}-${VERSION} $(DOCKER_IMAGE):$${arch}-latest && \
  106. rm -f Dockerfile.$${arch}* ;\
  107. done
  108. docker-manifest:
  109. for version in $(VERSION) latest; do \
  110. docker push $(DOCKER_IMAGE):amd64-$${version} && \
  111. docker push $(DOCKER_IMAGE):arm32v6-$${version} && \
  112. docker push $(DOCKER_IMAGE):arm64v8-$${version} && \
  113. docker manifest create --amend $(DOCKER_IMAGE):$${version} \
  114. $(DOCKER_IMAGE):amd64-$${version} \
  115. $(DOCKER_IMAGE):arm32v6-$${version} \
  116. $(DOCKER_IMAGE):arm64v8-$${version} && \
  117. docker manifest annotate $(DOCKER_IMAGE):$${version} \
  118. $(DOCKER_IMAGE):arm32v6-$${version} --os linux --arch arm --variant v6 && \
  119. docker manifest annotate $(DOCKER_IMAGE):$${version} \
  120. $(DOCKER_IMAGE):arm64v8-$${version} --os linux --arch arm64 --variant v8 && \
  121. docker manifest push --purge $(DOCKER_IMAGE):$${version} ;\
  122. done