Skip to content

Commit 1782d43

Browse files
address review comments
1 parent 459c291 commit 1782d43

File tree

4 files changed

+125
-115
lines changed

4 files changed

+125
-115
lines changed

.github/workflows/nightly-builds.yaml

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,19 @@ on:
1010
description: 'Kubernetes version to test with'
1111
required: false
1212
default: 'v1.33.0'
13-
type: choice
14-
options:
15-
- v1.33.0
16-
- v1.32.0
17-
- v1.31.0
18-
dry_run:
19-
description: 'Perform dry run (no actual publishing)'
20-
required: false
21-
default: false
22-
type: boolean
2313
nightly_bucket:
2414
description: 'Nightly bucket for builds'
2515
required: false
2616
default: 'gs://tekton-releases-nightly/pipeline'
2717
type: string
28-
# uncomment the following to enable manual testing of the workflow
29-
# push:
30-
# branches:
31-
# - test-rel
32-
# paths:
33-
# - '.github/workflows/nightly-builds.yaml'
34-
# - 'tekton/**'
35-
# - 'cmd/**'
36-
# - 'pkg/**'
3718

3819
env:
3920
KUBERNETES_VERSION: ${{ inputs.kubernetes_version || 'v1.33.0' }}
4021
REGISTRY: ghcr.io
41-
DRY_RUN: ${{ inputs.dry_run || false }}
42-
43-
COMPONENT: pipeline
44-
4522
PACKAGE: github.com/${{ github.repository }}
46-
GIT_ORG: ${{ github.repository_owner }}
47-
GIT_REPO: ${{ github.event.repository.name }}
48-
BUCKET: ${{ inputs.nightly_bucket || 'gs://anitha-tekton-nightly-test/pipeline' }}
23+
BUCKET: ${{ inputs.nightly_bucket || 'gs://tekton-releases-nightly/pipeline' }}
4924
IMAGE_REGISTRY_PATH: ${{ github.repository }}
50-
IMAGE_REGISTRY_USER: ${{ github.actor }}
25+
IMAGE_REGISTRY_USER: tekton-robot
5126

