build_packages.yaml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. name: Cross build packages
  2. concurrency:
  3. group: build-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. schedule:
  7. - cron: '0 */6 * * *'
  8. push:
  9. branches:
  10. - 'ci/**'
  11. release:
  12. types:
  13. - published
  14. workflow_dispatch:
  15. inputs:
  16. which_branch:
  17. required: false
  18. jobs:
  19. prepare:
  20. runs-on: ubuntu-20.04
  21. # prepare source with any OTP version, no need for a matrix
  22. container: "ghcr.io/emqx/emqx-builder/5.0-7:1.13.3-24.2.1-1-ubuntu20.04"
  23. outputs:
  24. DEP_ROCKSDB_REF: ${{ steps.deps-refs.outputs.DEP_ROCKSDB_REF }}
  25. DEP_QUICER_REF: ${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  26. steps:
  27. - uses: actions/checkout@v2
  28. with:
  29. ref: ${{ github.event.inputs.which_branch }}
  30. path: source
  31. fetch-depth: 0
  32. - name: Get deps git refs for cache
  33. id: deps-refs
  34. working-directory: source
  35. run: |
  36. bash -x scripts/get-dep-refs.sh
  37. make clean-all
  38. - name: get_all_deps
  39. run: |
  40. make -C source deps-all
  41. zip -ryq source.zip source/* source/.[^.]*
  42. - uses: actions/upload-artifact@v2
  43. with:
  44. name: source
  45. path: source.zip
  46. windows:
  47. runs-on: windows-2019
  48. needs: prepare
  49. strategy:
  50. fail-fast: false
  51. matrix:
  52. profile: # for now only CE for windows
  53. - emqx
  54. otp:
  55. - 24.2.1
  56. steps:
  57. - uses: actions/download-artifact@v2
  58. with:
  59. name: source
  60. path: .
  61. - name: unzip source code
  62. run: Expand-Archive -Path source.zip -DestinationPath ./
  63. - uses: ilammy/msvc-dev-cmd@v1
  64. - uses: erlef/setup-beam@v1
  65. with:
  66. otp-version: ${{ matrix.otp }}
  67. - name: build
  68. env:
  69. PYTHON: python
  70. DIAGNOSTIC: 1
  71. working-directory: source
  72. run: |
  73. # ensure crypto app (openssl)
  74. erl -eval "erlang:display(crypto:info_lib())" -s init stop
  75. make ${{ matrix.profile }}-tgz
  76. - name: run emqx
  77. timeout-minutes: 5
  78. working-directory: source
  79. run: |
  80. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx start
  81. Start-Sleep -s 5
  82. echo "EMQX started"
  83. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx stop
  84. echo "EMQX stopped"
  85. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx install
  86. echo "EMQX installed"
  87. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx uninstall
  88. echo "EMQX uninstalled"
  89. - uses: actions/upload-artifact@v1
  90. if: startsWith(github.ref, 'refs/tags/')
  91. with:
  92. name: ${{ matrix.profile }}-windows
  93. path: source/_packages/${{ matrix.profile }}/.
  94. mac:
  95. needs: prepare
  96. strategy:
  97. fail-fast: false
  98. matrix:
  99. profile: # no EDGE for mac
  100. - emqx
  101. - emqx-enterprise
  102. otp:
  103. - 24.2.1-1
  104. os:
  105. - macos-11
  106. - macos-10.15
  107. exclude:
  108. - profile: emqx-edge
  109. runs-on: ${{ matrix.os }}
  110. steps:
  111. - uses: actions/download-artifact@v2
  112. with:
  113. name: source
  114. path: .
  115. - name: unzip source code
  116. run: unzip -q source.zip
  117. - name: prepare
  118. run: |
  119. brew update
  120. brew install curl zip unzip gnu-sed kerl unixodbc freetds
  121. echo "/usr/local/bin" >> $GITHUB_PATH
  122. git config --global credential.helper store
  123. - uses: actions/cache@v2
  124. id: cache
  125. with:
  126. path: ~/.kerl/${{ matrix.otp }}
  127. key: otp-install-${{ matrix.otp }}-${{ matrix.os }}
  128. - name: build erlang
  129. if: steps.cache.outputs.cache-hit != 'true'
  130. timeout-minutes: 60
  131. env:
  132. KERL_BUILD_BACKEND: git
  133. OTP_GITHUB_URL: https://github.com/emqx/otp
  134. run: |
  135. kerl update releases
  136. kerl build ${{ matrix.otp }}
  137. kerl install ${{ matrix.otp }} $HOME/.kerl/${{ matrix.otp }}
  138. - name: load rocksdb cache
  139. uses: actions/cache@v2
  140. with:
  141. path: source/_build/default/lib/rocksdb/
  142. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ needs.prepare.outputs.DEP_ROCKSDB_REF }}
  143. - name: load quicer cache
  144. uses: actions/cache@v2
  145. with:
  146. path: source/_build/default/lib/quicer/
  147. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ needs.prepare.outputs.DEP_QUICER_REF }}
  148. - name: build
  149. working-directory: source
  150. run: |
  151. . $HOME/.kerl/${{ matrix.otp }}/activate
  152. make ensure-rebar3
  153. sudo cp rebar3 /usr/local/bin/rebar3
  154. rm -rf _build/${{ matrix.profile }}/lib
  155. make ${{ matrix.profile }}-tgz
  156. - name: test
  157. working-directory: source
  158. run: |
  159. pkg_name=$(find _packages/${{ matrix.profile }} -mindepth 1 -maxdepth 1 -iname \*.tar.gz)
  160. tar -zxf $pkg_name
  161. # gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins
  162. ./emqx/bin/emqx start || cat emqx/log/erlang.log.1
  163. ready='no'
  164. for i in {1..10}; do
  165. if curl -fs 127.0.0.1:18083/api/v5/status > /dev/null; then
  166. ready='yes'
  167. break
  168. fi
  169. sleep 1
  170. done
  171. if [ "$ready" != "yes" ]; then
  172. echo "Timed out waiting for emqx to be ready"
  173. cat emqx/log/erlang.log.1
  174. exit 1
  175. fi
  176. ./emqx/bin/emqx_ctl status
  177. ./emqx/bin/emqx stop
  178. rm -rf emqx
  179. - uses: actions/upload-artifact@v1
  180. if: startsWith(github.ref, 'refs/tags/')
  181. with:
  182. name: ${{ matrix.profile }}-${{ matrix.otp }}
  183. path: source/_packages/${{ matrix.profile }}/.
  184. linux:
  185. needs: prepare
  186. runs-on: ${{ matrix.build_machine }}
  187. container:
  188. image: "ghcr.io/emqx/emqx-builder/5.0-7:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  189. strategy:
  190. fail-fast: false
  191. matrix:
  192. profile: ## all editions for linux
  193. - emqx-edge
  194. - emqx
  195. - emqx-enterprise
  196. otp:
  197. - 24.2.1-1 # we test with OTP 23, but only build package on OTP 24 versions
  198. elixir:
  199. - 1.13.3
  200. # used to split elixir packages into a separate job, since the
  201. # entire job may take a lot of time, especially on arm64
  202. # emulation.
  203. # we only want to build ubuntu and centos with elixir for the
  204. # time being, so it's easier to just include those with
  205. # `with_elixir` set.
  206. build_elixir:
  207. # - with_elixir
  208. - no_elixir
  209. arch:
  210. - amd64
  211. - arm64
  212. os:
  213. - ubuntu20.04
  214. - ubuntu18.04
  215. - ubuntu16.04
  216. - debian10
  217. - debian9
  218. # - opensuse
  219. - centos7
  220. - raspbian10
  221. # - raspbian9
  222. build_machine:
  223. - aws-arm64
  224. - ubuntu-20.04
  225. exclude:
  226. - arch: arm64
  227. build_machine: ubuntu-20.04
  228. - arch: amd64
  229. build_machine: aws-arm64
  230. - os: raspbian9
  231. arch: amd64
  232. - os: raspbian10
  233. arch: amd64
  234. - os: raspbian10 # we only have arm32 image
  235. arch: arm64
  236. - os: raspbian9
  237. profile: emqx
  238. - os: raspbian10
  239. profile: emqx
  240. - os: raspbian9
  241. profile: emqx-enterprise
  242. - os: raspbian10
  243. profile: emqx-enterprise
  244. include:
  245. - profile: emqx
  246. otp: 24.2.1-1
  247. elixir: 1.13.3
  248. build_elixir: with_elixir
  249. arch: amd64
  250. os: ubuntu20.04
  251. build_machine: ubuntu-20.04
  252. - profile: emqx
  253. otp: 24.2.1-1
  254. elixir: 1.13.3
  255. build_elixir: with_elixir
  256. arch: amd64
  257. os: centos7
  258. build_machine: ubuntu-20.04
  259. defaults:
  260. run:
  261. shell: bash
  262. steps:
  263. - uses: AutoModality/action-clean@v1
  264. if: matrix.build_machine == 'aws-arm64'
  265. - uses: actions/download-artifact@v2
  266. with:
  267. name: source
  268. path: .
  269. - name: unzip source code
  270. run: unzip -q source.zip
  271. - name: load rocksdb cache
  272. uses: actions/cache@v2
  273. with:
  274. path: |
  275. source/_build/default/lib/rocksdb/
  276. source/deps/rocksdb/
  277. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ needs.prepare.outputs.DEP_ROCKSDB_REF }}
  278. - name: load quicer cache
  279. uses: actions/cache@v2
  280. with:
  281. path: |
  282. source/_build/default/lib/quicer/
  283. source/deps/quicer/
  284. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ needs.prepare.outputs.DEP_QUICER_REF }}
  285. - name: build emqx packages
  286. working-directory: source
  287. env:
  288. OTP: ${{ matrix.otp }}
  289. ELIXIR: ${{ matrix.elixir }}
  290. PROFILE: ${{ matrix.profile }}
  291. ARCH: ${{ matrix.arch }}
  292. SYSTEM: ${{ matrix.os }}
  293. run: |
  294. set -eu
  295. # Align path for CMake caches
  296. if [ ! "$PWD" = "/emqx" ]; then
  297. ln -s $PWD /emqx
  298. cd /emqx
  299. fi
  300. echo "pwd is $PWD"
  301. PkgTypes="tgz pkg"
  302. WithElixir=""
  303. if [ ${{ matrix.build_elixir }} = "with_elixir" ]; then
  304. PkgTypes="tgz"
  305. # set Elixir build flag
  306. WithElixir="--with-elixir"
  307. fi
  308. for PKGTYPE in ${PkgTypes};
  309. do
  310. ./scripts/buildx.sh \
  311. --profile "${PROFILE}" \
  312. --pkgtype "${PKGTYPE}" \
  313. --arch "${ARCH}" \
  314. --otp "${OTP}" \
  315. --elixir "${ELIXIR}" "$WithElixir" \
  316. --system "${SYSTEM}" \
  317. --builder "ghcr.io/emqx/emqx-builder/5.0-7:${ELIXIR}-${OTP}-${SYSTEM}"
  318. done
  319. - uses: actions/upload-artifact@v1
  320. if: startsWith(github.ref, 'refs/tags/')
  321. with:
  322. name: ${{ matrix.profile }}-${{ matrix.otp }}
  323. path: source/_packages/${{ matrix.profile }}/.
  324. docker:
  325. runs-on: ${{ matrix.build_machine }}
  326. needs: prepare
  327. strategy:
  328. fail-fast: false
  329. matrix:
  330. os:
  331. - alpine3.14
  332. profile: # all editions for docker
  333. - emqx-edge
  334. - emqx
  335. - emqx-enterprise
  336. # NOTE: for docker, only support latest otp and elixir
  337. # versions, not a matrix
  338. otp:
  339. - 24.2.1-1 # update to latest
  340. elixir:
  341. - 1.13.3 # update to latest
  342. arch:
  343. - amd64
  344. - arm64
  345. build_elixir:
  346. - no_elixir
  347. build_machine:
  348. - aws-arm64
  349. - ubuntu-20.04
  350. exclude:
  351. - arch: arm64
  352. build_machine: ubuntu-20.04
  353. - arch: amd64
  354. build_machine: aws-arm64
  355. include:
  356. - os: alpine3.14
  357. profile: emqx
  358. otp: 24.2.1-1
  359. elixir: 1.13.3
  360. arch: amd64
  361. build_elixir: with_elixir
  362. build_machine: ubuntu-20.04
  363. steps:
  364. - uses: AutoModality/action-clean@v1
  365. if: matrix.build_machine == 'aws-arm64'
  366. - uses: actions/download-artifact@v2
  367. with:
  368. name: source
  369. path: .
  370. - name: unzip source code
  371. run: unzip -q source.zip
  372. - uses: docker/setup-buildx-action@v1
  373. - name: load rocksdb cache
  374. uses: actions/cache@v2
  375. with:
  376. path: |
  377. source/_build/default/lib/rocksdb/
  378. source/deps/rocksdb//
  379. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ needs.prepare.outputs.DEP_ROCKSDB_REF }}
  380. - name: load quicer cache
  381. uses: actions/cache@v2
  382. with:
  383. path: |
  384. source/_build/default/lib/quicer/
  385. source/deps/quicer/
  386. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ needs.prepare.outputs.DEP_QUICER_REF }}
  387. - uses: docker/login-action@v1
  388. with:
  389. username: ${{ secrets.DOCKER_HUB_USER }}
  390. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  391. - name: prepare for docker-action-parms
  392. id: pre-meta
  393. run: |
  394. img=$(echo ${{ matrix.os }} | sed 's#\([0-9.]\+\)$#:\1#g')
  395. emqx_name=${{ matrix.profile }}
  396. img_suffix=${{ matrix.arch }}
  397. img_labels="org.opencontainers.image.otp.version=${{ matrix.otp }}"
  398. if [ ${{ matrix.build_elixir }} = "with_elixir" ]; then
  399. emqx_name="emqx-elixir"
  400. img_suffix="elixir-${{ matrix.arch }}"
  401. img_labels="org.opencontainers.image.elixir.version=${{ matrix.elixir }}\n${img_labels}"
  402. fi
  403. echo "::set-output name=img::${img}"
  404. echo "::set-output name=emqx_name::${emqx_name}"
  405. echo "::set-output name=img_suffix::${img_suffix}"
  406. echo "::set-output name=img_labels::${img_labels}"
  407. # NOTE, Pls make sure this is identical as the one in job 'docker-push-multi-arch-manifest'
  408. - uses: docker/metadata-action@v3
  409. id: meta
  410. with:
  411. images: ${{ github.repository_owner }}/${{ matrix.profile }}
  412. flavor: |
  413. latest=${{ github.event_name == 'release' && !github.event.release.prerelease }}
  414. suffix=-${{ steps.pre-meta.outputs.img_suffix }}
  415. tags: |
  416. type=ref,event=branch
  417. type=ref,event=pr
  418. type=ref,event=tag
  419. type=semver,pattern={{version}}
  420. labels:
  421. ${{ steps.pre-meta.outputs.img_labels }}
  422. - uses: docker/build-push-action@v2
  423. with:
  424. push: >
  425. ${{ (github.event_name == 'release' && !github.event.release.prerelease)
  426. || (github.event.repository.owner != 'emqx' && startsWith(github.ref_name, 'ci/')) }}
  427. pull: true
  428. no-cache: true
  429. platforms: linux/${{ matrix.arch }}
  430. tags: ${{ steps.meta.outputs.tags }}
  431. labels: ${{ steps.meta.outputs.labels }}
  432. build-args: |
  433. BUILD_FROM=ghcr.io/emqx/emqx-builder/5.0-7:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  434. RUN_FROM=${{ steps.pre-meta.outputs.img }}
  435. EMQX_NAME=${{ steps.pre-meta.outputs.emqx_name }}
  436. file: source/deploy/docker/Dockerfile
  437. context: source
  438. - uses: aws-actions/configure-aws-credentials@v1
  439. if: matrix.profile == 'emqx'
  440. with:
  441. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  442. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  443. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  444. - name: Docker push to aws ecr
  445. if: >
  446. ${{ (github.event_name == 'release' && !github.event.release.prerelease && matrix.profile == 'emqx')
  447. || (github.event.repository.owner != 'emqx' && startsWith(github.ref_name, 'ci/')) }}
  448. run: |
  449. aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
  450. for tag in $(echo ${{ steps.meta.outputs.json }} | jq -c '.tags[]'); do
  451. docker pull "$tag"
  452. docker tag "$tag" "public.ecr.aws/$tag"
  453. docker push "public.ecr.aws/$tag"
  454. done
  455. docker-push-multi-arch-manifest:
  456. # note, we only run on amd64
  457. if: >
  458. (github.event_name == 'release' && !github.event.release.prerelease)
  459. || (github.event.repository.owner != 'emqx' && startsWith(github.ref_name, 'ci/'))
  460. needs:
  461. - prepare
  462. - docker
  463. runs-on: ubuntu-latest
  464. strategy:
  465. fail-fast: false
  466. matrix:
  467. profile: # all editions for docker
  468. - emqx-edge
  469. - emqx
  470. - emqx-enterprise
  471. # NOTE: for docker, only support latest otp version, not a matrix
  472. otp:
  473. - 24.2.1-1 # update to latest
  474. #
  475. elixir:
  476. - 1.13.3 # update to latest
  477. arch:
  478. - amd64
  479. - arm64
  480. build_elixir:
  481. - no_elixir
  482. build_machine:
  483. - aws-arm64
  484. - ubuntu-20.04
  485. exclude:
  486. - arch: arm64
  487. build_machine: ubuntu-20.04
  488. - arch: amd64
  489. build_machine: aws-arm64
  490. include:
  491. - os: alpine3.14
  492. profile: emqx
  493. otp: 24.2.1-1
  494. elixir: 1.13.3
  495. arch: amd64
  496. build_elixir: with_elixir
  497. build_machine: ubuntu-20.04
  498. steps:
  499. - uses: actions/download-artifact@v2
  500. if: matrix.arch == 'amd64'
  501. with:
  502. name: source
  503. path: .
  504. - name: unzip source code
  505. if: matrix.arch == 'amd64'
  506. run: unzip -q source.zip
  507. - uses: docker/login-action@v1
  508. if: matrix.arch == 'amd64'
  509. with:
  510. username: ${{ secrets.DOCKER_HUB_USER }}
  511. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  512. - name: prepare for docker-action-parms
  513. id: pre-meta
  514. run: |
  515. img=$(echo ${{ matrix.os }} | sed 's#\([0-9.]\+\)$#:\1#g')
  516. emqx_name=${{ matrix.profile }}
  517. img_suffix=${{ matrix.arch }}
  518. img_labels="org.opencontainers.image.otp.version=${{ matrix.otp }}"
  519. if [ ${{ matrix.build_elixir }} = "with_elixir" ]; then
  520. emqx_name="emqx-elixir"
  521. img_suffix="elixir-${{ matrix.arch }}"
  522. img_labels="org.opencontainers.image.elixir.version=${{ matrix.elixir }}\n$img_labels"
  523. fi
  524. echo "::set-output name=img::${img}"
  525. echo "::set-output name=emqx_name::${emqx_name}"
  526. echo "::set-output name=img_suffix::${img_suffix}"
  527. echo "::set-output name=img_labels::${img_labels}"
  528. # NOTE, Pls make sure this is identical as the one in job 'docker'
  529. - uses: docker/metadata-action@v3
  530. if: matrix.arch == 'amd64'
  531. id: meta
  532. with:
  533. images: ${{ github.repository_owner }}/${{ matrix.profile }}
  534. flavor: |
  535. latest=false
  536. suffix=-${{ steps.pre-meta.outputs.img_suffix }}
  537. tags: |
  538. type=ref,event=branch
  539. type=ref,event=pr
  540. type=ref,event=tag
  541. type=semver,pattern={{version}}
  542. labels:
  543. ${{ steps.pre-meta.outputs.img_labels }}
  544. - name: update manifest for multiarch image
  545. if: matrix.arch == 'amd64'
  546. working-directory: source
  547. run: |
  548. IsPushLatest=${{ github.event_name == 'release' && !github.event.release.prerelease }};
  549. scripts/docker-create-push-manifests.sh "${{ steps.meta.outputs.tags }}" "$IsPushLatest"
  550. - uses: aws-actions/configure-aws-credentials@v1
  551. if: matrix.profile == 'emqx' && matrix.arch == 'amd64'
  552. with:
  553. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  554. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  555. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  556. - name: Docker push to aws ecr
  557. if: matrix.profile == 'emqx' && matrix.arch == 'amd64'
  558. run: |
  559. aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
  560. IsPushLatest=${{ github.event_name == 'release' && !github.event.release.prerelease }};
  561. scripts/docker-create-push-manifests.sh "public.ecr.aws/${{ steps.meta.outputs.tags }}" "$IsPushLatest"
  562. delete-artifact:
  563. runs-on: ubuntu-20.04
  564. needs: [prepare, mac, linux, docker]
  565. steps:
  566. - uses: geekyeggo/delete-artifact@v1
  567. with:
  568. name: source
  569. upload:
  570. runs-on: ubuntu-20.04
  571. if: startsWith(github.ref, 'refs/tags/')
  572. needs: [prepare, mac, linux, docker]
  573. strategy:
  574. fail-fast: false
  575. matrix:
  576. profile:
  577. - emqx-edge
  578. - emqx
  579. - emqx-enterprise
  580. otp:
  581. - 24.2.1-1
  582. include:
  583. - profile: emqx
  584. otp: windows # otp version on windows is rather fixed
  585. steps:
  586. - uses: actions/checkout@v2
  587. - name: get_version
  588. run: |
  589. echo 'version<<EOF' >> $GITHUB_ENV
  590. echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g" >> $GITHUB_ENV
  591. echo 'EOF' >> $GITHUB_ENV
  592. - uses: actions/download-artifact@v2
  593. with:
  594. name: ${{ matrix.profile }}-${{ matrix.otp }}
  595. path: ./_packages/${{ matrix.profile }}
  596. - name: install dos2unix
  597. run: sudo apt-get update && sudo apt install -y dos2unix
  598. - name: get packages
  599. run: |
  600. set -e -u
  601. cd _packages/${{ matrix.profile }}
  602. for var in $( ls |grep emqx |grep -v sha256); do
  603. dos2unix $var.sha256
  604. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  605. done
  606. cd -
  607. - name: upload aws s3
  608. run: |
  609. set -e -u
  610. PROFILE=${{ matrix.profile }}
  611. if [ $PROFILE = 'emqx' ]; then
  612. s3dir='emqx-ce'
  613. elif [ $PROFILE = 'emqx-enterprise' ]; then
  614. s3dir='emqx-ee'
  615. elif [ $PROFILE = 'emqx-edge' ]; then
  616. s3dir='emqx-edge'
  617. else
  618. echo "unknown profile $PROFILE"
  619. exit 1
  620. fi
  621. aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
  622. aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  623. aws configure set default.region ${{ secrets.AWS_DEFAULT_REGION }}
  624. aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ env.version }}
  625. aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ env.version }}/*"
  626. - uses: Rory-Z/upload-release-asset@v1
  627. if: github.event_name == 'release'
  628. with:
  629. repo: emqx
  630. path: "_packages/${{ matrix.profile }}/emqx-*"
  631. token: ${{ github.token }}
  632. - name: update to emqx.io
  633. if: github.event_name == 'release'
  634. run: |
  635. set -e -x -u
  636. curl -w %{http_code} \
  637. --insecure \
  638. -H "Content-Type: application/json" \
  639. -H "token: ${{ secrets.EMQX_IO_TOKEN }}" \
  640. -X POST \
  641. -d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ env.version }}\" }" \
  642. ${{ secrets.EMQX_IO_RELEASE_API }}
  643. - name: update repo.emqx.io
  644. if: github.event_name == 'release'
  645. run: |
  646. if [ "${{ matrix.profile }}" = 'emqx-enterprise' ]; then
  647. BOOL_FLAG_NAME="emqx_ee"
  648. else
  649. BOOL_FLAG_NAME="emqx_ce"
  650. fi
  651. curl --silent --show-error \
  652. -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
  653. -H "Accept: application/vnd.github.v3+json" \
  654. -X POST \
  655. -d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ env.version }}\", \"${BOOL_FLAG_NAME}\": \"true\"}}" \
  656. "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_repos.yaml/dispatches"
  657. - name: update homebrew packages
  658. if: github.event_name == 'release' && matrix.profile == 'emqx'
  659. run: |
  660. if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then
  661. curl --silent --show-error \
  662. -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
  663. -H "Accept: application/vnd.github.v3+json" \
  664. -X POST \
  665. -d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ env.version }}\"}}" \
  666. "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches"
  667. fi
  668. - uses: geekyeggo/delete-artifact@v1
  669. with:
  670. name: ${{ matrix.profile }}