build_packages.yaml 13 KB

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