2020# ./hack/release.sh v1.5.0 # bump, commit, tag, push
2121# ./hack/release.sh v1.5.0 --dry-run # show what would change
2222# ./hack/release.sh v1.5.0 --llm # generate changelog with gh copilot
23+ #
24+ # Environment variables:
25+ # SIGNING_KEY - Path to ECDSA private key for signing tasks (default: keys/signing-key.pem)
2326
2427set -euo pipefail
2528
@@ -30,6 +33,7 @@ ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
3033VERSION=" "
3134DRY_RUN=false
3235USE_LLM=false
36+ SIGNING_KEY=" ${SIGNING_KEY:- ${ROOT_DIR} / keys/ signing-key.pem} "
3337
3438for arg in " $@ " ; do
3539 case " ${arg} " in
@@ -46,6 +50,20 @@ if [[ -z "${VERSION}" ]]; then
4650 exit 1
4751fi
4852
53+ # Check signing key
54+ if [[ ! -f " ${SIGNING_KEY} " ]]; then
55+ echo " Error: signing key not found at ${SIGNING_KEY} "
56+ echo " Set SIGNING_KEY env var or place key at keys/signing-key.pem"
57+ echo " Generate with: openssl ecparam -genkey -name prime256v1 -noout -out keys/signing-key.pem"
58+ exit 1
59+ fi
60+
61+ # Check tkn CLI
62+ if ! command -v tkn & > /dev/null; then
63+ echo " Error: tkn CLI not found. Install from https://tekton.dev/docs/cli/"
64+ exit 1
65+ fi
66+
4967# Validate version format
5068if ! echo " ${VERSION} " | grep -qE ' ^v[0-9]+\.[0-9]+\.[0-9]+$' ; then
5169 echo " Error: version must match vX.Y.Z (got: ${VERSION} )"
@@ -57,6 +75,12 @@ BARE_VERSION="${VERSION#v}"
5775
5876cd " ${ROOT_DIR} "
5977
78+ # --- Task files to sign ---
79+ TASK_FILES=(
80+ " task/git-clone/git-clone.yaml"
81+ " stepaction/git-clone/git-clone.yaml"
82+ )
83+
6084# --- Detect current version ---
6185CURRENT_VERSION=$( grep ' app.kubernetes.io/version' task/git-clone/git-clone.yaml | head -1 | sed ' s/.*"\(.*\)"/\1/' )
6286CURRENT_TAG=" v${CURRENT_VERSION} "
@@ -122,7 +146,6 @@ Output the two sections separated by the exact string ---SEPARATOR--- on its own
122146 LLM_OUTPUT=$( gh copilot -p " ${PROMPT} " 2> /dev/null || echo " " )
123147
124148 if [[ -n " ${LLM_OUTPUT} " ]]; then
125- # Extract the two sections, stripping any preamble before the YAML
126149 AH_CHANGES=$( echo " ${LLM_OUTPUT} " | sed -n ' /^ *- kind:/,/---SEPARATOR---/p' | grep -v ' ^---SEPARATOR---' )
127150 TAG_MESSAGE=$( echo " ${LLM_OUTPUT} " | sed -n ' /^---SEPARATOR---$/,$ p' | tail -n +2 | sed ' /^$/d; /^[[:space:]]*$/d' | sed ' 1{/^$/d}' )
128151 else
@@ -159,14 +182,11 @@ echo "--- Tag message:"
159182echo " ${TAG_MESSAGE} "
160183echo " "
161184
162- # --- Files to update ---
163- FILES=(
164- " task/git-clone/git-clone.yaml"
165- " README.md"
166- )
185+ # --- All files to update ---
186+ ALL_FILES=(" ${TASK_FILES[@]} " " README.md" )
167187
168188echo " --- Version bumps:"
169- for f in " ${FILES [@]} " ; do
189+ for f in " ${ALL_FILES [@]} " ; do
170190 echo " ${f} "
171191done
172192echo " "
@@ -183,11 +203,13 @@ apply_version_bumps() {
183203
184204# --- Helper: update artifacthub changelog in content (stdin → stdout) ---
185205apply_ah_changes () {
206+ local normalized
207+ normalized=$( echo -e " ${AH_CHANGES} " | grep -v ' ^[[:space:]]*\`\`\`' | sed -e ' s/^[[:space:]]*- kind:/ - kind:/' -e ' s/^[[:space:]]*description:/ description:/' )
186208 python3 -c "
187209import re, sys
188210content = sys.stdin.read()
189211new_changes = ''' artifacthub.io/changes: |
190- $( echo -e " ${AH_CHANGES} " ) '''
212+ ${normalized} '''
191213content = re.sub(
192214 r' artifacthub\.io/changes: \|\n( .*\n)*',
193215 new_changes.rstrip() + '\n',
@@ -200,10 +222,10 @@ sys.stdout.write(content)
200222if [[ " ${DRY_RUN} " == true ]]; then
201223 echo " --- Dry run: showing changes ---"
202224
203- for f in " ${FILES [@]} " ; do
225+ for f in " ${ALL_FILES [@]} " ; do
204226 echo " "
205227 echo " === ${f} ==="
206- if [[ " ${f} " == * " git-clone .yaml" ]]; then
228+ if [[ " ${f} " == * " .yaml" ]]; then
207229 apply_version_bumps " ${f} " | apply_ah_changes | diff -u " ${f} " - || true
208230 else
209231 apply_version_bumps " ${f} " | diff -u " ${f} " - || true
217239# --- Apply version bumps ---
218240echo " --- Applying version bumps..."
219241
220- for f in " ${FILES [@]} " ; do
221- if [[ " ${f} " == * " git-clone .yaml" ]]; then
242+ for f in " ${ALL_FILES [@]} " ; do
243+ if [[ " ${f} " == * " .yaml" ]]; then
222244 apply_version_bumps " ${f} " | apply_ah_changes > " ${f} .tmp" && mv " ${f} .tmp" " ${f} "
223245 else
224246 apply_version_bumps " ${f} " > " ${f} .tmp" && mv " ${f} .tmp" " ${f} "
@@ -228,8 +250,15 @@ done
228250echo " --- Regenerating StepAction..."
229251./hack/generate-stepaction.sh
230252
253+ # --- Sign task YAMLs ---
254+ echo " --- Signing task YAMLs with ${SIGNING_KEY} ..."
255+ for f in " ${TASK_FILES[@]} " ; do
256+ echo " Signing ${f} "
257+ tkn task sign " ${f} " -K=" ${SIGNING_KEY} " -f=" ${f} "
258+ done
259+
231260echo " --- Committing..."
232- git add task/git-clone/git-clone.yaml README.md stepaction/git-clone/git-clone.yaml
261+ git add " ${ALL_FILES[@]} "
233262git commit --signoff --message " chore: bump version to ${VERSION} "
234263
235264echo " --- Pushing to main..."
0 commit comments