5227
jobs:
5328
build:
@@ -90,28 +65,33 @@ jobs:
9065
env:
9166
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN || github.token }}
9267
run: |
68+
# Create Git authentication secret with proper Tekton annotations
9369
kubectl create secret generic git-resolver-secret \
9470
--from-literal=token="${GITHUB_TOKEN}" \
9571
-n tekton-pipelines-resolvers || true
9672
97-
kubectl patch configmap resolvers-feature-flags -n tekton-pipelines-resolvers --patch='
98-
data:
99-
enable-git-resolver: "true"
100-
enable-hub-resolver: "true"
101-
enable-bundles-resolver: "true"
102-
enable-cluster-resolver: "true"
103-
' || true
73+
kubectl annotate secret git-resolver-secret \
74+
tekton.dev/git-0=github.com \
75+
-n tekton-pipelines-resolvers || true
10476
77+
kubectl create secret generic git-resolver-secret \
78+
--from-literal=token="${GITHUB_TOKEN}" \
79+
-n default || true
80+
81+
kubectl annotate secret git-resolver-secret \
82+
tekton.dev/git-0=github.com \
83+
-n default || true
84+
10585
kubectl patch configmap git-resolver-config -n tekton-pipelines-resolvers --patch='
10686
data:
107-
default-url: "https://github.com"
108-
default-revision: "main"
109-
fetch-timeout: "1m"
110-
scm-type: "github"
111-
server-url: "https://api.github.com"
11287
api-token-secret-name: "git-resolver-secret"
11388
api-token-secret-key: "token"
11489
' || true
90+
91+
kubectl patch configmap feature-flags -n tekton-pipelines --patch='
92+
data:
93+
enable-cel-in-whenexpression: "true"
94+
' || true
11595
11696
- name: Install tkn CLI
11797
uses: tektoncd/actions/setup-tektoncd-cli@main
@@ -120,24 +100,30 @@ jobs:
120100
121101
- name: Apply Build Pipeline Definition
122102
run: |
123-
kubectl apply -f tekton/publish.yaml
124-
kubectl apply -f tekton/release-pipeline.yaml
103+
kustomize build tekton | kubectl apply -f -
125104
126-
- name: Create secrets and PVC template
105+
- name: Create secrets, service account and PVC template
127106
env:
128107
GCS_SERVICE_ACCOUNT_KEY: ${{ secrets.GCS_SERVICE_ACCOUNT_KEY }}
129108
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN || github.token }}
109+
IMAGE_REGISTRY_USER: ${{ env.IMAGE_REGISTRY_USER }}
130110
run: |
111+
# Create GCS service account secret for release bucket access
131112
echo "${GCS_SERVICE_ACCOUNT_KEY}" > /tmp/gcs-key.json
132113
kubectl create secret generic release-secret \
133114
--from-file=release.json=/tmp/gcs-key.json
134115
rm -f /tmp/gcs-key.json
135-
136-
kubectl create secret docker-registry ghcr-creds \
137-
--docker-server=ghcr.io \
138-
--docker-username=${{ github.actor }} \
139-
--docker-password="${GHCR_TOKEN}" \
140-
--docker-email=${{ github.actor }}@users.noreply.github.com
116+
117+
# Create a Kubernetes secret for GHCR authentication.
118+
# This version creates the secret with a custom key name `docker-config.json`
119+
# (instead of the default `.dockerconfigjson`) to match what the publish task expects.
120+
echo "${GHCR_TOKEN}" > /tmp/docker-config.json
121+
kubectl create secret generic release-images-secret \
122+
--from-file=docker-config.json=/tmp/docker-config.json
123+
rm -f /tmp/docker-config.json
124+
125+
# Apply service account configuration with proper RBAC
126+
kubectl apply -f tekton/account.yaml
141127
142128
cat > workspace-template.yaml << EOF
143129
spec:
@@ -155,6 +141,7 @@ jobs:
155141
echo "Starting Tekton pipeline..."
156142
157143
PIPELINE_RUN=$(tkn pipeline start pipeline-release \
144+
--serviceaccount=release-right-meow \
158145
--param package="${{ env.PACKAGE }}" \
159146
--param gitRevision="${{ steps.version.outputs.latest_sha }}" \
160147
--param versionTag="${{ steps.version.outputs.version_tag }}" \
@@ -163,17 +150,18 @@ jobs:
163150
--param imageRegistryPath="${{ env.IMAGE_REGISTRY_PATH }}" \
164151
--param imageRegistryUser="${{ env.IMAGE_REGISTRY_USER }}" \
165152
--param imageRegistryRegions="" \
166-
--param buildPlatforms="linux/amd64" \
167-
--param publishPlatforms="linux/amd64" \
153+
--param buildPlatforms="linux/amd64,linux/arm64,linux/s390x,linux/ppc64le" \
154+
--param publishPlatforms="linux/amd64,linux/arm64,linux/s390x,linux/ppc64le,windows/amd64" \
168155
--param koExtraArgs="" \
169156
--param serviceAccountPath=release.json \
170-
--param serviceAccountImagesPath=.dockerconfigjson \
171-
--param releaseAsLatest="false" \
157+
--param serviceAccountImagesPath=docker-config.json \
158+
--param releaseAsLatest="true" \
172159
--param runTests="false" \
173160
--workspace name=workarea,volumeClaimTemplateFile=workspace-template.yaml \
174161
--workspace name=release-secret,secret=release-secret \
175-
--workspace name=release-images-secret,secret=ghcr-creds \
176-
--pipeline-timeout 2h \
162+
--workspace name=release-images-secret,secret=release-images-secret \
163+
--tasks-timeout 2h \
164+
--pipeline-timeout 3h \
177165
--output name) || {
178166
echo "Failed to start Tekton pipeline!"
179167
exit 1

tekton/account.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: release-right-meow
5+
secrets:
6+
- name: release-secret
7+
- name: git-resolver-secret
8+
- name: release-images-secret
9+
10+
---
11+
12+
apiVersion: v1
13+
kind: Secret
14+
metadata:
15+
name: kube-api-secret
16+
annotations:
17+
kubernetes.io/service-account.name: release-right-meow
18+
type: kubernetes.io/service-account-token
19+
20+
---
21+
22+
kind: Role
23+
apiVersion: rbac.authorization.k8s.io/v1
24+
metadata:
25+
name: pipeline-role
26+
rules:
27+
- apiGroups: [""]
28+
resources: ["services", "configmaps", "secrets"]
29+
verbs: ["get", "create", "update", "patch", "list"]
30+
- apiGroups: ["apps"]
31+
resources: ["deployments"]
32+
verbs: ["get", "create", "update", "patch", "list"]
33+
- apiGroups: ["tekton.dev"]
34+
resources: ["pipelines", "pipelineruns", "tasks", "taskruns"]
35+
verbs: ["get", "create", "update", "patch", "list"]
36+
- apiGroups: [""]
37+
resources: ["pods", "pods/log"]
38+
verbs: ["get", "list"]
39+
40+
---
41+
42+
apiVersion: rbac.authorization.k8s.io/v1
43+
kind: RoleBinding
44+
metadata:
45+
name: pipeline-role-binding
46+
roleRef:
47+
apiGroup: rbac.authorization.k8s.io
48+
kind: Role
49+
name: pipeline-role
50+
subjects:
51+
- kind: ServiceAccount
52+
name: release-right-meow

tekton/publish.yaml

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
description: Extra args to be passed to ko
1717
default: "--preserve-import-paths"
1818
- name: versionTag
19-
description: Version tag (X.Y.Z for stable, vYYYYMMDD-abc1234 for nightly)
19+
description: The version, vX.Y.Z for stable, vYYYYMMDD-abc1234 for nightly that the artifacts should be tagged with (including `v`).
2020
- name: imageRegistry
2121
description: The target image registry
2222
default: ghcr.io
@@ -41,9 +41,9 @@ spec:
4141
description: >-
4242
The workspace where the repo has been cloned. This should ideally
4343
be /go/src/$(params.package) however that is not possible today,
44-
see https://github.com/tektoncd/pipeline/issues/3786. For nightly builds
45-
on forks, we use a more generic mount path that works across repositories.
46-
mountPath: /go/src/repo
44+
see https://github.com/tektoncd/pipeline/issues/3786. To use this
45+
task on a fork of pipeline change the mountPath below
46+
mountPath: /go/src/github.com/tektoncd/pipeline
4747
- name: release-secret
4848
description: The secret that contains a service account authorized to push to the imageRegistry and to the output bucket
4949
- name: output
@@ -73,57 +73,23 @@ spec:
7373
steps:
7474

7575
- name: container-registry-auth
76-
image: cgr.dev/chainguard/crane:latest-dev@sha256:68d9b984ee9cb5ff9cf7a779e8bdf3c2022f9042abfa1f0f5727a082a9429535
76+
image: cgr.dev/chainguard/crane:latest-dev@sha256:430c7813147443b59185d79ce7f5d682698a9fc3072f100850dc3a04100c1d91
7777
script: |
7878
#!/bin/sh
7979
set -ex
8080
81-
# For GHCR (GitHub Container Registry), handle authentication differently
82-
if [[ "$(params.imageRegistry)" == "ghcr.io" ]]; then
83-
echo "🔍 Configuring authentication for GitHub Container Registry"
84-
85-
# For GHCR with Docker registry secrets, the secret structure is different
86-
# Check if we have a .dockerconfigjson file (from kubectl create secret docker-registry)
87-
if [[ -f "$(workspaces.release-secret.path)/.dockerconfigjson" ]]; then
88-
echo "Using Docker registry secret format"
89-
cp "$(workspaces.release-secret.path)/.dockerconfigjson" /workspace/docker-config.json
90-
elif [[ -f "${CONTAINER_REGISTRY_CREDENTIALS}" ]]; then
91-
# Check if it's a docker config.json or a simple token
92-
if cat ${CONTAINER_REGISTRY_CREDENTIALS} | jq -r '.auths // empty' >/dev/null 2>&1; then
93-
# It's a docker config.json, copy it directly
94-
echo "Using docker config.json format"
95-
cp ${CONTAINER_REGISTRY_CREDENTIALS} /workspace/docker-config.json
96-
else
97-
# It's a simple token, create docker config
98-
echo "Using token-based authentication"
99-
TOKEN=$(cat ${CONTAINER_REGISTRY_CREDENTIALS})
100-
101-
# Create docker config for GHCR
102-
mkdir -p ~/.docker
103-
echo '{"auths":{"ghcr.io":{"auth":"'$(echo -n "${CONTAINER_REGISTRY_USER}:${TOKEN}" | base64 -w 0)'"}}}' > ~/.docker/config.json
104-
cp ~/.docker/config.json /workspace/docker-config.json
105-
fi
106-
else
107-
echo "Credentials file not found: ${CONTAINER_REGISTRY_CREDENTIALS}"
108-
exit 1
109-
fi
110-
else
111-
# Original GCR authentication logic
112-
echo "🔍 Configuring authentication for GCR/other registries"
113-
114-
# Login to the container registry
115-
DOCKER_CONFIG=$(cat ${CONTAINER_REGISTRY_CREDENTIALS} | \
116-
crane auth login -u ${CONTAINER_REGISTRY_USER} --password-stdin $(params.imageRegistry) 2>&1 | \
117-
sed -n 's,^.*logged in via \(.*\)$,\1,p')
81+
# Login to the container registry
82+
DOCKER_CONFIG=$(cat ${CONTAINER_REGISTRY_CREDENTIALS} | \
83+
crane auth login -u ${CONTAINER_REGISTRY_USER} --password-stdin $(params.imageRegistry) 2>&1 | \
84+
sed -n 's,^.*logged in via \(.*\)$,\1,p')
11885
119-
# Auth with account credentials for all regions.
120-
for region in ${REGIONS}
121-
do
122-
HOSTNAME=${region}.$(params.imageRegistry)
123-
cat ${CONTAINER_REGISTRY_CREDENTIALS} | crane auth login -u ${CONTAINER_REGISTRY_USER} --password-stdin ${HOSTNAME}
124-
done
125-
cp ${DOCKER_CONFIG} /workspace/docker-config.json
126-
fi
86+
# Auth with account credentials for all regions.
87+
for region in ${REGIONS}
88+
do
89+
HOSTNAME=${region}.$(params.imageRegistry)
90+
cat ${CONTAINER_REGISTRY_CREDENTIALS} | crane auth login -u ${CONTAINER_REGISTRY_USER} --password-stdin ${HOSTNAME}
91+
done
92+
cp ${DOCKER_CONFIG} /workspace/docker-config.json
12793
12894
- name: create-ko-yaml
12995
image: cgr.dev/chainguard/go:latest-dev@sha256:8e2632f8725d1a48d6f97a13c71e1594fe17dc9c0e7d00543091a04ac82e429b
@@ -181,7 +147,6 @@ spec:
181147
set -ex
182148
183149
# Fix Git ownership issue for the repository directory
184-
git config --global --add safe.directory /go/src/repo
185150
git config --global --add safe.directory ${PROJECT_ROOT}
186151
187152
# Use the generated `.ko.yaml`
@@ -236,6 +201,7 @@ spec:
236201
# Rewrite "devel" to params.versionTag
237202
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${OUTPUT_RELEASE_DIR}/release.yaml
238203
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${OUTPUT_RELEASE_DIR}/release.notags.yaml
204+
239205
- name: koparse
240206
image: ghcr.io/tektoncd/plumbing/koparse@sha256:1898ef549aaff602d06c049136aaf1c1eacc573846c42bbf42d8dc9258235204
241207
script: |

tekton/release-pipeline.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
description: The user for the image registry credentials
2424
default: _json_key
2525
- name: versionTag
26-
description: Version tag (X.Y.Z for stable, vYYYYMMDD-abc1234 for nightly)
26+
description: Version tag (vX.Y.Z for stable, vYYYYMMDD-abc1234 for nightly)
2727
- name: releaseBucket
2828
description: bucket where the release is stored. The bucket must be project specific.
2929
default: "gs://tekton-releases-nightly/pipeline" # Will be overridden based on releaseMode
@@ -94,8 +94,6 @@ spec:
9494
params:
9595
- name: url
9696
value: https://github.com/tektoncd/plumbing
97-
- name: org
98-
value: tektoncd
9997
- name: revision
10098
value: main
10199
- name: pathInRepo
@@ -115,9 +113,7 @@ spec:
115113
- name: unit-tests
116114
runAfter: [precheck]
117115
when:
118-
- input: "$(params.runTests)"
119-
operator: in
120-
values: ["true"]
116+
- cel: "'$(params.runTests)' == 'true'"
121117
taskRef:
122118
resolver: bundles
123119
params:
@@ -142,9 +138,7 @@ spec:
142138
- name: build
143139
runAfter: [precheck]
144140
when:
145-
- input: "$(params.runTests)"
146-
operator: in
147-
values: ["true"]
141+
- cel: "'$(params.runTests)' == 'true'"
148142
taskRef:
149143
resolver: bundles
150144
params:
@@ -167,7 +161,16 @@ spec:
167161
- name: publish-images
168162
runAfter: [unit-tests, build]
169163
taskRef:
170-
name: publish-release
164+
resolver: git
165+
params:
166+
- name: repo
167+
value: pipeline
168+
- name: org
169+
value: tektoncd
170+
- name: revision
171+
value: $(params.gitRevision)
172+
- name: pathInRepo
173+
value: tekton/publish.yaml
171174
params:
172175
- name: package
173176
value: $(params.package)
@@ -279,6 +282,7 @@ spec:
279282
value: $(params.versionTag)
280283
script: |
281284
BASE_URL=$(echo "${RELEASE_BUCKET}/previous/${VERSION_TAG}")
285+
# If the bucket is in the gs:// return the corresponding public https URL
282286
BASE_URL=$(echo ${BASE_URL} | sed 's,gs://,https://storage.googleapis.com/,g')
283287
echo "${BASE_URL}/release.yaml" > $(results.release.path)
284288
echo "${BASE_URL}/release.notag.yaml" > $(results.release-no-tag.path)

0 commit comments

Comments
 (0)