Skip to content

Commit

Permalink
Update release README
Browse files Browse the repository at this point in the history
Add Task to create a draft release in GitHub with all of the commits and
authors.

Update release README with instructions about running the draft release
Task.
  • Loading branch information
Brandon Walker committed Mar 2, 2020
1 parent 5de247b commit ac7630d
Show file tree
Hide file tree
Showing 2 changed files with 237 additions and 15 deletions.
61 changes: 46 additions & 15 deletions tekton/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,55 @@ This cluster

To make a new release:

1. [Create draft release](#create-draft-release) in GitHub with release notes
1. (Optionally) [Apply the latest versions of the Tasks + Pipelines](#setup)
2. (If you haven't already)
1. (If you haven't already)
[Install `tkn`](https://github.com/tektoncd/cli#installing-tkn)
3. [Run the Pipeline](#run-the-pipeline)
4. Create the new tag and release in GitHub
1. [Run the Pipeline](#run-the-pipeline)
1. Create the new tag and release in GitHub
([see one of way of doing that here](https://github.com/tektoncd/pipeline/issues/530#issuecomment-477409459)).
_TODO(tektoncd/pipeline#530): Automate as much of this as possible with
Tekton._
5. Add an entry to [the README](../README.md) at `HEAD` for docs and examples
1. Add an entry to [the README](../README.md) at `HEAD` for docs and examples
for the new release ([README.md#read-the-docs](README.md#read-the-docs)).
6. Update the new release in GitHub with the same links to the docs and
1. Update the new release in GitHub with the same links to the docs and
examples, see
[v0.1.0](https://github.com/tektoncd/pipeline/releases/tag/v0.1.0) for
example.

### Create draft release

The Task `create-draft-triggers-release` calculates the list of PRs merged between the previous release and a specified revision. It also builds a list of authors and uses PRs and authors to build a draft new release in GitHub.

Running this Task multiple times will create multiple drafts; old drafts have to be pruned manually when needed.

Once the draft release is created, the release manager needs to edit the draft, arranging PRs in the right category, highlighting important changes.

Parameters:

- `package`
- `release-tag`
- `previous-release-tag`

Resources:

- `source`, a git resource that points to the release git revision

This Task expects a secret named `github-token` to exists, with a GitHub token in `GITHUB_TOKEN` with enough privileges to list PRs and create a draft release.

```bash
tkn task start \
-i source=tekton-triggers-git \
-p package=tektoncd/triggers \
-p release-tag=v0.3.1 \
-p previous-release-tag=v0.3.0 \
create-draft-triggers-release
```

### Run the Pipeline

To use [`tkn`](https://github.com/tektoncd/cli) to run the
`publish-tekton-pipelines` `Task` and create a release:
`triggers-release` PipelineRun and create a release:

1. Pick the revision you want to release and update the
[`resources.yaml`](./resources.yaml) file to add a `PipelineResoruce` for it,
Expand All @@ -59,14 +89,14 @@ To use [`tkn`](https://github.com/tektoncd/cli) to run the
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: tekton-triggers-vX-Y-
name: tekton-triggers-git
spec:
type: git
params:
- name: url
value: https://github.com/tektoncd/triggers
- name: revision
value: vX.Y.Z-invalid-tags-boouuhhh # REPLACE with the commit you'd like to build from
type: git
params:
- name: url
value: https://github.com/tektoncd/triggers
- name: revision
value: master # REPLACE with the commit you want to release
```
1. To run against your own infrastructure (if you are running
Expand All @@ -89,7 +119,7 @@ To use [`tkn`](https://github.com/tektoncd/cli) to run the
gcloud container clusters get-credentials dogfooding --zone us-central1-a --project tekton-releases
```

1. Run the `release-pipeline` (assuming you are using the dogfooding cluster and
1. Run the `triggers-release` (assuming you are using the dogfooding cluster and
[all the Tasks and Pipelines already exist](#setup)):

```shell
Expand All @@ -104,10 +134,11 @@ To use [`tkn`](https://github.com/tektoncd/cli) to run the
--param=versionTag=${VERSION_TAG} \
--serviceaccount=release-right-meow \
--resource=source-repo=tekton-triggers-git \
--resource=bucket=tekton-bucket \
--resource=bucket=tekton-triggers-bucket \
--resource=builtEventListenerSinkImage=event-listener-sink-image \
--resource=builtControllerImage=triggers-controller-image \
--resource=builtWebhookImage=triggers-webhook-image \
--resource=notification=post-release-trigger \
triggers-release
```

Expand Down
191 changes: 191 additions & 0 deletions tekton/create-draft-triggers-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# 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.

# 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
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:
- name: source
type: git
stepTemplate:
env:
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: github-token
key: GITHUB_TOKEN
- name: VERSION
value: $(inputs.params.release-tag)
- name: PROJECT
value: $(inputs.params.package)
- name: OLD_VERSION
value: $(inputs.params.previous-release-tag)
steps:
- name: header
image: gcr.io/tekton-releases/dogfooding/hub
script: |
#!/bin/bash
set -ex
p=$(basename $PROJECT)
TEKTON_PROJECT=${p^}
cat <<EOF | tee $HOME/release.md
Tekton $TEKTON_PROJECT ${VERSION}
-[Docs @ ${VERSION}](https://github.com/${PROJECT}/tree/${VERSION}/docs)
-[Examples @ ${VERSION}](https://github.com/${PROJECT}/tree/${VERSION}/examples)
EOF
- name: body
image: busybox
script: |
#!/bin/sh
set -ex
cat <<EOF | tee -a $HOME/release.md
## Changes
### Features
* [Feature Title] :sparkles:
[Detailed feature description] (#Number).
[Fill list here]
### Deprecation Notices :rotating_light:
* [Deprecation Notice Title]
[Detailed deprecation notice description] (#Number).
[Fill list here]
### Backwards incompatible changes :rotating_light:
In current release:
* [Change Title]
[Detailed change description] (#Number).
[Fill list here]
### Fixes :bug:
* [Description (#Number)]
[Fill list here]
### Misc :hammer:
* [Description (#Number)]
[Fill list here]
### Docs :book:
* [Description (#Number)]
[Fill list here]
## How to upgrade from $(inputs.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)
script: |
#!/usr/bin/env bash
set -e
# Restore full git history
git fetch --unshallow
LOWER_THRESHOLD=$(git rev-list ${OLD_VERSION} | wc -l)
UPPER_THRESHOLD=$(git rev-list $(inputs.resources.source.revision) | wc -l)
echo "LOWER_THRESHOLD: $LOWER_THRESHOLD"
echo "UPPER_THRESHOLD: $UPPER_THRESHOLD"
# Save the PR data in CSV. Only consider PRs whose number of ancestors
# is greater than the number of ancerstors of the commit sha of the
# previous PR.
# "author;number;title"
hub pr list --state merged -f "%sm;%au;%i;%t%n" | \
while read pr; do
SHA=$(echo $pr | cut -d';' -f1)
echo "$(git rev-list $SHA | wc -l);$(echo $pr | cut -d';' -f2-)"
done | \
awk -F";" '$1 > '${LOWER_THRESHOLD}' && $1 <= '${UPPER_THRESHOLD}' { print }' |\
sort -n | cut -d';' -f2- > $HOME/pr.csv
echo "$(wc -l $HOME/pr.csv | awk '{ print $1}') PRs in the new release."
cat $HOME/pr.csv
- name: authors
image: gcr.io/tekton-releases/dogfooding/hub
workingdir: $(inputs.resources.source.path)
script: |
#!/usr/bin/env bash
set -ex
cat <<EOF | tee -a $HOME/release.md
## Thanks
Thanks to these contributors who contributed to ${VERSION}!
EOF
awk -F";" '{ print "- :heart: @"$1 }' $HOME/pr.csv | sort -u | tee -a $HOME/release.md
cat <<EOF | tee -a $HOME/release.md
Extra shout-out for awesome release notes:
* :heart_eyes: [@GitHub Nickname] [Fill list here]
EOF
- name: pr-data
image: gcr.io/tekton-releases/dogfooding/hub
workingdir: $(inputs.resources.source.path)
script: |
#!/usr/bin/env bash
set -ex
cat <<EOF | tee -a $HOME/release.md
## Unsorted PR List
# List of PRs merged between $OLD_VERSION and $VERSION
To Be Done: Categorize these PRs into Features, Deprecation Notices,
Backward Incompatible Changes, Fixes, Docs, Misc.
EOF
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)
script: |
#!/usr/bin/env bash
set -ex
hub release create --draft --prerelease \
--commitish $(inputs.resources.source.revision) \
--file $HOME/release.md ${VERSION}

0 comments on commit ac7630d

Please sign in to comment.