docker.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. name: Docker
  2. on:
  3. push:
  4. branches: ["master"]
  5. tags: ["docker/*"]
  6. pull_request:
  7. branches: ["master"]
  8. schedule:
  9. - cron: "13 13 * * 3"
  10. concurrency:
  11. group: ${{ github.workflow }}-${{ github.ref }}
  12. cancel-in-progress: true
  13. jobs:
  14. ############
  15. # Building #
  16. ############
  17. build:
  18. strategy:
  19. fail-fast: false
  20. matrix:
  21. dist: ["alpine", "debian"]
  22. arch:
  23. - amd64
  24. - arm32v6
  25. - arm32v7
  26. - arm64v8
  27. - i386
  28. - ppc64le
  29. - s390x
  30. runs-on: ubuntu-latest
  31. steps:
  32. - uses: actions/checkout@v4
  33. with:
  34. fetch-depth: 0 # for correct image labeling via `git describe --tags`
  35. - uses: docker/setup-buildx-action@v3
  36. - name: Configure `max-parallelism = 1` for Docker BuildKit
  37. run: sudo echo "[worker.oci]\nmax-parallelism = 1"
  38. >> /etc/buildkitd.toml
  39. if: ${{ matrix.arch == 'ppc64le' }}
  40. - name: Create Docker BuildKit builder
  41. run: docker buildx create --use --name container \
  42. --driver docker-container \
  43. --config /etc/buildkitd.toml
  44. if: ${{ matrix.arch == 'ppc64le' }}
  45. - name: Detect correct Git ref for image build
  46. id: git
  47. uses: actions/github-script@v7
  48. with:
  49. script: |
  50. let out = {ref: 'HEAD', ver: ''};
  51. if ('${{ github.ref }}'.startsWith('refs/tags/docker/')) {
  52. out.ref = '${{ github.ref }}'.substring(17).split('-')[0];
  53. out.ver = out.ref;
  54. }
  55. return out;
  56. - name: Verify Git ref matches Makefile version
  57. run: |
  58. test "${{ fromJSON(steps.git.outputs.result).ref }}" \
  59. == "$(grep -m1 'COTURN_VER ?=' Makefile | cut -d'=' -f2 | tr -d ' ')"
  60. working-directory: docker/coturn/
  61. if: ${{ github.event_name == 'push'
  62. && startsWith(github.ref, 'refs/tags/docker/') }}
  63. - run: make docker.image no-cache=yes
  64. dockerfile=${{ matrix.dist }}
  65. platform=linux/${{ matrix.arch }}
  66. ref=${{ fromJSON(steps.git.outputs.result).ref }}
  67. tag=build-${{ github.run_number }}-${{ matrix.dist }}-${{ matrix.arch }}
  68. working-directory: docker/coturn/
  69. - run: make docker.tar to-file=.cache/image.tar
  70. tags=build-${{ github.run_number }}-${{ matrix.dist }}-${{ matrix.arch }}
  71. working-directory: docker/coturn/
  72. - uses: actions/upload-artifact@v4
  73. with:
  74. name: ${{ matrix.dist }}-${{ matrix.arch }}-${{ github.run_number }}
  75. path: docker/coturn/.cache/image.tar
  76. retention-days: 1
  77. ###########
  78. # Testing #
  79. ###########
  80. test:
  81. needs: ["build"]
  82. strategy:
  83. fail-fast: false
  84. matrix:
  85. dist: ["alpine", "debian"]
  86. arch:
  87. - amd64
  88. - arm32v6
  89. - arm32v7
  90. - arm64v8
  91. - i386
  92. - ppc64le
  93. - s390x
  94. # TODO: Try remove on new QEMU or Coturn versions.
  95. # Temporarily exclude `alpine` on `s390x` arch, as QEMU emulation
  96. # currently times out and fails the CI.
  97. exclude:
  98. - dist: alpine
  99. arch: s390x
  100. runs-on: ubuntu-latest
  101. steps:
  102. - uses: actions/checkout@v4
  103. - uses: docker/setup-qemu-action@v3
  104. - run: make npm.install
  105. working-directory: docker/coturn/
  106. - name: Detect correct Git version for image tests
  107. id: git
  108. uses: actions/github-script@v7
  109. with:
  110. script: |
  111. let out = {ref: 'HEAD', ver: ''};
  112. if ('${{ github.ref }}'.startsWith('refs/tags/docker/')) {
  113. out.ref = '${{ github.ref }}'.substring(17).split('-')[0];
  114. out.ver = out.ref;
  115. }
  116. return out;
  117. - uses: actions/download-artifact@v4
  118. with:
  119. name: ${{ matrix.dist }}-${{ matrix.arch }}-${{ github.run_number }}
  120. path: docker/coturn/.cache/
  121. - run: make docker.untar from-file=.cache/image.tar
  122. working-directory: docker/coturn/
  123. - run: make test.docker
  124. platform=linux/${{ matrix.arch }}
  125. tag=build-${{ github.run_number }}-${{ matrix.dist }}-${{ matrix.arch }}
  126. env:
  127. COTURN_VERSION: ${{ fromJSON(steps.git.outputs.result).ver }}
  128. working-directory: docker/coturn/
  129. #############
  130. # Releasing #
  131. #############
  132. push:
  133. if: ${{ github.event_name == 'push'
  134. && github.repository_owner == 'coturn'
  135. && (startsWith(github.ref, 'refs/tags/')
  136. || github.ref == 'refs/heads/master') }}
  137. needs: ["build", "test"]
  138. strategy:
  139. fail-fast: false
  140. max-parallel: 1
  141. matrix:
  142. registry: ["docker.io", "ghcr.io", "quay.io"]
  143. dist: ["alpine", "debian"]
  144. runs-on: ubuntu-latest
  145. steps:
  146. - uses: actions/checkout@v4
  147. - name: Parse Docker image name from Git repository name
  148. id: image
  149. uses: actions-ecosystem/action-regex-match@v2
  150. with:
  151. text: ${{ github.repository }}
  152. regex: '^${{ github.repository_owner }}/(.+)$'
  153. - name: Parse semver versions from Git tag
  154. id: semver
  155. uses: actions-ecosystem/action-regex-match@v2
  156. with:
  157. text: ${{ github.ref }}
  158. regex: '^refs/tags/docker/(((([0-9]+)\.[0-9]+)\.[0-9]+)-(.+))$'
  159. if: ${{ startsWith(github.ref, 'refs/tags/') }}
  160. - name: Form main Docker image tag
  161. id: docker
  162. run: echo "tag=${{ (startsWith(github.ref, 'refs/tags/')
  163. && steps.semver.outputs.group1)
  164. || 'edge' }}-${{ matrix.dist }}"
  165. >> $GITHUB_OUTPUT
  166. - uses: actions/download-artifact@v4
  167. with:
  168. path: docker/coturn/.cache/
  169. - name: Login to ${{ matrix.registry }} container registry
  170. uses: docker/login-action@v3
  171. with:
  172. registry: ${{ matrix.registry }}
  173. username: ${{ (matrix.registry == 'docker.io'
  174. && secrets.DOCKERHUB_BOT_USER)
  175. || (matrix.registry == 'quay.io'
  176. && secrets.QUAYIO_ROBOT_USERNAME)
  177. || github.repository_owner }}
  178. password: ${{ (matrix.registry == 'docker.io'
  179. && secrets.DOCKERHUB_BOT_PASS)
  180. || (matrix.registry == 'quay.io'
  181. && secrets.QUAYIO_ROBOT_TOKEN)
  182. || secrets.GITHUB_TOKEN }}
  183. - name: Tag and push single-platform images
  184. run: |
  185. for arch in amd64 \
  186. arm32v6 \
  187. arm32v7 \
  188. arm64v8 \
  189. i386 \
  190. ppc64le \
  191. s390x
  192. do
  193. make docker.untar \
  194. from-file=.cache/${{ matrix.dist }}-$arch-${{ github.run_number }}/image.tar
  195. make docker.tags \
  196. of=build-${{ github.run_number }}-${{ matrix.dist }}-$arch \
  197. tags=${{ steps.docker.outputs.tag }}-$arch \
  198. registries=${{ matrix.registry }}
  199. make docker.push \
  200. tags=${{ steps.docker.outputs.tag }}-$arch \
  201. registries=${{ matrix.registry }}
  202. done
  203. working-directory: docker/coturn/
  204. - name: Tag and push multi-platform images
  205. run: make docker.manifest push=yes
  206. registries=${{ matrix.registry }}
  207. of='${{ steps.docker.outputs.tag }}-amd64
  208. ${{ steps.docker.outputs.tag }}-arm32v6
  209. ${{ steps.docker.outputs.tag }}-arm32v7
  210. ${{ steps.docker.outputs.tag }}-arm64v8
  211. ${{ steps.docker.outputs.tag }}-i386
  212. ${{ steps.docker.outputs.tag }}-ppc64le
  213. ${{ steps.docker.outputs.tag }}-s390x'
  214. tags=${{ (!startsWith(github.ref, 'refs/tags/')
  215. && steps.docker.outputs.tag)
  216. || '' }}
  217. env:
  218. DOCKERFILE: ${{ matrix.dist }} # for correct `tags` auto-detection
  219. working-directory: docker/coturn/
  220. # On GitHub Container Registry README is automatically updated on pushes.
  221. - name: Update README on Docker Hub
  222. uses: christian-korneck/update-container-description-action@v1
  223. with:
  224. provider: dockerhub
  225. destination_container_repo: ${{ github.repository_owner }}/${{ steps.image.outputs.group1 }}
  226. readme_file: docker/coturn/README.md
  227. env:
  228. DOCKER_USER: ${{ secrets.DOCKERHUB_BOT_USER }}
  229. DOCKER_PASS: ${{ secrets.DOCKERHUB_BOT_PASS }}
  230. if: ${{ startsWith(github.ref, 'refs/tags/')
  231. && matrix.registry == 'docker.io' }}
  232. - name: Update README on Quay.io
  233. uses: christian-korneck/update-container-description-action@v1
  234. with:
  235. provider: quay
  236. destination_container_repo: ${{ matrix.registry }}/${{ github.repository_owner }}/${{ steps.image.outputs.group1 }}
  237. readme_file: docker/coturn/README.md
  238. env:
  239. DOCKER_APIKEY: ${{ secrets.QUAYIO_API_TOKEN }}
  240. if: ${{ startsWith(github.ref, 'refs/tags/')
  241. && matrix.registry == 'quay.io' }}
  242. release-github:
  243. name: release (GitHub)
  244. if: ${{ github.event_name == 'push'
  245. && github.repository_owner == 'coturn'
  246. && startsWith(github.ref, 'refs/tags/') }}
  247. needs: ["push"]
  248. runs-on: ubuntu-latest
  249. steps:
  250. - uses: actions/checkout@v4
  251. - name: Parse semver versions from Git tag
  252. id: semver
  253. uses: actions-ecosystem/action-regex-match@v2
  254. with:
  255. text: ${{ github.ref }}
  256. regex: '^refs/tags/docker/(((([0-9]+)\.[0-9]+)\.[0-9]+)-(.+))$'
  257. - name: Parse CHANGELOG link
  258. id: changelog
  259. run: echo "link=${{ github.server_url }}/${{ github.repository }}/blob/docker/${{ steps.semver.outputs.group1 }}/docker/coturn/CHANGELOG.md#$(sed -n '/^## \[${{ steps.semver.outputs.group1 }}\]/{s/^## \[\(.*\)\][^0-9]*\([0-9].*\)/\1--\2/;s/[^0-9a-z-]*//g;p;}' CHANGELOG.md)"
  260. >> $GITHUB_OUTPUT
  261. working-directory: docker/coturn/
  262. - name: Create GitHub release
  263. uses: softprops/action-gh-release@v2
  264. with:
  265. name: docker/${{ steps.semver.outputs.group1 }}
  266. body: |
  267. `${{ steps.semver.outputs.group1 }}` Docker image version of ${{ steps.semver.outputs.group2 }} Coturn release.
  268. [Docker Hub](https://hub.docker.com/r/coturn/coturn) | [GitHub Container Registry](https://github.com/orgs/coturn/packages/container/package/coturn) | [Quay.io](https://quay.io/repository/coturn/coturn)
  269. [Changelog](${{ steps.changelog.outputs.link }})