|
3 | 3 | branches:
|
4 | 4 | - master
|
5 | 5 |
|
6 |
| -permissions: |
7 |
| - contents: write |
8 |
| - pull-requests: write |
9 |
| - packages: write |
10 |
| - attestations: write |
11 |
| - id-token: write |
| 6 | +env: |
| 7 | + REGISTRY: ghcr.io |
| 8 | + IMAGE_NAME: ${{ github.repository }} |
12 | 9 |
|
13 | 10 | name: release
|
14 | 11 | jobs:
|
15 | 12 | release_please:
|
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + id-token: write |
| 17 | + |
16 | 18 | runs-on: ubuntu-latest
|
17 | 19 | outputs:
|
18 | 20 | major: ${{ steps.release.outputs.major }}
|
@@ -44,39 +46,68 @@ jobs:
|
44 | 46 | if: ${{ steps.release.outputs.release_created }}
|
45 | 47 |
|
46 | 48 | publish_docker:
|
| 49 | + name: Create and publish a Docker image |
47 | 50 | runs-on: ubuntu-latest
|
| 51 | + |
| 52 | + permissions: |
| 53 | + contents: read |
| 54 | + packages: write |
| 55 | + attestations: write |
| 56 | + id-token: write |
| 57 | + |
48 | 58 | needs: release_please
|
49 | 59 | if: ${{needs.release_please.outputs.release_created}}
|
| 60 | + |
50 | 61 | steps:
|
51 | 62 | - run: echo version v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
|
52 | 63 |
|
53 |
| - - uses: actions/checkout@v4 |
| 64 | + - name: Checkout repository |
| 65 | + uses: actions/checkout@v4 |
54 | 66 |
|
55 | 67 | - name: Set up QEMU
|
56 | 68 | uses: docker/setup-qemu-action@v3
|
57 | 69 | with:
|
58 |
| - platforms: 'arm64,arm' |
| 70 | + platforms: 'arm64' |
59 | 71 |
|
60 | 72 | - name: Set up Docker Buildx
|
61 | 73 | id: buildx
|
62 | 74 | uses: docker/setup-buildx-action@v3
|
63 | 75 | with:
|
64 |
| - platforms: linux/arm64,linux/amd64,linux/arm/v7 |
| 76 | + platforms: linux/arm64,linux/amd64 |
65 | 77 |
|
66 |
| - - name: Login to GHCR |
| 78 | + - name: Log in to the Container registry |
67 | 79 | uses: docker/login-action@v3
|
68 | 80 | with:
|
69 |
| - registry: ghcr.io |
| 81 | + registry: ${{ env.REGISTRY }} |
70 | 82 | username: ${{ github.repository_owner }}
|
71 | 83 | password: ${{ secrets.GITHUB_TOKEN }}
|
72 | 84 |
|
73 |
| - - name: Build and push |
74 |
| - uses: docker/build-push-action@v5 |
| 85 | + - name: Extract metadata (tags, labels) for Docker |
| 86 | + id: meta |
| 87 | + uses: docker/metadata-action@v5 |
| 88 | + with: |
| 89 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 90 | + flavor: | |
| 91 | + latest=false |
| 92 | + tags: | |
| 93 | + type=semver,pattern={{version}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}} |
| 94 | + type=semver,pattern={{major}}.{{minor}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}} |
| 95 | + type=semver,pattern={{major}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}} |
| 96 | +
|
| 97 | + - name: Build and push Docker image |
| 98 | + id: push |
| 99 | + uses: docker/build-push-action@v6 |
75 | 100 | with:
|
76 | 101 | context: .
|
77 |
| - platforms: ${{ steps.buildx.outputs.platforms }} |
78 | 102 | push: true
|
79 |
| - tags: | |
80 |
| - ghcr.io/${{ github.repository }}:${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}} |
81 |
| - ghcr.io/${{ github.repository }}:${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}} |
82 |
| - ghcr.io/${{ github.repository }}:${{needs.release_please.outputs.major}} |
| 103 | + platforms: ${{ steps.buildx.outputs.platforms }} |
| 104 | + tags: ${{ steps.meta.outputs.tags }} |
| 105 | + labels: ${{ steps.meta.outputs.labels }} |
| 106 | + |
| 107 | + - name: Generate artifact attestation |
| 108 | + uses: actions/attest-build-provenance@v1 |
| 109 | + with: |
| 110 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} |
| 111 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 112 | + push-to-registry: true |
| 113 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments