docker.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: Build docker image
  2. on:
  3. release:
  4. types: [published]
  5. jobs:
  6. build-image:
  7. runs-on: ubuntu-latest
  8. permissions:
  9. packages: write
  10. steps:
  11. - uses: actions/checkout@v4
  12. - name: Docker metadata
  13. id: meta
  14. uses: docker/metadata-action@v5
  15. with:
  16. images: ghcr.io/${{ github.repository_owner }}/xray-core
  17. flavor: latest=auto
  18. tags: |
  19. type=semver,pattern={{version}}
  20. - name: Docker metadata (unsupported architectures)
  21. id: metausa
  22. uses: docker/metadata-action@v5
  23. with:
  24. images: ghcr.io/${{ github.repository_owner }}/xray-core
  25. flavor: |
  26. latest=auto
  27. suffix=-usa,onlatest=true
  28. tags: |
  29. type=semver,pattern={{version}}
  30. - name: Login to GitHub Container Registry
  31. uses: docker/login-action@v3
  32. with:
  33. registry: ghcr.io
  34. username: ${{ github.repository_owner }}
  35. password: ${{ secrets.GITHUB_TOKEN }}
  36. - name: Set up Docker Buildx
  37. uses: docker/setup-buildx-action@v3
  38. - name: Build and push
  39. uses: docker/build-push-action@v6
  40. with:
  41. context: .
  42. platforms: |
  43. linux/amd64
  44. linux/arm/v7
  45. linux/arm64/v8
  46. linux/ppc64le
  47. linux/s390x
  48. provenance: false
  49. file: .github/docker/Dockerfile
  50. push: true
  51. tags: ${{ steps.meta.outputs.tags }}
  52. - name: Build and push (unsupported architectures)
  53. uses: docker/build-push-action@v6
  54. with:
  55. context: .
  56. platforms: |
  57. linux/386
  58. linux/arm/v6
  59. linux/riscv64
  60. linux/loong64
  61. provenance: false
  62. file: .github/docker/Dockerfile.usa
  63. push: true
  64. tags: ${{ steps.metausa.outputs.tags }}
  65. - name: Merge Multi-Arch Manifests
  66. run: |
  67. echo "Starting to merge multi-architecture manifests..."
  68. # Convert newlines to spaces and split into array
  69. TAGS=($(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '))
  70. echo "Total tags to process: ${#TAGS[@]}"
  71. for tag in "${TAGS[@]}"; do
  72. echo "Merging tag: $tag with unsupported architectures ($tag-usa)"
  73. docker buildx imagetools create --append --tag "$tag" "$tag-usa"
  74. if [ $? -ne 0 ]; then
  75. echo "Error: Failed to merge $tag-usa into $tag"
  76. exit 1
  77. fi
  78. done
  79. echo "Multi-architecture manifest merge completed successfully."