container.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ---
  2. name: Container
  3. # yamllint disable-line rule:truthy
  4. on:
  5. workflow_dispatch:
  6. workflow_run:
  7. workflows:
  8. - Integration
  9. types:
  10. - completed
  11. branches:
  12. - master
  13. concurrency:
  14. group: ${{ github.workflow }}-${{ github.ref_name }}
  15. cancel-in-progress: false
  16. permissions:
  17. contents: read
  18. # Organization GHCR
  19. packages: read
  20. env:
  21. PYTHON_VERSION: "3.13"
  22. jobs:
  23. build:
  24. if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
  25. name: Build (${{ matrix.arch }})
  26. runs-on: ${{ matrix.os }}
  27. strategy:
  28. fail-fast: false
  29. matrix:
  30. include:
  31. - arch: amd64
  32. os: ubuntu-24.04
  33. emulation: false
  34. - arch: arm64
  35. os: ubuntu-24.04-arm
  36. emulation: false
  37. - arch: armv7
  38. os: ubuntu-24.04-arm
  39. emulation: true
  40. permissions:
  41. # Organization GHCR
  42. packages: write
  43. outputs:
  44. version_string: ${{ steps.build.outputs.version_string }}
  45. version_tag: ${{ steps.build.outputs.version_tag }}
  46. docker_tag: ${{ steps.build.outputs.docker_tag }}
  47. git_url: ${{ steps.build.outputs.git_url }}
  48. git_branch: ${{ steps.build.outputs.git_branch }}
  49. steps:
  50. - name: Setup Python
  51. uses: actions/setup-python@v5
  52. with:
  53. python-version: "${{ env.PYTHON_VERSION }}"
  54. - name: Checkout
  55. uses: actions/checkout@v4
  56. with:
  57. persist-credentials: "false"
  58. - name: Setup cache Python
  59. uses: actions/cache@v4
  60. with:
  61. key: "python-${{ env.PYTHON_VERSION }}-${{ runner.arch }}-${{ hashFiles('./requirements*.txt') }}"
  62. restore-keys: "python-${{ env.PYTHON_VERSION }}-${{ runner.arch }}-"
  63. path: "./local/"
  64. - name: Setup cache container mounts
  65. uses: actions/cache@v4
  66. with:
  67. # yamllint disable-line rule:line-length
  68. key: "container-mounts-${{ matrix.arch }}-${{ hashFiles('./container/Dockerfile ./container/legacy/Dockerfile') }}"
  69. restore-keys: "container-mounts-${{ matrix.arch }}-"
  70. path: |
  71. /var/tmp/buildah-cache/
  72. /var/tmp/buildah-cache-*/
  73. - if: ${{ matrix.emulation }}
  74. name: Setup QEMU
  75. uses: docker/setup-qemu-action@v3
  76. - name: Login to GHCR
  77. uses: docker/login-action@v3
  78. with:
  79. registry: "ghcr.io"
  80. username: "${{ github.repository_owner }}"
  81. password: "${{ secrets.GITHUB_TOKEN }}"
  82. - name: Build
  83. id: build
  84. env:
  85. OVERRIDE_ARCH: "${{ matrix.arch }}"
  86. run: make podman.build
  87. test:
  88. name: Test (${{ matrix.arch }})
  89. runs-on: ${{ matrix.os }}
  90. needs: build
  91. strategy:
  92. fail-fast: false
  93. matrix:
  94. include:
  95. - arch: amd64
  96. os: ubuntu-24.04
  97. emulation: false
  98. - arch: arm64
  99. os: ubuntu-24.04-arm
  100. emulation: false
  101. - arch: armv7
  102. os: ubuntu-24.04-arm
  103. emulation: true
  104. permissions:
  105. # Organization GHCR
  106. packages: write
  107. steps:
  108. - name: Checkout
  109. uses: actions/checkout@v4
  110. with:
  111. persist-credentials: "false"
  112. - if: ${{ matrix.emulation }}
  113. name: Setup QEMU
  114. uses: docker/setup-qemu-action@v3
  115. - name: Login to GHCR
  116. uses: docker/login-action@v3
  117. with:
  118. registry: "ghcr.io"
  119. username: "${{ github.repository_owner }}"
  120. password: "${{ secrets.GITHUB_TOKEN }}"
  121. - name: Test
  122. env:
  123. OVERRIDE_ARCH: "${{ matrix.arch }}"
  124. GIT_URL: "${{ needs.build.outputs.git_url }}"
  125. run: make container.test
  126. release:
  127. if: github.repository_owner == 'searxng' && github.ref_name == 'master'
  128. name: Release
  129. runs-on: ubuntu-24.04-arm
  130. needs:
  131. - build
  132. - test
  133. steps:
  134. - name: Checkout
  135. uses: actions/checkout@v4
  136. with:
  137. persist-credentials: "false"
  138. - name: Login to GHCR
  139. uses: docker/login-action@v3
  140. with:
  141. registry: "ghcr.io"
  142. username: "${{ github.repository_owner }}"
  143. password: "${{ secrets.GITHUB_TOKEN }}"
  144. - name: Login to Docker Hub
  145. uses: docker/login-action@v3
  146. with:
  147. registry: "docker.io"
  148. username: "${{ secrets.DOCKERHUB_USERNAME }}"
  149. password: "${{ secrets.DOCKERHUB_TOKEN }}"
  150. - name: Release
  151. env:
  152. GIT_URL: "${{ needs.build.outputs.git_url }}"
  153. DOCKER_TAG: "${{ needs.build.outputs.docker_tag }}"
  154. run: make container.push