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

Use tekton beta resources for build #957

Merged
merged 1 commit into from
Feb 11, 2021
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
40 changes: 20 additions & 20 deletions tekton/create-draft-triggers-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@

# This is a modified version of the Task in the tektoncd/plumbing repo:
# https://github.com/tektoncd/plumbing/blob/master/tekton/resources/release/github_release.yaml
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: create-draft-triggers-release
spec:
inputs:
params:
- name: package
description: package (and its children) under test
- name: release-tag
description: Release number and git tag to be applied (e.g. 0.888.1, with 'v')
- name: previous-release-tag
description: Previous release number - for author and PR list calculation
resources:
params:
- name: package
description: package (and its children) under test
- name: release-tag
description: Release number and git tag to be applied (e.g. 0.888.1, with 'v')
- name: previous-release-tag
description: Previous release number - for author and PR list calculation
resources:
inputs:
- name: source
type: git
stepTemplate:
Expand All @@ -38,11 +38,11 @@ spec:
name: github-token
key: GITHUB_TOKEN
- name: VERSION
value: $(inputs.params.release-tag)
value: $(params.release-tag)
- name: PROJECT
value: $(inputs.params.package)
value: $(params.package)
- name: OLD_VERSION
value: $(inputs.params.previous-release-tag)
value: $(params.previous-release-tag)
steps:
- name: header
image: gcr.io/tekton-releases/dogfooding/hub
Expand Down Expand Up @@ -110,13 +110,13 @@ spec:

[Fill list here]

## How to upgrade from $(inputs.params.previous-release-tag) :up_arrow:
## How to upgrade from $(params.previous-release-tag) :up_arrow:

1. [Describe required steps for user to upgrade to the latest version]
EOF
- name: filter-data
image: gcr.io/tekton-releases/dogfooding/hub
workingdir: $(inputs.resources.source.path)
workingdir: $(resources.inputs.source.path)
script: |
#!/usr/bin/env bash
set -e
Expand All @@ -125,7 +125,7 @@ spec:
git fetch --unshallow

LOWER_THRESHOLD=$(git rev-list ${OLD_VERSION} | wc -l)
UPPER_THRESHOLD=$(git rev-list $(inputs.resources.source.revision) | wc -l)
UPPER_THRESHOLD=$(git rev-list $(resources.inputs.source.revision) | wc -l)
echo "LOWER_THRESHOLD: $LOWER_THRESHOLD"
echo "UPPER_THRESHOLD: $UPPER_THRESHOLD"

Expand All @@ -145,7 +145,7 @@ spec:
cat $HOME/pr.csv
- name: authors
image: gcr.io/tekton-releases/dogfooding/hub
workingdir: $(inputs.resources.source.path)
workingdir: $(resources.inputs.source.path)
script: |
#!/usr/bin/env bash
set -ex
Expand All @@ -164,7 +164,7 @@ spec:
EOF
- name: pr-data
image: gcr.io/tekton-releases/dogfooding/hub
workingdir: $(inputs.resources.source.path)
workingdir: $(resources.inputs.source.path)
script: |
#!/usr/bin/env bash
set -ex
Expand All @@ -181,11 +181,11 @@ spec:
awk -F";" '{ print "- "$3" ("$2")" }' $HOME/pr.csv | tee -a $HOME/release.md
- name: create-draft
image: gcr.io/tekton-releases/dogfooding/hub
workingdir: $(inputs.resources.source.path)
workingdir: $(resources.inputs.source.path)
script: |
#!/usr/bin/env bash
set -ex

