| 1234567891011121314151617181920212223242526272829 |
- #!/bin/sh
- # Build unbound-sec and (optionally) sign with cosign in keyless mode.
- #
- # Usage:
- # ./build.sh # build only
- # COSIGN_SIGN=1 ./build.sh # build + cosign sign (needs keyless
- # # capability: GHCR via GITHUB_TOKEN,
- # # or local keyless via OIDC provider)
- set -eu
- IMAGE="${IMAGE:-unbound-sec:latest}"
- VERSION="${VERSION:-$(git describe --tags --always 2>/dev/null || echo dev)}"
- echo "==> building $IMAGE (version=$VERSION)"
- docker build \
- --build-arg "COMMIT=${GITHUB_SHA:-$(git rev-parse HEAD 2>/dev/null || echo none)}" \
- --label "org.opencontainers.image.version=$VERSION" \
- --label "org.opencontainers.image.source=https://github.com/ric/unbound-sec" \
- -t "$IMAGE" .
- if [ "${COSIGN_SIGN:-0}" = "1" ]; then
- echo "==> cosign keyless sign"
- cosign sign --yes \
- --certificate-identity-regexp "https://token.actions.githubusercontent.com" \
- --certificate-oidc-issuer-regexp "https://token.actions.githubusercontent.com" \
- "$IMAGE"
- fi
- echo "==> done: $IMAGE"
|