Skip to content

Commit b3deefa

Browse files
committed
Provide Tekton manifests to release ks
Signed-off-by: John Niang <[email protected]>
1 parent 8f47e9a commit b3deefa

File tree

9 files changed

+245
-7
lines changed

9 files changed

+245
-7
lines changed

.github/tekton/README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ We dogfood our project by using Tekton Pipelines to build and test `ks`. This di
66

77
## Tekton manifests
88

9-
| Manifest | Description |
10-
| ---------------------------------- | ---------------------------------------------------------------------------------- |
11-
| build-bot.yaml | Needed by `PipelineRun`. For more granularity in specifying execution credentials. |
12-
| pull-request-pipeline.yaml | `Pipeline` configuration for ks when pull request event is comming. |
13-
| shared-storage.yaml | Share volume among tasks. Such as source code output from `git-clone` task. |
14-
| pull-request-trigger.yaml | Indicate what happens when the EventListener detects an event. |
15-
| pull-request-trigger-template.yaml | Specifies a blueprint for PipelineRun. |
9+
| Manifest | Description |
10+
| ---------------------------------- | -------------------------------------------------------------------------------------------------- |
11+
| shared-storage.yaml | Share volume among tasks. Such as source code output from `git-clone` task. |
12+
| build-bot.yaml | Needed by `PipelineRun`. For more granularity in specifying execution credentials. |
13+
| pull-request-pipeline.yaml | `Pipeline` configuration for ks when pull request event is comming. |
14+
| pull-request-trigger.yaml | Indicate what happens when the EventListener detects an event. |
15+
| pull-request-trigger-template.yaml | Specifies a blueprint for PipelineRun. |
16+
| release-bot.yaml | Needed by `ks-release-trigger-template`. For more granularity in specifying execution credentials. |
17+
| release-pipeline.yaml | Tasks defined in it when releasing. |
18+
| release-trigger-template.yaml | Specifies a blueprint for releasing. |
19+
| release-trigger.yaml | Indicate what happens when the EventListener detects an event. |
20+
| goreleaser-release.yaml | For releasing using goreleaser. |
1621

1722
## FAQ
1823

.github/tekton/build-bot.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ kind: ServiceAccount
33
metadata:
44
name: ks-pipeline-bot
55
secrets:
6+
# For setting commit status
67
- name: github
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: Task
3+
metadata:
4+
name: goreleaser-release
5+
labels:
6+
app.kubernetes.io/version: "0.2"
7+
annotations:
8+
tekton.dev/pipelines.minVersion: "0.12.1"
9+
tekton.dev/categories: Automation, Publishing
10+
tekton.dev/tags: golang, release-automation, package
11+
tekton.dev/displayName: "GoReleaser"
12+
tekton.dev/platforms: "linux/amd64"
13+
spec:
14+
description: |-
15+
GoReleaser builds Go binaries for several platforms.
16+
It creates a GitHub release and then pushes a Homebrew formula to a tap repository.
17+
params:
18+
- description: base package to build in
19+
name: package
20+
type: string
21+
- default: bot-token-github
22+
description: name of the secret holding the github-token
23+
name: github-token-secret
24+
type: string
25+
- default: bot-token
26+
description: name of the secret key holding the github-token
27+
name: github-token-secret-key
28+
type: string
29+
- default: --timeout=30m
30+
description: flags to pass to `goreleaser release`
31+
name: flags
32+
type: string
33+
- default: docker.io/goreleaser/goreleaser@sha256:0e87d0e33840a556d3b9c10a7f71a3a69bcd9c29b86a180cbbf7d7ad1f3fa280
34+
description: container image location for goreleaser
35+
name: image
36+
type: string
37+
- name: insecure_registry
38+
description: Allows the user to push to an insecure registry that has been specified
39+
default: ""
40+
- name: dind_image
41+
description: The location of the docker-in-docker image.
42+
default: docker:dind
43+
steps:
44+
- image: $(params.image)
45+
name: fetch-all-tags
46+
script: |
47+
git status
48+
git diff
49+
git fetch -p --all
50+
workingDir: $(workspaces.source.path)
51+
- name: release
52+
image: $(params.image)
53+
env:
54+
- name: GOPATH
55+
value: /workspace
56+
- name: GITHUB_TOKEN
57+
valueFrom:
58+
secretKeyRef:
59+
key: $(params.github-token-secret-key)
60+
name: $(params.github-token-secret)
61+
# Connect to the sidecar over TCP, with TLS.
62+
- name: DOCKER_TLS_VERIFY
63+
value: "1"
64+
# Verify TLS.
65+
- name: DOCKER_HOST
66+
value: tcp://localhost:2376
67+
# Use the certs generated by the sidecard daemon.
68+
- name: DOCKER_CERT_PATH
69+
value: /certs/client
70+
script: |
71+
apk add --no-cache upx
72+
goreleaser release $(params.flags)
73+
volumeMounts:
74+
- mountPath: /certs/client
75+
name: dind-certs
76+
workingDir: $(workspaces.source.path)
77+
sidecars:
78+
- image: $(params.dind_image)
79+
name: server
80+
args:
81+
- --storage-driver=vfs
82+
- --userland-proxy=false
83+
- --debug
84+
securityContext:
85+
privileged: true
86+
env:
87+
# Write generated certs to the path shared with the client.
88+
- name: DOCKER_TLS_CERTDIR
89+
value: /certs
90+
volumeMounts:
91+
- mountPath: /certs/client
92+
name: dind-certs
93+
# Wait for the dind daemon to generate the certs it will share with the
94+
# client.
95+
readinessProbe:
96+
periodSeconds: 1
97+
exec:
98+
command: ['ls', '/certs/client/ca.pem']
99+
workspaces:
100+
- description: The workspace containing the Go source code which needs to be released.
101+
mountPath: /workspace/src/$(params.package)
102+
name: source
103+
volumes:
104+
- name: dind-certs
105+
emptyDir: {}

