release.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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@v3
  33. - name: Log in to the Container registry
  34. uses: docker/login-action@v3
  35. with:
  36. registry: ${{ env.REGISTRY }}
  37. username: ${{ github.actor }}
  38. password: ${{ secrets.GITHUB_TOKEN }}
  39. - name: Make image lowercase
  40. run: |
  41. echo IMAGE_NAME_LOWER=$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]') >> ${GITHUB_ENV}
  42. - name: Extract metadata (tags, labels) for Docker
  43. id: meta
  44. uses: docker/metadata-action@v5
  45. with:
  46. flavor: |
  47. latest=false
  48. suffix=-php${{ matrix.php-version }}
  49. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}
  50. tags: |
  51. type=semver,pattern={{version}}
  52. type=semver,pattern={{major}}.{{minor}}
  53. type=semver,pattern={{major}}
  54. - name: Build and push Docker image
  55. uses: docker/build-push-action@v5
  56. with:
  57. context: .
  58. file: Dockerfile
  59. target: dist
  60. build-args: |
  61. PHP_VERSION=${{ matrix.php-version }}
  62. ALPINE_VERSION=${{ matrix.alpine-version }}
  63. push: true
  64. tags: ${{ steps.meta.outputs.tags }}
  65. labels: ${{ steps.meta.outputs.labels }}