Skip to content

Commit 2b65746

Browse files
committed
add makefile rule
Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
1 parent e0fe8ed commit 2b65746

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,9 @@ gosec:
288288
# Run this command to install gosec, if not installed:
289289
# go install github.com/securego/gosec/v2/cmd/gosec@v2.14.0
290290
gosec -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir pkg/test -exclude-dir tests ./...
291+
292+
### Release
293+
# RUN: make release new-version=x.x.x
294+
.PHONY:
295+
release:
296+
sh make-release.sh ${new-version}

make-release.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ usage ()
2424

2525
if [[ $# -lt 1 ]]; then usage; fi
2626
SCHEMA_VERSION=$1
27+
FIRST_DIGIT="${SCHEMA_VERSION%%.*}"
28+
RELEASE_BRANCH="release-v${FIRST_DIGIT}"
2729

2830
if ! command -v hub > /dev/null; then
2931
echo "[ERROR] The hub CLI needs to be installed. See https://github.com/github/hub/releases"
@@ -70,21 +72,21 @@ updateVersionNumbers() {
7072
SHORT_UNAME=$(uname -s)
7173

7274
## Updating version.md based off of operating system
73-
if [ "$(uname)" == "Darwin" ]; then
74-
sed -i '' "s/^.*$/$SCHEMA_VERSION/" VERSION
75-
elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then
76-
sed -i "s/^.*$/$SCHEMA_VERSION/" VERSION
77-
fi
75+
if [ "$(uname)" == "Darwin" ]; then
76+
sed -i '' "s/^.*$/$SCHEMA_VERSION/" VERSION
77+
elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then
78+
sed -i "s/^.*$/$SCHEMA_VERSION/" VERSION
79+
fi
7880

7981
## Remaining version number updates to yaml files
80-
yq eval ".metadata.annotations.containerImage = \"quay.io/devfile/registry-operator:$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml
82+
yq eval ".metadata.annotations.containerImage = \"quay.io/devfile/registry-operator:v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml
8183
yq eval ".metadata.name = \"registry-operator.v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml
8284
yq eval ".spec.version = \"$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml
8385
}
8486

8587
exportEnvironmentVariables() {
8688
CHANNEL=$(yq eval '.annotations."operators.operatorframework.io.bundle.channels.v1"' ./bundle/metadata/annotations.yaml)
87-
export IMG=quay.io/devfile/registry-operator:$SCHEMA_VERSION
89+
export IMG=quay.io/devfile/registry-operator:v$SCHEMA_VERSION
8890
export CHANNELS=$CHANNEL
8991

9092
}
@@ -95,13 +97,28 @@ commitChanges() {
9597
git commit -s -m "$1"
9698
git push origin $SCHEMA_VERSION
9799
}
100+
101+
# Creates a new branch in the registry-operator repo for a new major release
102+
# with the name release-vX
103+
## This func will be used when we have a new major release and there is no branch in the upstream repo
104+
createNewReleaseBranch(){
105+
git checkout -b "${RELEASE_BRANCH}"
106+
git push origin "${RELEASE_BRANCH}"
107+
hub sync
108+
}
109+
110+
createPullRequest(){
111+
echo "[INFO] Creating a PR"
112+
hub pull-request --base ${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1"
113+
}
98114

99115
main(){
100116
checkoutToReleaseBranch
101117
updateVersionNumbers
102118
exportEnvironmentVariables
103119
make bundle
104120
commitChanges "chore(release): release version ${SCHEMA_VERSION}"
121+
createPullRequest "v${SCHEMA_VERSION} Release"
105122
}
106123

107124
main

0 commit comments

Comments
 (0)