@@ -26,6 +26,11 @@ if [[ $# -lt 1 ]]; then usage; fi
26
26
SCHEMA_VERSION=$1
27
27
FIRST_DIGIT=" ${SCHEMA_VERSION%% .* } "
28
28
RELEASE_BRANCH=" release-v${FIRST_DIGIT} "
29
+ DEVFILE_REPO=" git@github.com:devfile/registry-operator.git"
30
+ # # This will be uncommented for actual devfile repo
31
+ RELEASE_UPSTREAM_NAME=" devfile-upstream-release"
32
+ # This goes to my origin for testing
33
+ # RELEASE_UPSTREAM_NAME="origin"
29
34
30
35
if ! command -v hub > /dev/null; then
31
36
echo " [ERROR] The hub CLI needs to be installed. See https://github.com/github/hub/releases"
@@ -40,14 +45,23 @@ if ! [[ "$SCHEMA_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
40
45
exit 1
41
46
fi
42
47
48
+ # Sets the upstream to devfile repo to ensure that git commands are performed on the correct repo
49
+ # Ensures users who don't have an upstream set will be able to run script with no setup
50
+ setUpstream (){
51
+ if git remote -v | grep -q " $RELEASE_UPSTREAM_NAME [[:space:]]\+$DEVFILE_REPO " ; then
52
+ git remote rm ${RELEASE_UPSTREAM_NAME}
53
+ fi
54
+ git remote add ${RELEASE_UPSTREAM_NAME} " ${DEVFILE_REPO} "
55
+ }
56
+
43
57
44
58
# # Ensures local branch matches the remote
45
59
resetChanges () {
46
60
echo " [INFO] Reset changes in $1 branch"
47
61
git reset --hard
48
62
git checkout $1
49
- git fetch origin --prune
50
- git pull origin $1
63
+ git fetch ${RELEASE_UPSTREAM_NAME} --prune
64
+ git pull ${RELEASE_UPSTREAM_NAME} $1
51
65
}
52
66
53
67
# # Branch containing releases and tags in main upstream repo will be named 'release-vx' where 'vx' is the major release
@@ -84,13 +98,14 @@ updateVersionNumbers() {
84
98
yq eval " .spec.version = \" $SCHEMA_VERSION \" " --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml
85
99
}
86
100
101
+ # Export env variables that are used in bundle scripts
87
102
exportEnvironmentVariables () {
88
103
CHANNEL=$( yq eval ' .annotations."operators.operatorframework.io.bundle.channels.v1"' ./bundle/metadata/annotations.yaml)
89
104
export IMG=quay.io/devfile/registry-operator:v$SCHEMA_VERSION
90
105
export CHANNELS=$CHANNEL
91
-
92
106
}
93
107
108
+ # Commits version changes to your forked repository
94
109
commitChanges () {
95
110
echo " [INFO] Pushing changes to $SCHEMA_VERSION branch"
96
111
git add -A
@@ -102,14 +117,24 @@ commitChanges() {
102
117
# with the name release-vX
103
118
# # This func will be used when we have a new major release and there is no branch in the upstream repo
104
119
createNewReleaseBranch (){
105
- git checkout -b " ${RELEASE_BRANCH} " main
106
- git push origin " ${RELEASE_BRANCH} "
107
- # hub sync
120
+ git checkout -b " ${RELEASE_BRANCH} " " ${RELEASE_UPSTREAM_NAME} " /main
121
+ git push " ${RELEASE_UPSTREAM_NAME} " " ${RELEASE_BRANCH} "
122
+ # hub sync -- this supposedly will create that branch in upstream
123
+ }
124
+
125
+ verifyReleaseBranch () {
126
+ if git ls-remote --exit-code --heads ${RELEASE_UPSTREAM_NAME} " $RELEASE_BRANCH " > /dev/null 2>&1 ; then
127
+ echo " Branch $RELEASE_BRANCH exists in the upstream repository."
128
+ else
129
+ echo " Branch $RELEASE_BRANCH does not exist in the upstream repository."
130
+ # createNewReleaseBranch
131
+
132
+ fi
108
133
}
109
134
110
135
createPullRequest (){
111
136
echo " [INFO] Creating a PR"
112
- hub pull-request --base jdubrick :${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m " $1 "
137
+ hub pull-request --base ${RELEASE_UPSTREAM_NAME} :${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m " $1 "
113
138
}
114
139
115
140
main (){
@@ -120,12 +145,8 @@ main(){
120
145
# commitChanges "chore(release): release version ${SCHEMA_VERSION}"
121
146
# createPullRequest "v${SCHEMA_VERSION} Release"
122
147
# Check if the branch exists in the remote repository
123
- if git ls-remote --exit-code --heads origin " $RELEASE_BRANCH " > /dev/null 2>&1 ; then
124
- echo " Branch $RELEASE_BRANCH exists in the remote repository."
125
- else
126
- echo " Branch $RELEASE_BRANCH does not exist in the remote repository."
127
- createNewReleaseBranch
128
- fi
148
+ verifyReleaseBranch
149
+ # setUpstream -- LEAVE COMMENTED AS THIS WILL SET MY ORIGIN TO DEVFILE
129
150
}
130
151
131
152
main
0 commit comments