Skip to content

Commit d2663cd

Browse files
authored
Fix cosign verification (#14)
1 parent dd2e3df commit d2663cd

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

.github/workflows/publish.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,36 @@ jobs:
5252
DIGEST: ${{ steps.build-and-push.outputs.digest }}
5353
TAGS: ${{ steps.meta.outputs.tags }}
5454
run: |
55+
set -euo pipefail
56+
[ -n "${DIGEST:-}" ] || { echo "No digest found"; exit 1; }
5557
images=""
56-
for tag in ${TAGS}; do
58+
while IFS= read -r tag; do
59+
tag="$(echo "$tag" | xargs)" # trim whitespace
60+
[ -z "$tag" ] && continue
5761
images+="${tag}@${DIGEST} "
58-
done
59-
cosign sign --yes ${images}
62+
done < <(echo "${TAGS:-}" | tr ',' '\n')
63+
echo "Signing: $images"
64+
cosign sign --yes $images
6065
6166
- name: Verify signatures
6267
env:
6368
DIGEST: ${{ steps.build-and-push.outputs.digest }}
6469
TAGS: ${{ steps.meta.outputs.tags }}
6570
run: |
71+
set -euo pipefail
72+
[ -n "${DIGEST:-}" ] || { echo "No digest found"; exit 1; }
6673
images=""
67-
for tag in ${TAGS}; do
74+
while IFS= read -r tag; do
75+
tag="$(echo "$tag" | xargs)"
76+
[ -z "$tag" ] && continue
6877
images+="${tag}@${DIGEST} "
69-
done
70-
cosign verify ${images}
78+
done < <(echo "${TAGS:-}" | tr ',' '\n')
79+
80+
CERT_ID="https://github.com/${{ github.repository }}/.github/workflows/publish.yml@${{ github.ref }}"
81+
CERT_ISSUER="https://token.actions.githubusercontent.com"
82+
83+
echo "Verifying: $images"
84+
cosign verify \
85+
--certificate-identity="${CERT_ID}" \
86+
--certificate-oidc-issuer="${CERT_ISSUER}" \
87+
$images

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,21 @@ upload the Docker image to
7878
The [build.yml][gh-build-file] workflow uploads all tested image versions to
7979
[GitHub container registry][gh-container-registry].
8080

81+
## Verifying Signature
82+
8183
> [!CAUTION]
8284
> Only download and run images you trust.
8385
86+
You can use `cosign` to verify the keyless signature from
87+
[publish.yml][gh-publish-file]:
88+
89+
```bash
90+
export TAG=v1.26.0
91+
cosign verify ghcr.io/openmodelica/crossbuild \
92+
--certificate-identity=https://github.com/OpenModelica/openmodelica-crossbuild/.github/workflows/publish.yml@refs/tags/$TAG \
93+
--certificate-oidc-issuer=https://token.actions.githubusercontent.com
94+
```
95+
8496
## License
8597

8698
This repository is part of OpenModelica and licensed with

0 commit comments

Comments
 (0)