Skip to content

Commit

Permalink
tekton: make sure the git workingdir is not dirty…
Browse files Browse the repository at this point in the history
… when building the released binaries/images.

As of today, we are modifying the source and building. This means
`knative.dev/pkg/changeset` will require the commit hash suffixed by
`-dirty`. This can be a bit confusing the users as, well, this means
the source is not really the source of truth of the binary :)

This changes that:
- it generates `.ko.yaml` in `/workspace` so that it's not in the git
  repository. It uses `KO_CONFIG_PATH` environment variable to force
  `ko` to use it.
- it does the devel->version rewrite on generated yamls, so after the
  build is done.

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Sep 28, 2022
1 parent 0362c6b commit 0bbbf41
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tekton/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
${CONTAINER_REGISTRY}/$(params.package)/combined-base-image:latest)
# NOTE: Make sure this list of images to use the combined base image is in sync with what's in test/presubmit-tests.sh's 'ko_resolve' function.
cat <<EOF > ${PROJECT_ROOT}/.ko.yaml
cat <<EOF > /workspace/.ko.yaml
# This matches the value configured in .ko.yaml
defaultBaseImage: cgr.dev/chainguard/static
baseImageOverrides:
Expand All @@ -117,7 +117,7 @@ spec:
$(params.package)/cmd/git-init: cgr.dev/chainguard/git
EOF
cat ${PROJECT_ROOT}/.ko.yaml
cat /workspace/.ko.yaml
- name: run-ko
image: gcr.io/tekton-releases/dogfooding/ko@sha256:0e9f6349df349cbeb859b3c7899c78c024202fa95f174b910fb181361fdf737a
Expand All @@ -130,6 +130,9 @@ spec:
#!/usr/bin/env sh
set -ex
# Use the generated `.ko.yaml`
KO_CONFIG_PATH=/workspace/.ko.yaml
# Setup docker-auth
DOCKER_CONFIG=~/.docker
mkdir -p ${DOCKER_CONFIG}
Expand All @@ -153,10 +156,6 @@ spec:
fi
done
# Rewrite "devel" to params.versionTag
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${PROJECT_ROOT}/config/*.yaml
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${PROJECT_ROOT}/config/resolvers/*.yaml
# Publish images and create release.yaml
mkdir -p $OUTPUT_RELEASE_DIR
Expand All @@ -168,6 +167,11 @@ spec:
ko resolve --platform=$(params.platforms) --preserve-import-paths -l 'app.kubernetes.io/component!=resolvers' -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.notags.yaml
ko resolve --platform=$(params.platforms) --preserve-import-paths -f ${PROJECT_ROOT}/config/resolvers > $OUTPUT_RELEASE_DIR/resolvers.notags.yaml
# Rewrite "devel" to params.versionTag
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${OUTPUT_RELEASE_DIR}/release.yaml
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${OUTPUT_RELEASE_DIR}/release.notags.yaml
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${OUTPUT_RELEASE_DIR}/resolvers.yaml
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${OUTPUT_RELEASE_DIR}/resolvers.notags.yaml
- name: koparse
image: gcr.io/tekton-releases/dogfooding/koparse:latest
script: |
Expand Down

0 comments on commit 0bbbf41

Please sign in to comment.