build_packages.yaml 12 KB

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