Skip to content

Commit 0d3321b

Browse files
committed
ci: update publish ci
1 parent 9f39568 commit 0d3321b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/publish.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Publish
33
on:
44
push:
55
branches: [main]
6+
tags: [v*]
67
pull_request:
78

89
env:
@@ -21,6 +22,8 @@ jobs:
2122
attestations: write
2223
id-token: write
2324
steps:
25+
- name: Install Cosign
26+
uses: sigstore/[email protected]
2427
- name: Checkout
2528
uses: actions/checkout@v4
2629
with:
@@ -36,12 +39,25 @@ jobs:
3639
id: meta
3740
with:
3841
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=ref,event=branch
44+
type=ref,event=pr
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=sha
3948
- name: Build and push
4049
uses: docker/build-push-action@v4
50+
id: build-and-push
4151
with:
4252
context: .
4353
push: ${{ github.event_name != 'pull_request' }}
4454
tags: ${{ steps.meta.outputs.tags }}
4555
labels: ${{ steps.meta.outputs.labels }}
4656
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4757
cache-to: type=inline
58+
- name: Sign the published Docker image
59+
if: ${{ github.event_name != 'pull_request' }}
60+
env:
61+
TAGS: ${{ steps.meta.outputs.tags }}
62+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
63+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)