diff --git a/pkg/version/version.go b/pkg/version/version.go new file mode 100644 index 00000000000..5969a2f03d3 --- /dev/null +++ b/pkg/version/version.go @@ -0,0 +1,20 @@ +// Copyright © 2019 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package version + +// NOTE: use go build -ldflags "-X github.com/tektoncd/pipeline/pkg/cmd/version.PipelineVersion=$(git describe)" +const devVersion = "dev" + +var PipelineVersion = devVersion diff --git a/tekton/publish-nightly.yaml b/tekton/publish-nightly.yaml index ef3841c346d..d41d0dcc7b8 100644 --- a/tekton/publish-nightly.yaml +++ b/tekton/publish-nightly.yaml @@ -58,27 +58,6 @@ spec: - name: GOOGLE_APPLICATION_CREDENTIALS value: /secret/release.json - - name: create-ko-yaml - image: busybox - command: - - /bin/sh - args: - - -ce - - | - set -e - set -x - - cat < /workspace/go/src/github.com/tektoncd/pipeline/.ko.yaml - # By default ko will build images on top of distroless - baseImageOverrides: - # Use the images we just built as base images - ${inputs.params.pathToProject}/${outputs.resources.builtCredsInitImage.url}: ${inputs.params.imageRegistry}/${inputs.params.pathToProject}/build-base:latest - ${inputs.params.pathToProject}/${outputs.resources.builtGitInitImage.url}: ${inputs.params.imageRegistry}/${inputs.params.pathToProject}/build-base:latest - ${inputs.params.pathToProject}/${outputs.resources.builtEntrypointImage.url}: busybox # image should have shell in $PATH - EOF - - cat /workspace/go/src/github.com/tektoncd/pipeline/.ko.yaml - - name: ensure-release-dirs-exist image: busybox command: ["mkdir"] @@ -107,6 +86,35 @@ spec: echo $VERSION_TAG > "/builder/home/version" + - name: create-ko-yaml + image: busybox + command: + - /bin/sh + args: + - -ce + - | + set -e + set -x + + cat < /workspace/go/src/github.com/tektoncd/pipeline/.ko.yaml + # By default ko will build images on top of distroless + baseImageOverrides: + # Use the images we just built as base images + ${inputs.params.pathToProject}/${outputs.resources.builtCredsInitImage.url}: ${inputs.params.imageRegistry}/${inputs.params.pathToProject}/build-base:latest + ${inputs.params.pathToProject}/${outputs.resources.builtGitInitImage.url}: ${inputs.params.imageRegistry}/${inputs.params.pathToProject}/build-base:latest + ${inputs.params.pathToProject}/${outputs.resources.builtEntrypointImage.url}: busybox # image should have shell in $PATH + baseBuildOverrides: + $(input.params.pathToProject)/$(outputs.resources.builtControllerImage.url): + env: + - name: CGO_ENABLED + value: 1 + flags: + - name: ldflags + value: "-X $(inputs.params.pathToProject)/pkg/version.PipelineVersion=$(cat /builder/home/version)" + EOF + + cat /workspace/go/src/github.com/tektoncd/pipeline/.ko.yaml + - name: run-ko # TODO(#639) we should be able to use the image built by an upstream Task here instead of hardcoding image: gcr.io/tekton-nightly/ko-ci diff --git a/tekton/publish.yaml b/tekton/publish.yaml index 40b31252bc9..30613ac52d7 100644 --- a/tekton/publish.yaml +++ b/tekton/publish.yaml @@ -77,6 +77,14 @@ spec: $(inputs.params.pathToProject)/$(outputs.resources.builtCredsInitImage.url): $(inputs.params.imageRegistry)/$(inputs.params.pathToProject)/build-base:latest $(inputs.params.pathToProject)/$(outputs.resources.builtGitInitImage.url): $(inputs.params.imageRegistry)/$(inputs.params.pathToProject)/build-base:latest $(inputs.params.pathToProject)/$(outputs.resources.builtEntrypointImage.url): busybox # image should have shell in $PATH + baseBuildOverrides: + $(input.params.pathToProject)/$(outputs.resources.builtControllerImage.url): + env: + - name: CGO_ENABLED + value: 1 + flags: + - name: ldflags + value: "-X $(inputs.params.pathToProject)/pkg/version.PipelineVersion=$(inputs.params.versionTag)" EOF cat /workspace/go/src/github.com/tektoncd/pipeline/.ko.yaml diff --git a/tekton/release-pipeline.yaml b/tekton/release-pipeline.yaml index 920250e9759..8e11fa796fa 100644 --- a/tekton/release-pipeline.yaml +++ b/tekton/release-pipeline.yaml @@ -85,6 +85,8 @@ spec: params: - name: package value: $(params.package) + - name: flags + value: -ldflags "-X github.com/tektoncd/pipeline/pkg/version.PipelineVersion=$(params.versionTag)" resources: inputs: - name: source