|
| 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: {} |
0 commit comments