Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store tektoncd/pipeline release version to a variable during build #1650

Merged
merged 1 commit into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -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
50 changes: 29 additions & 21 deletions tekton/publish-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > /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"]
Expand Down Expand Up @@ -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 <<EOF > /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
Expand Down
8 changes: 8 additions & 0 deletions tekton/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tekton/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down