Add repo tag support for GitHub 70/66570/3
authorJessica Wagantall <jwagantall@linuxfoundation.org>
Wed, 20 Jan 2021 22:54:19 +0000 (14:54 -0800)
committerJessica Wagantall <jwagantall@linuxfoundation.org>
Thu, 21 Jan 2021 21:58:52 +0000 (13:58 -0800)
Rename "tag-gerrit-repo" to "tag-git-repo" in
preparation to support self releases for Github
based projects.

Issue: RELENG-3368
Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
Change-Id: I6ceb6675a2f37cbfd1d008046aecb734665db6d3

releasenotes/notes/generatlize-tag-function-self-release-10be50b5d7e741cd.yaml [new file with mode: 0644]
shell/release-job.sh

diff --git a/releasenotes/notes/generatlize-tag-function-self-release-10be50b5d7e741cd.yaml b/releasenotes/notes/generatlize-tag-function-self-release-10be50b5d7e741cd.yaml
new file mode 100644 (file)
index 0000000..b1789b2
--- /dev/null
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Rename "tag-gerrit-repo" function in self releases to "tag-git-repo".
+    This change is in preparation for self releases support for GitHub based
+    projects. Use the name "git-repo" to fit both Gerrit and Github projects.
index eba269b..7ac6fc5 100644 (file)
@@ -146,7 +146,7 @@ set_variables_container(){
     printf "\t%-30s %s\n" CONTAINER_RELEASE_TAG: "$VERSION"
     printf "\t%-30s %s\n" CONTAINER_PULL_REGISTRY: "$CONTAINER_PULL_REGISTRY"
     printf "\t%-30s %s\n" CONTAINER_PUSH_REGISTRY: "$CONTAINER_PUSH_REGISTRY"
-    printf "\t%-30s %s\n" GERRIT_REF_TO_TAG: "$ref"
+    printf "\t%-30s %s\n" GIT_REF_TO_TAG: "$ref"
     printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
 }
 
@@ -209,7 +209,7 @@ set_variables_packagecloud(){
      printf "\t%-30s %s\n" PACKAGE_NAME: "$PACKAGE_NAME"
      printf "\t%-30s %s\n" LOG_DIR: "$LOG_DIR"
      printf "\t%-30s %s\n" LOGS_URL: "$logs_url"
-     printf "\t%-30s %s\n" GERRIT_REF_TO_TAG: "$REF"
+     printf "\t%-30s %s\n" GIT_REF_TO_TAG: "$REF"
      printf "\t%-30s %s\n" VERSION: "$VERSION"
      printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
 }
@@ -285,13 +285,19 @@ verify_packagecloud_match_release(){
 
 # sigul is only available on Centos
 # TODO: write tag-github-repo function
-tag-gerrit-repo(){
+tag-git-repo(){
     if [[ $TAG_RELEASE == false ]]; then
-       echo "INFO: Skipping gerrit repo tag"
+       echo "INFO: Skipping code repo tag"
        return
     fi
 
-    echo "INFO: tag gerrit with $GIT_TAG"
+    if [[ -z ${GERRIT_URL:-} ]]; then
+        GIT_REPO_BASE=github
+    else
+        GIT_REPO_BASE=gerrit
+    fi
+
+    echo "INFO: tag repo with $GIT_TAG"
     # Import public signing key
     gpg --import "$SIGNING_PUBKEY"
     if type=$(git cat-file -t "$GIT_TAG"); then
@@ -312,12 +318,16 @@ tag-gerrit-repo(){
         ########## Merge Part ##############
         if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
             echo "INFO: Running merge, pushing tag"
-            gerrit_ssh=$(echo "$GERRIT_URL" | awk -F"/" '{print $3}')
-            git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/"$PROJECT"
+            if [[ $GIT_REPO_BASE == "gerrit" ]]; then
+                gerrit_ssh=$(echo "$GERRIT_URL" | awk -F"/" '{print $3}')
+                git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/"$PROJECT"
+                echo -e "Host $gerrit_ssh\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
+                chmod 600 ~/.ssh/config
+            else
+                git remote set-url origin "$GIT_CLONE_URL""$RELEASE_USERNAME"/"$PROJECT".git
+            fi
             git config user.name "$RELEASE_USERNAME"
             git config user.email "$RELEASE_EMAIL"
-            echo -e "Host $gerrit_ssh\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
-            chmod 600 ~/.ssh/config
             git push origin "$GIT_TAG"
         fi
     fi
@@ -386,7 +396,7 @@ container_release_file(){
 
     echo "INFO: Merge will tag ref: $ref"
     git checkout "$ref"
-    tag-gerrit-repo
+    tag-git-repo
 }
 
 maven_release_file(){
@@ -403,7 +413,7 @@ maven_release_file(){
     git fetch "$PATCH_DIR/${PROJECT//\//-}.bundle"
     git merge --ff-only FETCH_HEAD
     nexus_release
-    tag-gerrit-repo
+    tag-git-repo
 }
 
 # calls pip to download binary and source distributions from the specified index,
@@ -448,7 +458,7 @@ pypi_release_file(){
         echo "INFO: uploading $filecount distributions to repo $REPOSITORY"
         $cmd
     fi
-    tag-gerrit-repo
+    tag-git-repo
 }
 
 packagecloud_verify(){
@@ -478,7 +488,7 @@ packagecloud_promote(){
         | echo "INFO: Promoted package location: \
         https://packagecloud.io$(yq -r .package_html_url)"
     git checkout "$REF"
-    tag-gerrit-repo
+    tag-git-repo
 }
 
 ##############################  End Function Declarations  ################################