Skip to content

Commit 5223ccf

Browse files
committed
Add Release workflows
Signed-off-by: Pramod Bindal <[email protected]> Add Release workflows Add Release workflows Signed-off-by: Pramod Bindal <[email protected]> Signed-off-by: Pramod Bindal <[email protected]> change stepAction version to tekton.dev/v1beta1 Signed-off-by: Pramod Bindal <[email protected]>
1 parent 0e5f607 commit 5223ccf

File tree

5 files changed

+159
-2
lines changed

5 files changed

+159
-2
lines changed

.github/workflows/release.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: release
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Define the version you want to release'
9+
required: true
10+
default: '0.0.1'
11+
12+
jobs:
13+
release:
14+
permissions:
15+
contents: write
16+
packages: write
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: stable
23+
- name: github-release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: |
27+
make RELEASE_VERSION=v${{github.event.inputs.version}} github-release

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
SHELL := /usr/bin/env bash
12
E2E_TAG ?= e2e
3+
24
REGISTRY_NAME ?= registry
35

46
GOLANGCI_LINT=golangci-lint
57
TIMEOUT_UNIT = 20m
68
GOFUMPT=gofumpt
79

10+
BIN = $(CURDIR)/.bin
11+
# release directory where the Tekton resources are rendered into.
12+
RELEASE_VERSION=v0.1.1
13+
RELEASE_DIR ?= /tmp/tekton-caches-${RELEASE_VERSION}
14+
$(BIN):
15+
@mkdir -p $@
16+
CATALOGCD = $(or ${CATALOGCD_BIN},${CATALOGCD_BIN},$(BIN)/catalog-cd)
17+
$(BIN)/catalog-cd: $(BIN)
18+
curl -fsL https://github.com/openshift-pipelines/catalog-cd/releases/download/v0.3.0/catalog-cd_0.3.0_linux_x86_64.tar.gz | tar xzf - -C $(BIN) catalog-cd
19+
20+
21+
822
e2e-coverage: ## run e2e tests with coverage
923
tests/e2e.sh
1024
@go test -v -failfast -count=1 -tags=$(E2E_TAG) ./tests -coverpkg=./... -coverprofile /tmp/coverage.out
@@ -42,3 +56,34 @@ fumpt:
4256
help: ## print this help
4357
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
4458

59+
#Release
60+
# pepare a release
61+
.PHONY: prepare-release
62+
prepare-release:
63+
mkdir -p $(RELEASE_DIR) || true
64+
hack/release.sh $(RELEASE_DIR)
65+
66+
67+
.PHONY: release
68+
release: ${CATALOGCD} prepare-release
69+
pushd ${RELEASE_DIR} && \
70+
$(CATALOGCD) release \
71+
--output release \
72+
--version $(RELEASE_VERSION) \
73+
stepactions/* \
74+
; \
75+
popd
76+
77+
# tags the repository with the RELEASE_VERSION and pushes to "origin"
78+
git-tag-release-version:
79+
if ! git rev-list "${RELEASE_VERSION}".. >/dev/null; then \
80+
git tag "$(RELEASE_VERSION)" && \
81+
git push origin --tags; \
82+
fi
83+
84+
# github-release
85+
.PHONY: github-release
86+
github-release: git-tag-release-version release
87+
gh release create $(RELEASE_VERSION) --generate-notes && \
88+
gh release upload $(RELEASE_VERSION) $(RELEASE_DIR)/release/catalog.yaml && \
89+
gh release upload $(RELEASE_VERSION) $(RELEASE_DIR)/release/resources.tar.gz

hack/release.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Renders and copies documentation files into the informed RELEASE_DIR, the script search for
4+
# task templates on a specific glob expression. The templates are rendered using the actual
5+
# task name and documentation is searched for and copied over to the task release directory.
6+
#
7+
8+
shopt -s inherit_errexit
9+
set -eu -o pipefail
10+
11+
readonly RELEASE_DIR="${1:-}"
12+
13+
# Print error message and exit non-successfully.
14+
panic() {
15+
echo "# ERROR: ${*}"
16+
exit 1
17+
}
18+
19+
# Extracts the filename only, without path or extension.
20+
extract_name() {
21+
declare filename=$(basename -- "${1}")
22+
declare extension="${filename##*.}"
23+
echo "${filename%.*}"
24+
}
25+
26+
# Function to find the respective documentation for a given name, however, for s2i it only consider the
27+
## "task-s2i" part instead of the whole name.
28+
find_doc() {
29+
declare name="${1}"
30+
[[ "${name}" == "task-s2i"* ]] &&
31+
name="task-s2i"
32+
find docs/ -name "${name}*.md"
33+
}
34+
35+
#
36+
# Main
37+
#
38+
39+
release() {
40+
# making sure the release directory exists, this script should only create releative
41+
# directories using it as root
42+
[[ ! -d "${RELEASE_DIR}" ]] &&
43+
panic "Release dir is not found '${RELEASE_DIR}'!"
44+
45+
# Release task templates
46+
# release_templates "task" "templates/task-*.yaml" "tasks"
47+
48+
# Release StepAction templates
49+
release_templates "stepaction" "tekton/*.yaml" "stepactions"
50+
}
51+
52+
release_templates() {
53+
local template_type=$1
54+
local glob_expression=$2
55+
local release_subdir=$3
56+
57+
# releasing all templates using the following glob expression
58+
for t in $(ls -1 ${glob_expression}); do
59+
declare name=$(extract_name ${t})
60+
[[ -z "${name}" ]] &&
61+
panic "Unable to extract name from '${t}'!"
62+
63+
# local doc=$(find_doc ${name})
64+
# [[ -z "${doc}" ]] &&
65+
# panic "Unable to find documentation file for '${name}'!"
66+
67+
local dir="${RELEASE_DIR}/${release_subdir}/${name}"
68+
[[ ! -d "${dir}" ]] &&
69+
mkdir -p "${dir}"
70+
71+
# rendering the helm template for the specific file, using the resource name for the
72+
# filename respectively
73+
echo "# Rendering '${name}' at '${dir}'..."
74+
cp $t ${dir}/${name}.yaml ||
75+
panic "Unable to render '${t}'!"
76+
77+
# finds the respective documentation file copying as "README.md", on the same
78+
# directory where the respective task is located
79+
# echo "# Copying '${name}' documentation file '${doc}'..."
80+
# cp -v -f ${doc} "${dir}/README.md" ||
81+
# panic "Unable to copy '${doc}' into '${dir}'"
82+
done
83+
}
84+
85+
release

tekton/cache-fetch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: tekton.dev/v1alpha1
1+
apiVersion: tekton.dev/v1beta1
22
kind: StepAction
33
metadata:
44
name: cache-fetch

tekton/cache-upload.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: tekton.dev/v1alpha1
1+
apiVersion: tekton.dev/v1beta1
22
kind: StepAction
33
metadata:
44
name: cache-upload

0 commit comments

Comments
 (0)