diff --git a/bin/update-split-repo.sh b/bin/delete-samples-split-repo.sh similarity index 96% rename from bin/update-split-repo.sh rename to bin/delete-samples-split-repo.sh index b7bfea8a9c0..bf972f34baa 100755 --- a/bin/update-split-repo.sh +++ b/bin/delete-samples-split-repo.sh @@ -31,7 +31,7 @@ git clone "git@github.com:googleapis/${SPLIT_REPO}.git" "/tmp/${SPLIT_REPO}" cd "/tmp/${SPLIT_REPO}" -git checkout -b 'removeOwlBotAndUpdateREADME' +git checkout -b 'deleteMostOfLibrary' shopt -s extglob @@ -72,7 +72,7 @@ echo -e "'**_THIS REPOSITORY IS DEPRECATED. ALL OF ITS CONTENT AND HISTORY HAS B git add . git commit -m 'build: update README for deprecation notice and delete all files except samples' -git push -f --set-upstream origin removeOwlBotAndUpdateREADME +git push -f --set-upstream origin deleteMostOfLibrary # create pull request if gh --help > /dev/null diff --git a/bin/migrate-split-repo.sh b/bin/migrate-split-repo.sh index ff41007991b..ae5ca6d8cd4 100755 --- a/bin/migrate-split-repo.sh +++ b/bin/migrate-split-repo.sh @@ -42,5 +42,6 @@ ${SCRIPT_DIR}/migrate-git-history.sh \ ".kokoro,.github,.trampolinerc,SECURITY.md,renovate.json,samples" \ ".github/.OwlBot.yaml,samples/quickstart.js,samples/test/quickstart.js,samples/test/quickstart.test.js,system-test/test/quickstart.test.js,system-test/test/quickstart.js,samples/README.md,samples/package.json,samples/generated" -# run the script to update the split repo -${SCRIPT_DIR}/update-split-repo.sh ${SPLIT_REPO} ${ARTIFACT_NAME} +# run the script to update the split repo and either delete all the samples or just update the README +${SCRIPT_DIR}/delete-samples-split-repo.sh ${SPLIT_REPO} ${ARTIFACT_NAME} +${SCRIPT_DIR}/update-readme-only-split-repo.sh ${SPLIT_REPO} ${ARTIFACT_NAME} diff --git a/bin/update-readme-only-split-repo.sh b/bin/update-readme-only-split-repo.sh new file mode 100755 index 00000000000..b4167133314 --- /dev/null +++ b/bin/update-readme-only-split-repo.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +if [ $# -lt 2 ] +then + echo "Usage: $0 " + exit 1 +fi + +# repo name (e.g. nodejs-asset) +SPLIT_REPO=$1 +# destination directory (e.g. google-cloud-asset) +ARTIFACT_NAME=$2 + +rm -rf "/tmp/${SPLIT_REPO}" +git clone "git@github.com:googleapis/${SPLIT_REPO}.git" "/tmp/${SPLIT_REPO}" + +cd "/tmp/${SPLIT_REPO}" + +git checkout -b 'removeOwlBotAndUpdateREADME' + +shopt -s extglob + +OWLBOT_PY="/tmp/${SPLIT_REPO}/owlbot.py" +# Delete owlbot.yaml +rm -rf "$OWLBOT_PY" + +IGNORE_README_TXT="# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an \"AS IS\" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import synthtool.languages.node as node + +node.owlbot_main(templates_excludes=[ +README.md' +])" + +echo "$IGNORE_README_TXT" >> "$OWLBOT_PY" + +# Update the README +README_MD="/tmp/${SPLIT_REPO}/README.md" + +echo -e "'**_THIS REPOSITORY IS DEPRECATED. ALL OF ITS CONTENT AND HISTORY HAS BEEN MOVED TO [GOOGLE-CLOUD-NODE](https://github.com/googleapis/google-cloud-node/tree/main/packages/${ARTIFACT_NAME})_**'\n$(cat $README_MD)" > "$README_MD" + +git add . +git commit -m 'build: update README for deprecation notice and delete all files except samples' + +git push -f --set-upstream origin removeOwlBotAndUpdateREADME + +# create pull request +if gh --help > /dev/null +then + gh pr create --title "build: update README for deprecation notice" +else + hub pull-request -m "build: update README for deprecation notice" +fi + +rm -rf "/tmp/${SPLIT_REPO}" \ No newline at end of file