Inline the semver pipeline.

main^2
Tom Alexander 2 weeks ago
parent 83cf479342
commit 69e36b1ad6
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -19,7 +19,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:
@ -30,7 +30,7 @@ spec:
- name: unix-time
description: The current date in unix timestamp format
steps:
- image: alpine:3.18
- image: alpine:3.19
name: get-time-step
script: |
#!/usr/bin/env sh
@ -110,7 +110,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:
@ -118,7 +118,7 @@ spec:
memory: 600Mi
workingDir: "$(workspaces.source.path)"
steps:
- image: alpine:3.18
- image: alpine:3.19
name: copy-private-files
script: |
#!/usr/bin/env sh
@ -214,7 +214,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:
@ -237,7 +237,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:

@ -19,7 +19,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:
@ -30,7 +30,7 @@ spec:
- name: unix-time
description: The current date in unix timestamp format
steps:
- image: alpine:3.18
- image: alpine:3.19
name: get-time-step
script: |
#!/usr/bin/env sh
@ -40,7 +40,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:
@ -143,7 +143,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:
@ -151,7 +151,7 @@ spec:
memory: 600Mi
workingDir: "$(workspaces.source.path)"
steps:
- image: alpine:3.18
- image: alpine:3.19
name: copy-private-files
script: |
#!/usr/bin/env sh
@ -246,7 +246,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:
@ -269,7 +269,7 @@ spec:
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
image: alpine:3.19
name: ""
resources:
requests:

@ -0,0 +1,186 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: semver
spec:
pipelineSpec:
params:
- name: REPO_OWNER
description: Owner of the repo on gitea
type: string
- name: REPO_NAME
description: Name of the repo on gitea
type: string
- name: PULL_BASE_SHA
description: The commit sha
type: string
- name: JOB_NAME
description: The name of the job to report to gitea
type: string
tasks:
- name: calculate-tag
runAfter:
- report-pending
workspaces:
- name: source
workspace: git-source
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.19
name: ""
resources:
requests:
cpu: 10m
memory: 600Mi
workingDir: /workspace/source
results:
- name: tag
description: The tag to use for the docker container
steps:
- image: alpine/git:2.43.0
name: calculate-tag
script: |
#!/usr/bin/env sh
set -euo pipefail
git config --global --add safe.directory $(workspaces.source.path)
git fetch --tags
current_tag=$(git tag --points-at HEAD --list 'v*.*.*')
if [ -z "$current_tag" ]; then
prev_tag=$(git tag --list 'v*.*.*' | sort -V -r | head -n 1)
if [ -n "$prev_tag" ]; then
last_bit=$(echo "$prev_tag" | cut -d '.' -f 3)
incremented=$((last_bit + 1))
prefix=$(echo "$prev_tag" | grep -oE 'v[0-9]*\.[0-9]*\.')
final_tag="${prefix}${incremented}"
else
final_tag="v0.0.1"
fi
echo -n "${final_tag}" | tee $(results.tag.path)
git tag "${final_tag}"
git push origin "${final_tag}"
else
echo -n "${current_tag}" | tee $(results.tag.path)
fi
- name: report-pending
taskRef:
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/gitea-set-status/0.1/gitea-set-status.yaml
runAfter:
- fetch-repository
params:
- name: CONTEXT
value: "$(params.JOB_NAME)"
- name: REPO_FULL_NAME
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
- name: GITEA_HOST_URL
value: code.fizz.buzz
- name: SHA
value: "$(tasks.fetch-repository.results.commit)"
- name: DESCRIPTION
value: "Build $(params.JOB_NAME) has started"
- name: STATE
value: pending
- name: TARGET_URL
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
- name: fetch-repository
taskRef:
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/git-clone/0.9/git-clone.yaml
workspaces:
- name: output
workspace: git-source
params:
- name: url
value: $(params.REPO_URL)
- name: revision
value: $(params.PULL_BASE_SHA)
- name: deleteExisting
value: "true"
finally:
- name: report-success
when:
- input: "$(tasks.status)"
operator: in
values: ["Succeeded", "Completed"]
taskRef:
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/gitea-set-status/0.1/gitea-set-status.yaml
params:
- name: CONTEXT
value: "$(params.JOB_NAME)"
- name: REPO_FULL_NAME
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
- name: GITEA_HOST_URL
value: code.fizz.buzz
- name: SHA
value: "$(tasks.fetch-repository.results.commit)"
- name: DESCRIPTION
value: "Build $(params.JOB_NAME) has succeeded"
- name: STATE
value: success
- name: TARGET_URL
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
- name: report-failure
when:
- input: "$(tasks.status)"
operator: in
values: ["Failed"]
taskRef:
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/gitea-set-status/0.1/gitea-set-status.yaml
params:
- name: CONTEXT
value: "$(params.JOB_NAME)"
- name: REPO_FULL_NAME
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
- name: GITEA_HOST_URL
value: code.fizz.buzz
- name: SHA
value: "$(tasks.fetch-repository.results.commit)"
- name: DESCRIPTION
value: "Build $(params.JOB_NAME) has failed"
- name: STATE
value: failure
- name: TARGET_URL
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
workspaces:
- name: git-source
workspaces:
- name: git-source
volumeClaimTemplate:
spec:
storageClassName: "nfs-client"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
subPath: source
serviceAccountName: build-bot
timeout: 240h0m0s
params: []

@ -3,33 +3,16 @@ kind: TriggerConfig
spec:
postsubmits:
- name: semver
agent: tekton-pipeline
branches:
- ^main$
- ^master$
context: homepage
source: "pipeline-semver.yaml"
max_concurrency: 1
# Override https-based url from lighthouse events.
clone_uri: "git@code.fizz.buzz:talexander/homepage.git"
pipeline_run_spec:
serviceAccountName: build-bot
pipelineRef:
name: semver
namespace: lighthouse
workspaces:
- name: git-source
volumeClaimTemplate:
spec:
storageClassName: "nfs-client"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
subPath: homepage-source
params: []
branches:
- ^main$
- ^master$
- name: build-homepage-staging
source: "pipeline-build-homepage-staging.yaml"
max_concurrency: 1
# Override https-based url from lighthouse events.
clone_uri: "git@code.fizz.buzz:talexander/homepage.git"
skip_branches:
@ -37,6 +20,7 @@ spec:
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
- name: build-homepage
source: "pipeline-build-homepage.yaml"
max_concurrency: 1
# Override https-based url from lighthouse events.
clone_uri: "git@code.fizz.buzz:talexander/homepage.git"
branches:

Loading…
Cancel
Save