release.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - "v[0-9]+.[0-9]+.[0-9]+"
  6. env:
  7. REGISTRY: ghcr.io
  8. IMAGE_NAME: ${{ github.repository }}
  9. jobs:
  10. docker-images:
  11. name: Docker with PHP ${{ matrix.php-version }}, Fixer ${{ github.ref_name }}
  12. if: github.repository == 'PHP-CS-Fixer/PHP-CS-Fixer'
  13. runs-on: ubuntu-latest
  14. strategy:
  15. matrix:
  16. include:
  17. - php-version: '7.4'
  18. alpine-version: '3.16'
  19. - php-version: '8.0'
  20. alpine-version: '3.16'
  21. - php-version: '8.1'
  22. alpine-version: '3.18'
  23. - php-version: '8.2'
  24. alpine-version: '3.18'
  25. - php-version: '8.3'
  26. alpine-version: '3.18'
  27. permissions:
  28. contents: read
  29. packages: write
  30. steps:
  31. - name: Checkout repository
  32. uses: actions/checkout@v4
  33. - name: Set up QEMU
  34. uses: docker/setup-qemu-action@v3
  35. - name: Set up Docker Buildx
  36. uses: docker/setup-buildx-action@v3
  37. - name: Log in to the Container registry
  38. uses: docker/login-action@v3
  39. with:
  40. registry: ${{ env.REGISTRY }}
  41. username: ${{ github.actor }}
  42. password: ${{ secrets.GITHUB_TOKEN }}
  43. - name: Make image lowercase
  44. run: |
  45. echo IMAGE_NAME_LOWER=$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]') >> ${GITHUB_ENV}
  46. - name: Extract metadata (tags, labels) for Docker
  47. id: meta
  48. uses: docker/metadata-action@v5
  49. with:
  50. flavor: |
  51. latest=false
  52. suffix=-php${{ matrix.php-version }}
  53. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}
  54. tags: |
  55. type=semver,pattern={{version}}
  56. type=semver,pattern={{major}}.{{minor}}
  57. type=semver,pattern={{major}}
  58. - name: Build and push Docker image
  59. uses: docker/build-push-action@v5
  60. with:
  61. context: .
  62. platforms: linux/amd64,linux/arm64
  63. file: Dockerfile
  64. target: dist
  65. build-args: |
  66. PHP_VERSION=${{ matrix.php-version }}
  67. ALPINE_VERSION=${{ matrix.alpine-version }}
  68. push: true
  69. tags: ${{ steps.meta.outputs.tags }}
  70. labels: ${{ steps.meta.outputs.labels }}