build_packages.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. name: Build packages
  2. concurrency:
  3. group: build-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. push:
  7. tags:
  8. - "*"
  9. pull_request:
  10. release:
  11. types:
  12. - published
  13. jobs:
  14. build:
  15. runs-on: ubuntu-latest
  16. strategy:
  17. matrix:
  18. golang:
  19. - 1.15.11
  20. arch:
  21. - linux/amd64
  22. - linux/arm64
  23. os:
  24. - debian
  25. - centos
  26. steps:
  27. - uses: actions/checkout@v2
  28. with:
  29. fetch-depth: 0
  30. - uses: docker/setup-buildx-action@v1
  31. - uses: docker/setup-qemu-action@v1
  32. with:
  33. image: tonistiigi/binfmt:latest
  34. platforms: all
  35. - uses: docker/setup-buildx-action@v1
  36. - name: build
  37. run: |
  38. docker run -i --rm \
  39. -v $(pwd):/ekuiper \
  40. --workdir /ekuiper \
  41. --platform ${{ matrix.arch }} \
  42. ghcr.io/lf-edge/ekuiper/base:${{ matrix.golang }}-${{ matrix.os }} \
  43. bash -euc "make pkg && .github/scripts/test.sh"
  44. cd _packages && for var in $(ls); do sudo bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd -
  45. - uses: actions/upload-artifact@v1
  46. with:
  47. name: packages
  48. path: _packages/.
  49. build-on-mac:
  50. runs-on: macos-latest
  51. steps:
  52. - uses: actions/checkout@v2
  53. with:
  54. fetch-depth: 0
  55. - uses: actions/setup-go@v2
  56. with:
  57. go-version: '1.15.1'
  58. - name: prepare
  59. run: |
  60. brew install curl zip unzip gnu-sed upx pkg-config zmq
  61. echo "/usr/local/bin:$PATH" >> ~/.bashrc
  62. - name: build
  63. run: |
  64. make pkg
  65. cd _packages && for var in $(ls); do openssl dgst -sha256 $var | awk '{print $2}' > $var.sha256; done && cd -
  66. - uses: actions/upload-artifact@v1
  67. with:
  68. name: packages-mac
  69. path: _packages/.
  70. build-docker-images:
  71. runs-on: ubuntu-latest
  72. strategy:
  73. fail-fast: false
  74. matrix:
  75. suffix:
  76. - ""
  77. - "-slim"
  78. - "-alpine"
  79. steps:
  80. - uses: actions/checkout@v2
  81. with:
  82. fetch-depth: 0
  83. - uses: docker/setup-buildx-action@v1
  84. - uses: docker/setup-qemu-action@v1
  85. with:
  86. image: tonistiigi/binfmt:latest
  87. platforms: all
  88. - name: Build single platform image
  89. id: single_image
  90. uses: docker/build-push-action@v2
  91. with:
  92. context: .
  93. platforms: linux/amd64
  94. push: false
  95. load: true
  96. tags: docker.io/lfedge/ekuiper
  97. file: deploy/docker/Dockerfile${{ matrix.suffix }}
  98. - name: Test docker image
  99. run: |
  100. docker run -d --name ekuiper docker.io/lfedge/ekuiper
  101. ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ekuiper)
  102. sleep 5
  103. if ! curl ${ip_address}:9081 >/dev/null 2>&1; then
  104. echo "docker image failed"
  105. docker logs ekuiper
  106. exit 1
  107. fi
  108. - uses: docker/metadata-action@v3
  109. id: meta
  110. with:
  111. images: docker.io/lfedge/ekuiper
  112. flavor: |
  113. latest=${{ github.event_name == 'release' && !github.event.release.prerelease}}
  114. suffix=${{ matrix.suffix }}
  115. tags: |
  116. type=ref,event=branch
  117. type=ref,event=pr
  118. type=ref,event=tag
  119. type=semver,pattern={{version}}
  120. type=semver,pattern={{major}}.{{minor}}
  121. - uses: docker/login-action@v1
  122. if: github.event_name == 'release'
  123. with:
  124. username: ${{ secrets.DOCKER_HUB_USER }}
  125. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  126. - name: Build multi platform image
  127. uses: docker/build-push-action@v2
  128. with:
  129. context: .
  130. platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
  131. push: ${{ github.event_name == 'release' }}
  132. tags: ${{ steps.meta.outputs.tags }}
  133. labels: ${{ steps.meta.outputs.labels }}
  134. file: deploy/docker/Dockerfile${{ matrix.suffix }}
  135. build-plugins:
  136. runs-on: ubuntu-latest
  137. strategy:
  138. fail-fast: false
  139. matrix:
  140. plugin:
  141. - sinks/file
  142. - sinks/image
  143. - sinks/influx
  144. - sinks/tdengine
  145. - sinks/zmq
  146. - sinks/redis
  147. - sources/random
  148. - sources/zmq
  149. - functions/accumulateWordCount
  150. - functions/countPlusOne
  151. - functions/echo
  152. - functions/image
  153. - functions/geohash
  154. - functions/labelImage
  155. arch:
  156. - linux/amd64
  157. - linux/arm64
  158. golang:
  159. - 1.15.11
  160. exclude:
  161. - arch: linux/arm64
  162. plugin: functions/labelImage
  163. steps:
  164. - uses: actions/checkout@v2
  165. with:
  166. fetch-depth: 0
  167. - uses: docker/setup-buildx-action@v1
  168. - uses: docker/setup-qemu-action@v1
  169. with:
  170. image: tonistiigi/binfmt:latest
  171. platforms: all
  172. - name: build debian plugins
  173. run: |
  174. docker run -i --rm \
  175. -v $(pwd):/ekuiper \
  176. --workdir /ekuiper \
  177. --platform ${{ matrix.arch }} \
  178. ghcr.io/lf-edge/ekuiper/base:${{ matrix.golang }}-debian \
  179. bash -euc "make ${{ matrix.plugin }}"
  180. - name: Build ekuiper image
  181. uses: docker/build-push-action@v2
  182. if: matrix.arch == 'linux/amd64'
  183. with:
  184. context: .
  185. platforms: linux/amd64
  186. push: false
  187. load: true
  188. tags: docker.io/lfedge/ekuiper
  189. file: deploy/docker/Dockerfile
  190. - name: test docker and plugins
  191. if: matrix.arch == 'linux/amd64'
  192. env:
  193. PLUGIN: ${{ matrix.plugin }}
  194. run: |
  195. set -e -x -u
  196. plugin_type=$(echo ${PLUGIN%%/*})
  197. plugin_name=$(echo ${PLUGIN##*/})
  198. container_id=$(docker run -d -v $(pwd)/_plugins:/var/plugins docker.io/lfedge/ekuiper)
  199. ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container_id)
  200. os=$(docker exec -i ${container_id} sh -c "sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g'" )
  201. sleep 5
  202. if ! curl ${ip_address}:9081 >/dev/null 2>&1; then echo "docker image failed"; exit 1; fi
  203. if [ "${plugin_name}" = "tdengine" ]; then
  204. curl \
  205. ${ip_address}:9081/plugins/${plugin_type} \
  206. -X POST \
  207. -d "{\"name\":\"${plugin_name}\", \"file\":\"file:///var/plugins/${os}/${plugin_type}/${plugin_name}_amd64.zip\", \"shellParas\": [\"2.0.3.1\"]}"
  208. elif [ "${plugin_name}" = "image" ]; then
  209. curl \
  210. ${ip_address}:9081/plugins/${plugin_type} \
  211. -X POST \
  212. -d "{\"name\":\"${plugin_name}\", \"file\":\"file:///var/plugins/${os}/${plugin_type}/${plugin_name}_amd64.zip\", \"functions\": [\"resize\",\"thumbnail\"]}"
  213. elif [ "${plugin_name}" = "geohash" ]; then
  214. curl \
  215. ${ip_address}:9081/plugins/${plugin_type} \
  216. -X POST \
  217. -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\"]}"
  218. else
  219. curl \
  220. ${ip_address}:9081/plugins/${plugin_type} \
  221. -X POST \
  222. -d "{\"name\":\"${plugin_name}\", \"file\":\"file:///var/plugins/${os}/${plugin_type}/${plugin_name}_amd64.zip\"}"
  223. fi
  224. docker logs ${container_id}
  225. [ $plugin_name = $(curl ${ip_address}:9081/plugins/${plugin_type}/${plugin_name} | jq '.name'| sed 's/\"//g' ) ] || exit 1
  226. - uses: actions/upload-artifact@v2
  227. with:
  228. name: plugins
  229. path: "_plugins/"
  230. build-kubernetes-tool:
  231. runs-on: ubuntu-latest
  232. steps:
  233. - uses: actions/checkout@v2
  234. with:
  235. fetch-depth: 0
  236. - uses: docker/setup-buildx-action@v1
  237. - uses: docker/setup-qemu-action@v1
  238. with:
  239. image: tonistiigi/binfmt:latest
  240. platforms: all
  241. - name: Build single platform image
  242. uses: docker/build-push-action@v2
  243. with:
  244. context: .
  245. platforms: linux/amd64
  246. push: false
  247. load: true
  248. tags: docker.io/lfedge/ekuiper-kubernetes-tool
  249. file: deploy/docker/Dockerfile-kubernetes-tool
  250. - name: Test docker image
  251. run: |
  252. docker run -d --name kuiper-kubernetes-tool docker.io/lfedge/ekuiper-kubernetes-tool
  253. sleep 5
  254. if [[ "$(docker logs kuiper-kubernetes-tool)" != *"Kuiper kubernetes tool is started successfully!"* ]]; then exit 1; fi
  255. - uses: docker/metadata-action@v3
  256. id: meta
  257. with:
  258. images: docker.io/lfedge/ekuiper-kubernetes-tool
  259. flavor: |
  260. latest=${{ github.event_name == 'release' && !github.event.release.prerelease}}
  261. tags: |
  262. type=ref,event=branch
  263. type=ref,event=pr
  264. type=ref,event=tag
  265. type=semver,pattern={{version}}
  266. type=semver,pattern={{major}}.{{minor}}
  267. - uses: docker/login-action@v1
  268. if: github.event_name == 'release'
  269. with:
  270. username: ${{ secrets.DOCKER_HUB_USER }}
  271. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  272. - name: Build multi platform image
  273. uses: docker/build-push-action@v2
  274. with:
  275. context: .
  276. platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
  277. push: ${{ github.event_name == 'release' }}
  278. tags: ${{ steps.meta.outputs.tags }}
  279. labels: ${{ steps.meta.outputs.labels }}
  280. file: deploy/docker/Dockerfile-kubernetes-tool
  281. release:
  282. runs-on: ubuntu-latest
  283. needs:
  284. - build
  285. - build-on-mac
  286. - build-plugins
  287. steps:
  288. - uses: actions/checkout@v2
  289. - uses: actions/download-artifact@v1
  290. with:
  291. name: packages
  292. path: _packages
  293. - uses: actions/download-artifact@v1
  294. with:
  295. name: packages-mac
  296. path: _packages
  297. - uses: actions/download-artifact@v1
  298. with:
  299. name: plugins
  300. path: _plugins
  301. - name: check packages
  302. run: |
  303. cd _packages && for var in $( ls |grep -v sha256); do
  304. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  305. done
  306. - uses: Rory-Z/upload-release-asset@v1
  307. if: github.event_name == 'release'
  308. with:
  309. repo: ekuiper
  310. path: "_packages/kuiper-*"
  311. token: ${{ secrets.GITHUB_TOKEN }}
  312. - name: upload plugins to s3
  313. if: github.event_name == 'release'
  314. run: |
  315. version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g")
  316. aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
  317. aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  318. aws configure set default.region us-west-2
  319. aws s3 rm --quiet --recursive s3://packages.emqx/kuiper/$version
  320. aws s3 cp --quiet --recursive ./_packages s3://packages.emqx/kuiper/$version
  321. aws s3 cp --quiet --recursive ./_plugins s3://packages.emqx/kuiper-plugins/$version
  322. aws cloudfront create-invalidation --distribution-id E170YEULGLT8XB --paths "/kuiper/$version/*,/kuiper-plugins/$version/*"