build_packages.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. name: Build packages
  2. on:
  3. push:
  4. tags:
  5. pull_request:
  6. release:
  7. types:
  8. - published
  9. jobs:
  10. build:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - uses: actions/checkout@v2
  14. with:
  15. fetch-depth: 0
  16. - uses: docker/setup-buildx-action@v1
  17. - uses: docker/setup-qemu-action@v1
  18. with:
  19. image: tonistiigi/binfmt:latest
  20. platforms: all
  21. - name: build
  22. run: |
  23. make all_pkgs
  24. cd _packages && for var in $(ls); do sudo bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd -
  25. - uses: actions/upload-artifact@v1
  26. with:
  27. name: packages
  28. path: _packages/.
  29. build-on-mac:
  30. runs-on: macos-latest
  31. steps:
  32. - uses: actions/checkout@v2
  33. with:
  34. fetch-depth: 0
  35. - uses: actions/setup-go@v2
  36. with:
  37. go-version: '1.15.1'
  38. - name: prepare
  39. run: |
  40. brew install curl zip unzip gnu-sed upx pkg-config zmq
  41. echo "/usr/local/bin:$PATH" >> ~/.bashrc
  42. - name: build
  43. run: |
  44. make pkg
  45. cd _packages && for var in $(ls); do openssl dgst -sha256 $var | awk '{print $2}' > $var.sha256; done && cd -
  46. - uses: actions/upload-artifact@v1
  47. with:
  48. name: packages-mac
  49. path: _packages/.
  50. build-docker-images:
  51. runs-on: ubuntu-latest
  52. steps:
  53. - uses: actions/checkout@v2
  54. with:
  55. fetch-depth: 0
  56. - uses: docker/setup-buildx-action@v1
  57. - uses: docker/setup-qemu-action@v1
  58. with:
  59. image: tonistiigi/binfmt:latest
  60. platforms: all
  61. - name: build docker image
  62. run: |
  63. make docker -j4
  64. docker save lfedge/ekuiper:$(git describe --tags --always)-slim > kuiper-image.tar.gz
  65. - name: test docker image
  66. run: |
  67. for image_id in $(docker images lfedge/ekuiper -q); do
  68. container_id=$(docker run -d $image_id)
  69. ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container_id)
  70. sleep 5
  71. if ! curl ${ip_address}:9081 >/dev/null 2>&1; then echo "docker image failed"; exit 1; fi
  72. done
  73. - uses: actions/upload-artifact@v2
  74. with:
  75. name: kuiper-image
  76. path: "kuiper-image.tar.gz"
  77. build-plugins:
  78. runs-on: ubuntu-latest
  79. needs: build-docker-images
  80. strategy:
  81. fail-fast: false
  82. matrix:
  83. plugin:
  84. - sinks/file
  85. - sinks/image
  86. - sinks/influx
  87. - sinks/tdengine
  88. - sinks/zmq
  89. - sources/random
  90. - sources/zmq
  91. - functions/accumulateWordCount
  92. - functions/countPlusOne
  93. - functions/echo
  94. - functions/image
  95. - functions/geohash
  96. - functions/labelImage
  97. steps:
  98. - uses: actions/checkout@v2
  99. with:
  100. fetch-depth: 0
  101. - uses: docker/setup-buildx-action@v1
  102. - uses: docker/setup-qemu-action@v1
  103. with:
  104. image: tonistiigi/binfmt:latest
  105. platforms: all
  106. - name: build debian plugins
  107. env:
  108. PLUGIN: ${{ matrix.plugin }}
  109. run: |
  110. make ${PLUGIN}
  111. - uses: actions/download-artifact@v1
  112. with:
  113. name: kuiper-image
  114. path: .
  115. - name: test docker and plugins
  116. env:
  117. PLUGIN: ${{ matrix.plugin }}
  118. run: |
  119. set -e -x -u
  120. docker load < kuiper-image.tar.gz
  121. plugin_type=$(echo ${PLUGIN%%/*})
  122. plugin_name=$(echo ${PLUGIN##*/})
  123. for image_id in $(docker images lfedge/ekuiper -q); do
  124. container_id=$(docker run -d -v $(pwd)/_plugins:/var/plugins $image_id)
  125. ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container_id)
  126. os=$(docker exec -i ${container_id} sh -c "sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g'" )
  127. sleep 5
  128. if ! curl ${ip_address}:9081 >/dev/null 2>&1; then echo "docker image failed"; exit 1; fi
  129. if [ ${os} = alpine ]; then continue; fi
  130. if [ "${plugin_name}" = "tdengine" ]; then
  131. curl \
  132. ${ip_address}:9081/plugins/${plugin_type} \
  133. -X POST \
  134. -d "{\"name\":\"${plugin_name}\", \"file\":\"file:///var/plugins/${os}/${plugin_type}/${plugin_name}_amd64.zip\", \"shellParas\": [\"2.0.3.1\"]}"
  135. elif [ "${plugin_name}" = "image" ]; then
  136. curl \
  137. ${ip_address}:9081/plugins/${plugin_type} \
  138. -X POST \
  139. -d "{\"name\":\"${plugin_name}\", \"file\":\"file:///var/plugins/${os}/${plugin_type}/${plugin_name}_amd64.zip\", \"functions\": [\"resize\",\"thumbnail\"]}"
  140. elif [ "${plugin_name}" = "geohash" ]; then
  141. curl \
  142. ${ip_address}:9081/plugins/${plugin_type} \
  143. -X POST \
  144. -d "{\"name\":\"${plugin_name}\", \"file\":\"file:///var/plugins/${os}/${plugin_type}/${plugin_name}_amd64.zip\", \"functions\": [\"geohashEncode\", \"geohashEncodeInt\", \"geohashDecode\", \"geohashDecodeInt\", \"geohashBoundingBox\", \"geohashBoundingBoxInt\", \"geohashNeighbor\", \"geohashNeighborInt\", \"geohashNeighbors\", \"geohashNeighborsInt\"]}"
  145. else
  146. curl \
  147. ${ip_address}:9081/plugins/${plugin_type} \
  148. -X POST \
  149. -d "{\"name\":\"${plugin_name}\", \"file\":\"file:///var/plugins/${os}/${plugin_type}/${plugin_name}_amd64.zip\"}"
  150. fi
  151. docker logs ${container_id}
  152. [ $plugin_name = $(curl ${ip_address}:9081/plugins/${plugin_type}/${plugin_name} | jq '.name'| sed 's/\"//g' ) ] || exit 1
  153. done
  154. - uses: actions/upload-artifact@v2
  155. with:
  156. name: plugins
  157. path: "_plugins/"
  158. build-docker-manifest-images:
  159. runs-on: ubuntu-latest
  160. needs: build-docker-images
  161. if: github.event_name == 'release'
  162. strategy:
  163. matrix:
  164. suffix:
  165. - fat
  166. - slim
  167. - alpine
  168. steps:
  169. - uses: actions/checkout@v2
  170. with:
  171. fetch-depth: 0
  172. - uses: docker/setup-buildx-action@v1
  173. - uses: docker/setup-qemu-action@v1
  174. with:
  175. image: tonistiigi/binfmt:latest
  176. platforms: all
  177. - uses: docker/login-action@v1
  178. with:
  179. username: ${{ secrets.DOCKER_HUB_USER }}
  180. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  181. - name: cross build docker images
  182. if: matrix.suffix == 'fat'
  183. run: |
  184. set -e -u -x
  185. docker buildx build --no-cache \
  186. --platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386 \
  187. -t lfedge/ekuiper:$(git describe --tags --always) \
  188. -f deploy/docker/Dockerfile . \
  189. --push
  190. - name: cross build docker images
  191. if: matrix.suffix != 'fat'
  192. env:
  193. SUFFIX: ${{ matrix.suffix }}
  194. run: |
  195. set -e -u -x
  196. docker buildx build --no-cache \
  197. --platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386 \
  198. -t lfedge/ekuiper:$(git describe --tags --always)-$SUFFIX \
  199. -f deploy/docker/Dockerfile-$SUFFIX . \
  200. --push
  201. build-kubernetes-tool:
  202. runs-on: ubuntu-latest
  203. steps:
  204. - uses: actions/checkout@v2
  205. with:
  206. fetch-depth: 0
  207. - uses: docker/setup-buildx-action@v1
  208. - uses: docker/setup-qemu-action@v1
  209. with:
  210. image: tonistiigi/binfmt:latest
  211. platforms: all
  212. - name: build docker image
  213. run: docker build --no-cache -t lfedge/ekuiper-kubernetes-tool:$(git describe --tags --always) -f deploy/docker/Dockerfile-kubernetes-tool .
  214. - name: test docker image
  215. run: |
  216. set -e -u -x
  217. docker run -d --name kuiper-kubernetes-tool lfedge/ekuiper-kubernetes-tool:$(git describe --tags --always)
  218. sleep 5
  219. if [[ "$(docker logs kuiper-kubernetes-tool)" != *"Kuiper kubernetes tool is started successfully!"* ]]; then exit 1; fi
  220. - uses: docker/login-action@v1
  221. if: github.event_name == 'release'
  222. with:
  223. username: ${{ secrets.DOCKER_HUB_USER }}
  224. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  225. - name: buildx docker image
  226. if: github.event_name == 'release'
  227. run: |
  228. docker buildx build --no-cache \
  229. --platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386 \
  230. -t lfedge/ekuiper-kubernetes-tool:$(git describe --tags --always) \
  231. -f deploy/docker/Dockerfile-kubernetes-tool . \
  232. --push
  233. release:
  234. runs-on: ubuntu-latest
  235. needs:
  236. - build
  237. - build-on-mac
  238. - build-plugins
  239. steps:
  240. - uses: actions/checkout@v2
  241. - uses: actions/download-artifact@v1
  242. with:
  243. name: packages
  244. path: _packages
  245. - uses: actions/download-artifact@v1
  246. with:
  247. name: packages-mac
  248. path: _packages
  249. - uses: actions/download-artifact@v1
  250. with:
  251. name: plugins
  252. path: _plugins
  253. - name: check packages
  254. run: |
  255. cd _packages && for var in $( ls |grep -v sha256); do
  256. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  257. done
  258. - uses: Rory-Z/upload-release-asset@v1
  259. if: github.event_name == 'release'
  260. with:
  261. repo: ekuiper
  262. path: "_packages/kuiper-*"
  263. token: ${{ secrets.GITHUB_TOKEN }}