Skip to content

Commit

Permalink
Bump builder image to use go1.21.4 and add new cosign image tags with…
Browse files Browse the repository at this point in the history
… shell (#3373)

* bump builder image to use go1.21.4

Signed-off-by: cpanato <ctadeu@gmail.com>

* build -dev tag images that have a shell

Signed-off-by: cpanato <ctadeu@gmail.com>

* use previous cosign image, the new one does not have shell and break the current workflows

Signed-off-by: cpanato <ctadeu@gmail.com>

---------

Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed Nov 19, 2023
1 parent d5da268 commit f1aaa95
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/validate-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
steps:
- name: Check Signature
run: |
cosign verify ghcr.io/gythialy/golang-cross:v1.21.3-0@sha256:6e2c885532ad276195d3e3f269055fb2742c8963b231d097c467758dd425a632 \
cosign verify ghcr.io/gythialy/golang-cross:v1.21.4-0@sha256:d18679c199db258cac9876a80abf9aff69485cf8a324bf547521f3de4cf3a366 \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity "https://github.com/gythialy/golang-cross/.github/workflows/release-golang-cross.yml@refs/tags/v1.21.3-0"
--certificate-identity "https://github.com/gythialy/golang-cross/.github/workflows/release-golang-cross.yml@refs/tags/v1.21.4-0"
env:
TUF_ROOT: /tmp

Expand All @@ -43,7 +43,7 @@ jobs:
- check-signature

container:
image: ghcr.io/gythialy/golang-cross:v1.21.3-0@sha256:6e2c885532ad276195d3e3f269055fb2742c8963b231d097c467758dd425a632
image: ghcr.io/gythialy/golang-cross:v1.21.4-0@sha256:d18679c199db258cac9876a80abf9aff69485cf8a324bf547521f3de4cf3a366

permissions: {}

Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
run: make snapshot
env:
PROJECT_ID: honk-fake-project
RUNTIME_IMAGE: gcr.io/distroless/static:debug-nonroot
RUNTIME_IMAGE: gcr.io/distroless/static-debian12:nonroot

- name: check binaries
run: |
Expand Down
4 changes: 0 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ before:
hooks:
- go mod tidy
- /bin/bash -c 'if [ -n "$(git --no-pager diff --exit-code go.mod go.sum)" ]; then exit 1; fi'
# if running a release we will generate the images in this step
# if running in the CI the CI env va is set and we dont run the ko steps
# this is needed because we are generating files that goreleaser was not aware to push to GH project release
- /bin/bash -c 'if [ -z "$CI" ]; then make sign-release-images; fi'

gomod:
proxy: true
Expand Down
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ cross:
golangci-lint:
rm -f $(GOLANGCI_LINT_BIN) || :
set -e ;\
GOBIN=$(GOLANGCI_LINT_DIR) $(GOEXE) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 ;\
GOBIN=$(GOLANGCI_LINT_DIR) $(GOEXE) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 ;\

lint: golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT_BIN) run -n
Expand Down Expand Up @@ -128,7 +128,7 @@ endef
# ko build
##########
.PHONY: ko
ko: ko-cosign
ko: ko-cosign ko-cosign-dev

.PHONY: ko-cosign
ko-cosign:
Expand All @@ -139,6 +139,15 @@ ko-cosign:
$(ARTIFACT_HUB_LABELS) --image-refs cosignImagerefs \
github.com/sigstore/cosign/v2/cmd/cosign

.PHONY: ko-cosign-dev
ko-cosign-dev:
$(create_kocache_path)
LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \
KOCACHE=$(KOCACHE_PATH) KO_DEFAULTBASEIMAGE=gcr.io/distroless/static-debian12:debug-nonroot ko build --base-import-paths \
--platform=all --tags $(GIT_VERSION)-dev --tags $(GIT_HASH)-dev \
$(ARTIFACT_HUB_LABELS) --image-refs cosignDevImagerefs \
github.com/sigstore/cosign/v2/cmd/cosign

.PHONY: ko-local
ko-local:
$(create_kocache_path)
Expand All @@ -148,6 +157,15 @@ ko-local:
$(ARTIFACT_HUB_LABELS) \
github.com/sigstore/cosign/v2/cmd/cosign

.PHONY: ko-local-dev
ko-local-dev:
$(create_kocache_path)
KO_DOCKER_REPO=ko.local/cosign-dev LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \
KOCACHE=$(KOCACHE_PATH) KO_DEFAULTBASEIMAGE=gcr.io/distroless/static-debian12:debug-nonroot ko build --base-import-paths \
--tags $(GIT_VERSION) --tags $(GIT_HASH) \
$(ARTIFACT_HUB_LABELS) \
github.com/sigstore/cosign/v2/cmd/cosign

