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

Prepare for release #11

Merged
merged 6 commits into from
Dec 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: task-maven
version: 0.0.1
version: 0.1.0
description: todo
type: application
43 changes: 33 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ E2E_MAVEN_PARAMS_SERVER_SECRET ?= secret-maven
# generic arguments employed on most of the targets
ARGS ?=

# external task dependency to run the end-to-end tests pipeline
TASK_GIT ?= https://github.com/openshift-pipelines/task-git/releases/download/0.0.1/task-git-0.0.1.yaml

# installs "git" task directly from the informed location, the task is required to run the test-e2e
# target, it will hold the "source" workspace data
.PHONY: task-git
task-git:
kubectl apply -f $(TASK_GIT)

# making sure the variables declared in the Makefile are exported to the excutables/scripts invoked
# on all targets
.EXPORT_ALL_VARIABLES:
Expand All @@ -39,10 +30,42 @@ endef
# renders the task resource file printing it out on the standard output
helm-template:
$(call render-template)

# renders and installs the resources (task)
install:
$(call render-template) |kubectl $(ARGS) apply -f -

# pepare a release
.PHONY: prepare-release
prepare-release:
mkdir -p $(RELEASE_DIR) || true
hack/release.sh $(RELEASE_DIR)

.PHONY: release
release: prepare-release
pushd ${RELEASE_DIR} && \
go run github.com/openshift-pipelines/tektoncd-catalog/cmd/catalog-cd@main \
release \
--output release \
--version $(CHART_VERSION) \
tasks/* \
; \
popd

# tags the repository with the RELEASE_VERSION and pushes to "origin"
git-tag-release-version:
if ! git rev-list "${RELEASE_VERSION}".. >/dev/null; then \
git tag "$(RELEASE_VERSION)" && \
git push origin --tags; \
fi

# github-release
.PHONY: github-release
github-release: git-tag-release-version release
gh release create $(RELEASE_VERSION) --generate-notes && \
gh release upload $(RELEASE_VERSION) $(RELEASE_DIR)/release/catalog.yaml && \
gh release upload $(RELEASE_VERSION) $(RELEASE_DIR)/release/resources.tar.gz

# packages the helm-chart as a single tarball, using it's name and version to compose the file
helm-package: clean
helm package $(ARGS) .
Expand All @@ -58,7 +81,7 @@ bats: install
$(BATS_CORE) $(BATS_FLAGS) $(ARGS) $(E2E_TESTS)

.PHONY: prepare-e2e
prepare-e2e: task-git
prepare-e2e:
kubectl apply -f ${E2E_PVC}

# run end-to-end tests against the current kuberentes context, it will required a cluster with tekton
Expand Down
3 changes: 2 additions & 1 deletion hack/install-osp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ metadata:
namespace: openshift-marketplace
spec:
sourceType: grpc
image: quay.io/openshift-pipeline/openshift-pipelines-operator-index:1.10
# image: quay.io/openshift-pipeline/openshift-pipelines-operator-index:5.0
image: quay.io/openshift-pipeline/openshift-pipelines-pipelines-operator-bundle-container-index:v4.14-candidate
displayName: "Custom OSP Nightly"
updateStrategy:
registryPoll:
Expand Down
66 changes: 66 additions & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
#
# Renders and copies documentation files into the informed RELEASE_DIR, the script search for
# task templates on a specific glob expression. The templates are rendered using the actual
# task name and documentation is searched for and copied over to the task release directory.
#

shopt -s inherit_errexit
set -eu -o pipefail

readonly RELEASE_DIR="${1:-}"

# Print error message and exit non-successfully.
panic() {
echo "# ERROR: ${*}"
exit 1
}

# Extracts the filename only, without path or extension.
extract_name() {
declare filename=$(basename -- "${1}")
declare extension="${filename##*.}"
echo "${filename%.*}"
}

# Finds the respective documentation for the task name, however, for s2i it only consider the
# "task-s2i" part instead of the whole name.
find_doc() {
declare task_name="${1}"
[[ "${task_name}" == "task-s2i"* ]] &&
task_name="task-s2i"
find docs/ -name "${task_name}*.md"
}

#
# Main
#

release() {
# making sure the release directory exists, this script should only create releative
# directories using it as root
[[ ! -d "${RELEASE_DIR}" ]] &&
panic "Release dir is not found '${RELEASE_DIR}'!"

# releasing task-git (it's the only task)
# See task-containers if there is more than one task to support.
declare task_name=task-maven
declare task_doc=README.md
declare task_dir="${RELEASE_DIR}/tasks/${task_name}"
[[ ! -d "${task_dir}" ]] &&
mkdir -p "${task_dir}"

# rendering the helm template for the specific file, using the resource name for the
# filename respectively
echo "# Rendering '${task_name}' at '${task_dir}'..."
helm template . >${task_dir}/${task_name}.yaml ||
panic "Unable to render '${task_name}'!"

# finds the respective documentation file copying as "README.md", on the same
# directory where the respective task is located
echo "# Copying '${task_name}' documentation file '${task_doc}'..."
cp -v -f ${task_doc} "${task_dir}/README.md" ||
panic "Unable to copy '${task_doc}' into '${task_dir}'"
}

release
9 changes: 8 additions & 1 deletion test/e2e/resources/pipeline-maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ spec:
tasks:
- name: git
taskRef:
name: git
resolver: git
params:
- name: url
value: https://github.com/openshift-pipelines/tektoncd-catalog
- name: revision
value: p
- name: pathInRepo
value: tasks/task-git/0.2.0/task-git.yaml
workspaces:
- name: output
workspace: source
Expand Down
4 changes: 2 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
images:
minimal: registry.access.redhat.com/ubi8/ubi-minimal:8.2
minimal: registry.access.redhat.com/ubi8/ubi-minimal:8.9
maven: registry.access.redhat.com/ubi8/openjdk-11:latest

annotations:
tekton.dev/pipelines.minVersion: "0.38.0"
tekton.dev/pipelines.minVersion: "0.41.0"
tekton.dev/categories: containers
tekton.dev/tags: containers
Loading