build_packages.yaml 13 KB

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