Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: extracts task preparation logic to its own script #944

Merged
merged 2 commits into from Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -434,9 +434,9 @@ TEKTON_TASK_VERSION:=$(shell echo "${OPERATOR_VERSION}" | cut -d'.' -f 1,2)

.PHONY: tekton-deploy
tekton-deploy: ## Deploy the Tekton tasks
sed -e "s/released-image/${IKE_IMAGE}/g" -e "s/current-version/${TEKTON_TASK_VERSION}/g" "$(PROJECT_DIR)/integration/tekton/tasks/ike-create/ike-create.yaml" | $(k8s) apply -f - -n $(TEST_NAMESPACE)
sed -e "s/released-image/${IKE_IMAGE}/g" -e "s/current-version/${TEKTON_TASK_VERSION}/g" "$(PROJECT_DIR)/integration/tekton/tasks/ike-session-url/ike-session-url.yaml" | $(k8s) apply -f - -n $(TEST_NAMESPACE)
sed -e "s/released-image/${IKE_IMAGE}/g" -e "s/current-version/${TEKTON_TASK_VERSION}/g" "$(PROJECT_DIR)/integration/tekton/tasks/ike-delete/ike-delete.yaml" | $(k8s) apply -f - -n $(TEST_NAMESPACE)
./scripts/release/tektonhub/prepare_task.sh replace_placeholders "$(PROJECT_DIR)/integration/tekton/tasks/ike-create/ike-create.yaml" "${TEKTON_TASK_VERSION}" "${IKE_IMAGE}" | $(k8s) apply -f - -n $(TEST_NAMESPACE)
./scripts/release/tektonhub/prepare_task.sh replace_placeholders "$(PROJECT_DIR)/integration/tekton/tasks/ike-session-url/ike-session-url.yaml" "${TEKTON_TASK_VERSION}" "${IKE_IMAGE}" | $(k8s) apply -f - -n $(TEST_NAMESPACE)
./scripts/release/tektonhub/prepare_task.sh replace_placeholders "$(PROJECT_DIR)/integration/tekton/tasks/ike-delete/ike-delete.yaml" "${TEKTON_TASK_VERSION}" "${IKE_IMAGE}" | $(k8s) apply -f - -n $(TEST_NAMESPACE)

.PHONY: tekton-undeploy
tekton-undeploy: ## UnDeploy the Tekton tasks
Expand Down
20 changes: 20 additions & 0 deletions scripts/release/tektonhub/prepare_task.sh
@@ -0,0 +1,20 @@
#!/bin/bash

set -euo pipefail

function replace_placeholders() {
local path=$1
local taskVersion=$2
local image=$3
local cmd=( "sed" )

if [ -n "${4:-}" ]; then
cmd+=( -i )
fi
cmd+=( -e "s/released-image/${image}/g" -e "s/current-version/${taskVersion}/g" "${path}")
"${cmd[@]}"
}

case ${1-noop} in
replace_placeholders) "$@"; exit;;
esac
8 changes: 5 additions & 3 deletions scripts/release/tektonhub/publish.sh
Expand Up @@ -53,6 +53,8 @@ CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
PROJECT_DIR="$(git rev-parse --show-toplevel)"
TASKS_DIR="${PROJECT_DIR}"/integration/tekton/tasks/

source "${CUR_DIR}"/prepare_task.sh

GITHUB_TOKEN="${GITHUB_TOKEN:-}"
GIT_USER="${GIT_USER:-alien-ike}"

Expand All @@ -64,7 +66,8 @@ FORK="${FORK:-maistra}"
FORK_REPO="${FORK_REPO:-catalog}"
FORK_REPO_URL="${FORK_REPO_URL:-https://${GIT_USER}:${GITHUB_TOKEN}@github.com/${FORK}/${FORK_REPO}.git}"

OPERATOR_VERSION=${OPERATOR_VERSION:-0.0.5} # should be provided by Makefile target
IKE_IMAGE=${IKE_IMAGE:-latest}
OPERATOR_VERSION=${OPERATOR_VERSION:-0.4.0} # should be provided by Makefile target
source "${CUR_DIR}"/../validate_semver.sh
validate_semantic_versioning "v${OPERATOR_VERSION}"

Expand Down Expand Up @@ -103,8 +106,7 @@ for taskName in "${TASKS_DIR}"/*; do
asciidoctor --require @asciidoctor/docbook-converter --require "${ADOC_INCLUDE}" -a leveloffset=+1 --backend docbook -o - "${PROJECT_DIR}"/docs/modules/ROOT/pages/integration/tekton/tasks/"${taskName}".adoc | pandoc --wrap=preserve --from docbook --to gfm >"${TMP_DIR}/${TEKTON_HUB_PATH}/${taskName}/${TEKTON_TASK_VERSION}"/README.md
popd

sed -i "s/released-image/${IKE_IMAGE}/g" "${TEKTON_HUB_PATH}/${taskName}/${TEKTON_TASK_VERSION}/${taskName}.yaml"
sed -i "s/current-version/${TEKTON_TASK_VERSION}/g" "${TEKTON_HUB_PATH}/${taskName}/${TEKTON_TASK_VERSION}/${taskName}.yaml"
replace_placeholders "${TEKTON_HUB_PATH}/${taskName}/${TEKTON_TASK_VERSION}/${taskName}.yaml" "${TEKTON_TASK_VERSION}" "${IKE_IMAGE}" "--in-place"
done

COMMIT_MESSAGE="${COMMIT_MESSAGE}
Expand Down