|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + release: |
| 6 | + types: [created] |
| 7 | + |
| 8 | +permissions: read-all |
| 9 | + |
| 10 | +env: |
| 11 | + IMAGE_REGISTRY: ghcr.io |
| 12 | + IMAGE_NAME: ${{ github.repository }} |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + outputs: |
| 20 | + image: ${{ steps.image.outputs.image }} |
| 21 | + digest: ${{ steps.build.outputs.digest }} |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Checkout the repository |
| 25 | + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2.3.4 |
| 26 | + |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0 |
| 29 | + |
| 30 | + - name: Authenticate Docker |
| 31 | + uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0 |
| 32 | + with: |
| 33 | + registry: ${{ env.IMAGE_REGISTRY }} |
| 34 | + username: ${{ github.actor }} |
| 35 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Extract metadata (tags, labels) for Docker |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # v4.0.1 |
| 40 | + with: |
| 41 | + images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} |
| 42 | + |
| 43 | + - name: Build and push Docker image |
| 44 | + uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # v3.0.0 |
| 45 | + id: build |
| 46 | + with: |
| 47 | + push: true |
| 48 | + tags: ${{ steps.meta.outputs.tags }} |
| 49 | + labels: ${{ steps.meta.outputs.labels }} |
| 50 | + |
| 51 | + - name: Output image |
| 52 | + id: image |
| 53 | + run: | |
| 54 | + # NOTE: Set the image as an output because the `env` context is not |
| 55 | + # available to the inputs of a reusable workflow call. |
| 56 | + image_name="${IMAGE_REGISTRY}/${IMAGE_NAME}" |
| 57 | + echo "image=$image_name" >> "$GITHUB_OUTPUT" |
| 58 | +
|
| 59 | + image-provenance: |
| 60 | + needs: [build] |
| 61 | + permissions: |
| 62 | + actions: read |
| 63 | + id-token: write |
| 64 | + packages: write |
| 65 | + if: startsWith(github.ref, 'refs/tags/') |
| 66 | + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v1.9.0 |
| 67 | + with: |
| 68 | + image: ${{ needs.build.outputs.image }} |
| 69 | + digest: ${{ needs.build.outputs.digest }} |
| 70 | + registry-username: ${{ github.actor }} |
| 71 | + secrets: |
| 72 | + registry-password: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + binary-provenance: |
| 75 | + permissions: |
| 76 | + id-token: write |
| 77 | + contents: write |
| 78 | + actions: read |
| 79 | + uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.9.0 |
| 80 | + with: |
| 81 | + go-version: 1.21 |
0 commit comments