hub release create --draft --prerelease \
--commitish $(inputs.resources.source.revision) \
--commitish $(resources.inputs.source.revision) \
--file $HOME/release.md ${VERSION}
61 changes: 30 additions & 31 deletions tekton/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: publish-tekton-triggers
spec:
inputs:
resources:
resources:
inputs:
- name: source
type: git
targetPath: go/src/github.com/tektoncd/triggers
- name: bucket
type: storage
params:
- name: versionTag
description: The vX.Y.Z version that the artifacts should be tagged with (including `v`)
- name: imageRegistry
description: TODO(tektoncd/pipeline#569) This is a hack to make it easy for folks to switch the registry being used by the many many image outputs
- name: pathToProject
description: The path to the folder in the go/src dir that contains the project, which is used by `ko` to name the resulting images
- name: releaseAsLatest
description: "Whether to tag and publish this release as Triggers' latest"
default: "true"
outputs:
resources:
outputs:
- name: bucket
type: storage
- name: builtControllerImage
Expand All @@ -34,6 +23,16 @@ spec:
type: image
- name: notification
type: cloudEvent
params:
- name: versionTag
description: The vX.Y.Z version that the artifacts should be tagged with (including `v`)
- name: imageRegistry
description: TODO(tektoncd/pipeline#569) This is a hack to make it easy for folks to switch the registry being used by the many many image outputs
- name: pathToProject
description: The path to the folder in the go/src dir that contains the project, which is used by `ko` to name the resulting images
- name: releaseAsLatest
description: "Whether to tag and publish this release as Triggers' latest"
default: "true"
steps:
- name: link-input-bucket-to-output
image: busybox
Expand All @@ -49,13 +48,13 @@ spec:
args:
- "-p"
- "/workspace/output/bucket/latest/"
- "/workspace/output/bucket/previous/$(inputs.params.versionTag)/"
- "/workspace/output/bucket/previous/$(params.versionTag)/"

- name: run-ko
image: gcr.io/tekton-releases/dogfooding/ko-gcloud:latest
env:
- name: KO_DOCKER_REPO
value: $(inputs.params.imageRegistry)
value: $(params.imageRegistry)
- name: GOPATH
value: /workspace/go
- name: GOOGLE_APPLICATION_CREDENTIALS
Expand All @@ -74,12 +73,12 @@ spec:
# Change to directory with our .ko.yaml
cd /workspace/go/src/github.com/tektoncd/triggers
# Rewrite "devel" to inputs.params.versionTag
sed -i -e 's/\(triggers.tekton.dev\/release\): "devel"/\1: "$(inputs.params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(inputs.params.versionTag)"/g' /workspace/go/src/github.com/tektoncd/triggers/config/*.yaml
sed -i -e 's/\(triggers.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' /workspace/go/src/github.com/tektoncd/triggers/config/*.yaml

OUTPUT_BUCKET_RELEASE_DIR="/workspace/output/bucket/previous/$(inputs.params.versionTag)"
OUTPUT_BUCKET_RELEASE_DIR="/workspace/output/bucket/previous/$(params.versionTag)"

# Publish images and create release.yaml
ko resolve --platform=all --preserve-import-paths -t $(inputs.params.versionTag) -f /workspace/go/src/github.com/tektoncd/triggers/config/ > $OUTPUT_BUCKET_RELEASE_DIR/release.yaml
ko resolve --platform=all --preserve-import-paths -t $(params.versionTag) -f /workspace/go/src/github.com/tektoncd/triggers/config/ > $OUTPUT_BUCKET_RELEASE_DIR/release.yaml

# Publish images and create release.notags.yaml
# This is useful if your container runtime doesn't support the `image-reference:tag@digest` notation
Expand All @@ -96,10 +95,10 @@ spec:
#!/bin/sh
set -ex

if [[ "$(inputs.params.releaseAsLatest)" == "true" ]]
if [[ "$(params.releaseAsLatest)" == "true" ]]
then
mkdir -p "/workspace/output/bucket/latest/"
OUTPUT_BUCKET_RELEASE_DIR="/workspace/output/bucket/previous/$(inputs.params.versionTag)"
OUTPUT_BUCKET_RELEASE_DIR="/workspace/output/bucket/previous/$(params.versionTag)"
OUTPUT_BUCKET_LATEST_DIR="/workspace/output/bucket/latest"
cp "$OUTPUT_BUCKET_RELEASE_DIR/release.yaml" "$OUTPUT_BUCKET_LATEST_DIR/release.yaml"
cp "$OUTPUT_BUCKET_RELEASE_DIR/release.notags.yaml" "$OUTPUT_BUCKET_LATEST_DIR/release.notags.yaml"
Expand All @@ -113,13 +112,13 @@ spec:

REGIONS=(us eu asia)
IMAGES=(
$(inputs.params.imageRegistry)/$(inputs.params.pathToProject)/$(outputs.resources.builtControllerImage.url):$(inputs.params.versionTag)
$(inputs.params.imageRegistry)/$(inputs.params.pathToProject)/$(outputs.resources.builtWebhookImage.url):$(inputs.params.versionTag)
$(inputs.params.imageRegistry)/$(inputs.params.pathToProject)/$(outputs.resources.builtEventListenerSinkImage.url):$(inputs.params.versionTag)
$(inputs.params.imageRegistry)/$(inputs.params.pathToProject)/$(outputs.resources.builtCoreInterceptorsImage.url):$(inputs.params.versionTag)
$(params.imageRegistry)/$(params.pathToProject)/$(resources.outputs.builtControllerImage.url):$(params.versionTag)
$(params.imageRegistry)/$(params.pathToProject)/$(resources.outputs.builtWebhookImage.url):$(params.versionTag)
$(params.imageRegistry)/$(params.pathToProject)/$(resources.outputs.builtEventListenerSinkImage.url):$(params.versionTag)
$(params.imageRegistry)/$(params.pathToProject)/$(resources.outputs.builtCoreInterceptorsImage.url):$(params.versionTag)
)
# Parse the built images from the release.yaml generated by ko
BUILT_IMAGES=( $(/workspace/go/src/github.com/tektoncd/triggers/tekton/koparse/koparse.py --path /workspace/output/bucket/previous/$(inputs.params.versionTag)/release.yaml --base $(inputs.params.imageRegistry)/$(inputs.params.pathToProject) --images ${IMAGES[@]}) )
BUILT_IMAGES=( $(/workspace/go/src/github.com/tektoncd/triggers/tekton/koparse/koparse.py --path /workspace/output/bucket/previous/$(params.versionTag)/release.yaml --base $(params.imageRegistry)/$(params.pathToProject) --images ${IMAGES[@]}) )

# Auth with account credentials
gcloud auth activate-service-account --key-file=/secret/release.json
Expand All @@ -130,20 +129,20 @@ spec:
IMAGE_WITHOUT_SHA=${IMAGE%%@*}
IMAGE_WITHOUT_SHA_AND_TAG=${IMAGE_WITHOUT_SHA%%:*}
IMAGE_WITH_SHA=${IMAGE_WITHOUT_SHA_AND_TAG}@${IMAGE##*@}
if [[ "$(inputs.params.releaseAsLatest)" == "true" ]]
if [[ "$(params.releaseAsLatest)" == "true" ]]
then
gcloud -q container images add-tag ${IMAGE_WITH_SHA} ${IMAGE_WITHOUT_SHA_AND_TAG}:latest
fi
for REGION in "${REGIONS[@]}"
do
if [[ "$(inputs.params.releaseAsLatest)" == "true" ]]
if [[ "$(params.releaseAsLatest)" == "true" ]]
then
for TAG in "latest" $(inputs.params.versionTag)
for TAG in "latest" $(params.versionTag)
do
gcloud -q container images add-tag ${IMAGE_WITH_SHA} ${REGION}.${IMAGE_WITHOUT_SHA_AND_TAG}:$TAG
done
else
TAG="$(inputs.params.versionTag)"
TAG="$(params.versionTag)"
gcloud -q container images add-tag ${IMAGE_WITH_SHA} ${REGION}.${IMAGE_WITHOUT_SHA_AND_TAG}:$TAG
fi
done
Expand Down
2 changes: 1 addition & 1 deletion tekton/release-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: triggers-release
Expand Down