##################
# help
##################
Expand Down
10 changes: 5 additions & 5 deletions release/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ steps:
- TUF_ROOT=/tmp
args:
- 'verify'
- 'ghcr.io/gythialy/golang-cross:v1.21.3-0@sha256:6e2c885532ad276195d3e3f269055fb2742c8963b231d097c467758dd425a632'
- 'ghcr.io/gythialy/golang-cross:v1.21.4-0@sha256:d18679c199db258cac9876a80abf9aff69485cf8a324bf547521f3de4cf3a366'
- '--certificate-oidc-issuer'
- "https://token.actions.githubusercontent.com"
- '--certificate-identity'
- "https://github.com/gythialy/golang-cross/.github/workflows/release-golang-cross.yml@refs/tags/v1.21.3-0"
- "https://github.com/gythialy/golang-cross/.github/workflows/release-golang-cross.yml@refs/tags/v1.21.4-0"

# maybe we can build our own image and use that to be more in a safe side
- name: ghcr.io/gythialy/golang-cross:v1.21.3-0@sha256:6e2c885532ad276195d3e3f269055fb2742c8963b231d097c467758dd425a632
- name: ghcr.io/gythialy/golang-cross:v1.21.4-0@sha256:d18679c199db258cac9876a80abf9aff69485cf8a324bf547521f3de4cf3a366
entrypoint: /bin/sh
dir: "go/src/sigstore/cosign"
env:
Expand All @@ -68,7 +68,7 @@ steps:
gcloud auth configure-docker \
&& make release
- name: ghcr.io/gythialy/golang-cross:v1.21.3-0@sha256:6e2c885532ad276195d3e3f269055fb2742c8963b231d097c467758dd425a632
- name: ghcr.io/gythialy/golang-cross:v1.21.4-0@sha256:d18679c199db258cac9876a80abf9aff69485cf8a324bf547521f3de4cf3a366
entrypoint: 'bash'
dir: "go/src/sigstore/cosign"
env:
Expand All @@ -90,7 +90,7 @@ steps:
- '-c'
- |
echo $$GITHUB_TOKEN | docker login ghcr.io -u $$GITHUB_USER --password-stdin \
&& make copy-signed-release-to-ghcr || true
&& make sign-release-images && make copy-signed-release-to-ghcr || true
availableSecrets:
secretManager:
Expand Down
11 changes: 11 additions & 0 deletions release/ko-sign-release-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ if [[ ! -f cosignImagerefs ]]; then
exit 1
fi

if [[ ! -f cosignDevImagerefs ]]; then
echo "cosignDevImagerefs not found"
exit 1
fi

echo "Signing cosign images with GCP KMS Key..."
cosign sign --yes --key "gcpkms://projects/$PROJECT_ID/locations/$KEY_LOCATION/keyRings/$KEY_RING/cryptoKeys/$KEY_NAME/versions/$KEY_VERSION" -a GIT_HASH="$GIT_HASH" -a GIT_VERSION="$GIT_VERSION" $(cat cosignImagerefs)

echo "Signing images with Keyless..."
cosign sign --yes -a GIT_HASH="$GIT_HASH" -a GIT_VERSION="$GIT_VERSION" $(cat cosignImagerefs)

echo "Signing cosign images with GCP KMS Key..."
cosign sign --yes --key "gcpkms://projects/$PROJECT_ID/locations/$KEY_LOCATION/keyRings/$KEY_RING/cryptoKeys/$KEY_NAME/versions/$KEY_VERSION" -a GIT_HASH="$GIT_HASH" -a GIT_VERSION="$GIT_VERSION" $(cat cosignDevImagerefs)

echo "Signing images with Keyless..."
cosign sign --yes -a GIT_HASH="$GIT_HASH" -a GIT_VERSION="$GIT_VERSION" $(cat cosignDevImagerefs)
3 changes: 2 additions & 1 deletion release/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sign-release-images: ko
# used when need to validate the goreleaser
.PHONY: snapshot
snapshot:
LDFLAGS="$(LDFLAGS)" goreleaser release --skip-sign --skip-publish --snapshot --clean --timeout 120m --parallelism 1
LDFLAGS="$(LDFLAGS)" goreleaser release --skip=sign,publish --snapshot --clean --timeout 120m --parallelism 1

####################
# copy image to GHCR
Expand All @@ -27,3 +27,4 @@ snapshot:
.PHONY: copy-signed-release-to-ghcr
copy-signed-release-to-ghcr:
cosign copy $(KO_PREFIX)/cosign:$(GIT_VERSION) $(GHCR_PREFIX)/cosign:$(GIT_VERSION)
cosign copy $(KO_PREFIX)/cosign:$(GIT_VERSION)-dev $(GHCR_PREFIX)/cosign:$(GIT_VERSION)-dev

0 comments on commit f1aaa95

Please sign in to comment.