|
38 | 38 | if: ${{startsWith(github.ref, 'refs/tags/') }} |
39 | 39 | with: |
40 | 40 | files: pie.phar |
| 41 | + |
| 42 | + docker-binary-only-image: |
| 43 | + needs: build-phar |
| 44 | + name: Docker binary-only image |
| 45 | + runs-on: ubuntu-latest |
| 46 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 47 | + |
| 48 | + permissions: |
| 49 | + # attestations:write is required for build provenance attestation. |
| 50 | + attestations: write |
| 51 | + # id-token:write is required for build provenance attestation. |
| 52 | + id-token: write |
| 53 | + # packages:write is required to publish Docker images to GitHub's registry. |
| 54 | + packages: write |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout repository |
| 58 | + uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Fetch built PHAR from artifacts |
| 61 | + uses: actions/download-artifact@v4 |
| 62 | + with: |
| 63 | + name: pie-${{ github.sha }}.phar |
| 64 | + |
| 65 | + - name: Verify the PHAR |
| 66 | + env: |
| 67 | + GH_TOKEN: ${{ github.token }} |
| 68 | + run: gh attestation verify pie.phar --repo ${{ github.repository }} |
| 69 | + |
| 70 | + - name: Set up QEMU |
| 71 | + uses: docker/setup-qemu-action@v3 |
| 72 | + |
| 73 | + - name: Set up Docker Buildx |
| 74 | + uses: docker/setup-buildx-action@v3 |
| 75 | + |
| 76 | + - name: Log in to the Container registry |
| 77 | + uses: docker/login-action@v3 |
| 78 | + with: |
| 79 | + registry: ghcr.io |
| 80 | + username: ${{ github.actor }} |
| 81 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + |
| 83 | + - name: Extract metadata (tags, labels) for Docker |
| 84 | + id: meta |
| 85 | + uses: docker/metadata-action@v5 |
| 86 | + with: |
| 87 | + flavor: | |
| 88 | + latest=false |
| 89 | + images: ghcr.io/${{ github.repository }} |
| 90 | + # @TODO v1.0 Consider introducing more granular tags (major and major.minor) |
| 91 | + # @see https://github.com/php/pie/pull/122#pullrequestreview-2477496308 |
| 92 | + # @see https://github.com/php/pie/pull/122#discussion_r1867331273 |
| 93 | + tags: | |
| 94 | + type=raw,value=bin |
| 95 | + type=semver,pattern={{version}}-bin |
| 96 | +
|
| 97 | + - name: Build and push Docker image |
| 98 | + id: build-and-push |
| 99 | + uses: docker/build-push-action@v5 |
| 100 | + with: |
| 101 | + context: . |
| 102 | + platforms: linux/amd64,linux/arm64 |
| 103 | + file: Dockerfile |
| 104 | + target: standalone-binary |
| 105 | + push: true |
| 106 | + tags: ${{ steps.meta.outputs.tags }} |
| 107 | + labels: ${{ steps.meta.outputs.labels }} |
| 108 | + |
| 109 | + - name: Generate artifact attestation |
| 110 | + uses: actions/attest-build-provenance@v1 |
| 111 | + with: |
| 112 | + subject-name: ghcr.io/${{ github.repository }} |
| 113 | + subject-digest: ${{ steps.build-and-push.outputs.digest }} |
| 114 | + push-to-registry: true |
0 commit comments