Skip to content

Commit

Permalink
build: add update split repo script to update the README and delete t…
Browse files Browse the repository at this point in the history
…he rest of the repo (#3377)

* build: add update split repo script to update the README and delete the rest of the repo

Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
sofisl and chingor13 authored Sep 30, 2022
1 parent 4104a21 commit 4b45779
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/migrate-split-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ ${SCRIPT_DIR}/migrate-git-history.sh \
"${PACKAGE_PATH}" \
".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}
85 changes: 85 additions & 0 deletions bin/update-split-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/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 <split-repo-name> <target-path>"
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

# Delete everything first that's not the samples, README.md, and git folder
rm -rf !("samples"|"README.md"|".git")
rm -rf "/tmp/${SPLIT_REPO}/.[!.git]*"
rm -rf "/tmp/${SPLIT_REPO}/.github"

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'
])"

OWLBOT_PY="/tmp/${SPLIT_REPO}/owlbot.py"

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 and delete all files except samples"
else
hub pull-request -m "build: update README for deprecation notice and delete all files except samples"
fi

rm -rf "/tmp/${SPLIT_REPO}"

0 comments on commit 4b45779

Please sign in to comment.