Skip to content

Commit

Permalink
Fix rpm build for release
Browse files Browse the repository at this point in the history
* fix referenced pipelineresource not existing anymore
* Use a github-token to do github operation to don't get rate limited (since we
have already one setup)
* use v1beta1

Fixes 1171

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel committed Sep 16, 2020
1 parent d5a15bd commit 2376b3b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 32 deletions.
2 changes: 2 additions & 0 deletions tekton/rpmbuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ need to have a PipelineResource for your git repository. See
kubectl create secret generic copr-cli-config --from-file=copr=${HOME}/.config/copr
```

* Make sure you have the GitHUB token set as documented in [RELEASE_PROCESS.md](../../RELEASE_PROCESS.md)

* You should be able create the task with:

```
Expand Down
10 changes: 6 additions & 4 deletions tekton/rpmbuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ mkdir -p ${TMPD}
clean() { rm -rf ${TMPD} ;}
trap clean EXIT

set -e
set -ex

curl -o ${TMPD}/output.json -s https://api.github.com/repos/tektoncd/cli/releases/latest
[[ -z ${GITHUB_TOKEN} ]] && { echo "We need a GITHUB_TOKEN".; exit 1;}

curl -H "Authorization: token ${GITHUB_TOKEN}" -o ${TMPD}/output.json -s https://api.github.com/repos/tektoncd/cli/releases/latest
version=$(python3 -c "import sys, json;x=json.load(sys.stdin);print(x['tag_name'])" < ${TMPD}/output.json)
version=${version/v}

Expand All @@ -29,8 +31,8 @@ done

cd ${TMPD}

curl -O -L https://github.com/tektoncd/cli/archive/v${version}.tar.gz
curl -H "Authorization: token ${GITHUB_TOKEN}" -O -L https://github.com/tektoncd/cli/archive/v${version}.tar.gz

rpmbuild -bs tekton.spec --define "_sourcedir $PWD" --define "_srcrpmdir $PWD"

copr-cli --config=/var/secret/copr/copr build tektoncd-cli tektoncd-cli-${version}-1.src.rpm
copr-cli --config=<( echo "${COPR_TOKEN}" ) build tektoncd-cli tektoncd-cli-${version}-1.src.rpm
19 changes: 11 additions & 8 deletions tekton/rpmbuild/rpmbuild-run.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: rpmbuild-taskrun
spec:
taskRef:
kind: Task
name: rpmbuild
inputs:
resources:
resources:
inputs:
- name: source
resourceRef:
name: tektoncd-cli-git
params:
- name: copr-cli-secret
value: copr-cli-config
resourceSpec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/tektoncd/cli
37 changes: 17 additions & 20 deletions tekton/rpmbuild/rpmbuild.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: rpmbuild
spec:
inputs:
params:
- name: copr-cli-secret
description: copr cli secret
default: copr-cli-config
- name: github-token-secret
description: name of the secret holding the github-token
default: github-token
resources:
- name: source
type: git
targetPath: src
resources:
inputs:
- name: source
type: git
targetPath: src
steps:
- name: build-rpm
env:
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: bot-token-github
key: bot-token
- name: COPR_TOKEN
valueFrom:
secretKeyRef:
name: copr-cli-config
key: copr
image: quay.io/chmouel/rpmbuild
workingdir: /workspace/src
command: ["tekton/rpmbuild/build.sh"]
volumeMounts:
- name: copr-cli-config
mountPath: /var/secret/copr
volumes:
- name: copr-cli-config
secret:
secretName: "$(inputs.params.copr-cli-secret)"

0 comments on commit 2376b3b

Please sign in to comment.