forked from tektoncd/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
prerelease-checks.yaml
71 lines (70 loc) · 3.18 KB
/
prerelease-checks.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright 2021-2024 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.
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: dashboard-prerelease-checks
spec:
params:
- name: package
description: package to release
default: github.com/tektoncd/dashboard
- name: versionTag
description: The X.Y.Z version that the artifacts would be tagged with
- name: releaseBucket
description: >-
The bucket where to look for the release, in the format gs://<bucket-name>/<project-name>
workspaces:
- name: source-to-release
description: The workspace where the repo has been cloned
steps:
- name: check-git-tag
image: ghcr.io/wolfi-dev/git:alpine@sha256:cb1a409ac765dff98d281625b3b0ce63a798f1494f6814a7e3c9515df7a8ab95
script: |
echo "Checking git tag"
# Look for the tag in the list of tags
git ls-remote --tags https://$(params.package) | \
grep "$(params.versionTag)$" || exit 0
# If the version was found fail
echo "Version $(params.versionTag) already tagged for $(params.package)"
exit 1
- name: check-release-file
image: gcr.io/google.com/cloudsdktool/cloud-sdk:502.0.0@sha256:86cc09d835c1652ad61fe8312e6a9ee2836cd2627e7a03bbab023c9372dc3773
script: |
echo "Checking release file"
# Check if the release file already exists
# gsutil retuns 1 if the object was not found
if gsutil stat $(params.releaseBucket)/previous/$(params.versionTag)/release.yaml; then
echo "Release file already exists for $(params.versionTag) in the release bucket,"
echo "but no git tag was found. To continue remove the release file first."
exit 1
fi
- name: check-github-release
image: docker.io/library/python:3.6-alpine3.9@sha256:368f69f11e002a63d587791bb9652009dbb19a85f015698eac40d687e6f4ab19
script: |
echo "Checking GitHub release"
PACKAGE=$(echo $(params.package) | cut -d/ -f2,3)
# Check if the release exists on GitHub
wget -q -O- --header 'Accept: application/vnd.github.v3+json' \
https://api.github.com/repos/${PACKAGE}/releases | \
python -c 'import sys; import json; print("\n".join([x["tag_name"] for x in json.load(sys.stdin)]))' | \
grep "$(params.versionTag)$" || exit 0
echo "Release $(params.versionTag) already exists for $(params.package)"
exit 1
- name: success-confirmation
image: docker.io/library/alpine:3.20.3@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d
script: |
echo "All pre-release checks for $(params.package) @ $(params.versionTag) were successful"
echo "Happy releasing 😺"