.github/tekton/release-bot.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: ks-release-bot
5+
secrets:
6+
# For uploading assets to a release
7+
- name: bot-token-github
8+
# For pushing docker image to docker.io
9+
- name: docker-id
10+
# For pushing docker image to ghcr.io
11+
- name: ghcr-id
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: triggers.tekton.dev/v1beta1
2+
kind: TriggerTemplate
3+
metadata:
4+
name: ks-release
5+
spec:
6+
params:
7+
- name: revision
8+
- name: clone-url
9+
- name: tag-name
10+
resourcetemplates:
11+
- apiVersion: tekton.dev/v1beta1
12+
kind: PipelineRun
13+
metadata:
14+
generateName: ks-release-$(tt.params.tag-name)-
15+
spec:
16+
serviceAccountName: ks-release-bot
17+
pipelineRef:
18+
name: ks-release
19+
params:
20+
- name: clone-url
21+
value: $(tt.params.clone-url)
22+
- name: revision
23+
value: $(tt.params.revision)
24+
workspaces:
25+
- name: repo
26+
persistentVolumeClaim:
27+
claimName: shared-ks-storage
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: triggers.tekton.dev/v1beta1
2+
kind: Trigger
3+
metadata:
4+
name: ks-release-trigger
5+
spec:
6+
interceptors:
7+
- ref:
8+
name: github
9+
params:
10+
- name: secretRef
11+
value:
12+
secretName: webhook-secret
13+
secretKey: secret
14+
- name: eventTypes
15+
value:
16+
- push
17+
- ref:
18+
name: cel
19+
params:
20+
- name: filter
21+
value: "body.ref.startsWith('refs/tags/')"
22+
- ref:
23+
name: cel
24+
params:
25+
- name: filter
26+
value: "body.repository.full_name == 'kubesphere-sigs/ks'"
27+
- ref:
28+
name: cel
29+
params:
30+
- name: overlays
31+
value:
32+
- key: tag-name
33+
expression: "body.ref.replace('refs/tags/', '')"
34+
bindings:
35+
- name: clone-url
36+
value: $(body.repository.clone_url)
37+
- name: revision
38+
value: $(extensions.tag-name)
39+
- name: tag-name
40+
value: $(extensions.tag-name)
41+
template:
42+
ref: ks-release
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: Pipeline
3+
metadata:
4+
name: ks-release
5+
spec:
6+
workspaces:
7+
- name: repo
8+
params:
9+
# - name: repo-full-name
10+
# description: "Repository full name. like: kubesphere-sigs/ks"
11+
- name: clone-url
12+
description: Git repository clone URL.
13+
- name: revision
14+
description: Git repository revision to checkout.
15+
# - name: dashboard-url
16+
# description: Tekton dashboard access URL, like http://demo:31962/#/namespaces/ks/pipelineruns.
17+
tasks:
18+
- name: checkout
19+
taskRef:
20+
name: git-clone
21+
params:
22+
- name: url
23+
value: $(params.clone-url)
24+
- name: revision
25+
value: $(params.revision)
26+
workspaces:
27+
- name: output
28+
workspace: repo
29+
- name: release
30+
runAfter:
31+
- checkout
32+
taskRef:
33+
name: goreleaser-release
34+
params:
35+
- name: package
36+
value: github.com/kubesphere-sigs/ks
37+
- name: flags
38+
value: --rm-dist --debug
39+
workspaces:
40+
- name: source
41+
workspace: repo
File renamed without changes.

.goreleaser.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,9 @@ dockers:
108108
- "surenpi/ks:{{.Tag}}"
109109
- "ghcr.io/linuxsuren/ks/ks:latest"
110110
- "ghcr.io/linuxsuren/ks/ks:{{.Tag}}"
111+
- goos: linux
112+
goarch: amd64
113+
dockerfile: build/Dockerfile
114+
image_templates:
115+
- "surenpi/ks-tool:v1.17.0-{{.Tag}}"
116+
- "surenpi/ks-tool:latest"

0 commit comments

Comments
 (0)