-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1657 from SaschaSchwarze0/sascha-bump-tekton
Add automation to bump Tekton automatically
- Loading branch information
Showing
4 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)" | ||
|
||
usage() { | ||
echo | ||
echo "Usage:" | ||
echo " $0 [--output SOME_FILE]" | ||
echo | ||
exit 1 | ||
} | ||
|
||
OUTPUT_FILE= | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
--output) | ||
shift | ||
OUTPUT_FILE="$1" | ||
;; | ||
|
||
*) | ||
echo "Unknown flag $1" | ||
usage | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# Retrieve current Tekton version | ||
OLD_VERSION="$( | ||
grep github.com/tektoncd/pipeline "${BASEDIR}/go.mod" | | ||
sed s#github.com/tektoncd/pipeline## | | ||
tr -d ' \t' | ||
)" | ||
|
||
# Retrieve the latest Tekton LTS version | ||
# Assumption: every third Tekton release is LTS | ||
NEW_VERSION="$( | ||
curl -s 'https://api.github.com/repos/tektoncd/pipeline/releases?per_page=100' | | ||
jq -r '.[] | select(.draft == false and .prerelease == false and (.tag_name | split(".") | .[1] | tonumber) % 3 == 2) | .tag_name' | | ||
sort --version-sort | | ||
tail -n 1 | ||
)" | ||
|
||
# Write output | ||
if [ -n "${OUTPUT_FILE}" ]; then | ||
echo "OLD_VERSION=${OLD_VERSION}" >>"${OUTPUT_FILE}" | ||
echo "NEW_VERSION=${NEW_VERSION}" >>"${OUTPUT_FILE}" | ||
fi | ||
|
||
# Update go.mod | ||
pushd "${BASEDIR}" >/dev/null | ||
go get "github.com/tektoncd/pipeline@${NEW_VERSION}" | ||
go mod tidy | ||
go mod vendor | ||
popd >/dev/null | ||
|
||
# Update ci.yml | ||
sed -i "s/- v.* # RETAIN-COMMENT: TEKTON_NEWEST_LTS/- ${NEW_VERSION} # RETAIN-COMMENT: TEKTON_NEWEST_LTS/" "${BASEDIR}/.github/workflows/ci.yml" | ||
|
||
# Update Makefile | ||
sed -i "s/TEKTON_VERSION ?= v.*/TEKTON_VERSION ?= ${NEW_VERSION}/" "${BASEDIR}/Makefile" | ||
|
||
# Update install-tekton.sh | ||
sed -i "s/TEKTON_VERSION:-v.*}/TEKTON_VERSION:-${NEW_VERSION}}/" "${BASEDIR}/hack/install-tekton.sh" | ||
|
||
# Update README.md | ||
sed -i "s#https://storage.googleapis.com/tekton-releases/pipeline/previous/v.*/release.yaml#https://storage.googleapis.com/tekton-releases/pipeline/previous/${NEW_VERSION}/release.yaml#" "${BASEDIR}/README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
name: Update Tekton version | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
issue_comment: | ||
types: [created, edited] | ||
jobs: | ||
check-new-versions: | ||
if: contains(github.event.comment.body, '/rebase') || github.event_name == 'schedule' | ||
permissions: | ||
pull-requests: write # To be able to create pull requests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21.x' | ||
cache: true | ||
check-latest: true | ||
|
||
- name: Update Tekton version | ||
id: update-tekton | ||
run: ./.github/bump-tekton-lts.sh --output "${GITHUB_OUTPUT}" | ||
|
||
- name: Create pull request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
commit-message: Bump Tekton Pipeline from ${{ steps.update-tekton.outputs.OLD_VERSION }} to ${{ steps.update-tekton.outputs.NEW_VERSION }} | ||
title: Bump Tekton Pipeline from ${{ steps.update-tekton.outputs.OLD_VERSION }} to ${{ steps.update-tekton.outputs.NEW_VERSION }} | ||
body: | | ||
# Changes | ||
Bumps Tekton Pipeline from ${{ steps.update-tekton.outputs.OLD_VERSION }} to ${{ steps.update-tekton.outputs.NEW_VERSION }} | ||
You can trigger a rebase manually by commenting `/rebase` and resolve any conflicts with this PR. | ||
# Submitter Checklist | ||
- [ ] Includes tests if functionality changed/was added | ||
- [ ] Includes docs if changes are user-facing | ||
- [x] [Set a kind label on this PR](https://prow.k8s.io/command-help#kind) | ||
- [x] Release notes block has been filled in, or marked NONE | ||
# Release Notes | ||
```release-note | ||
Update the the new latest Tekton LTS release ${{ steps.update-tekton.outputs.NEW_VERSION }} | ||
``` | ||
labels: kind/dependency-change | ||
branch: bump-tekton-pipeline | ||
delete-branch: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters