README.md
1# Generation 2 3## Using scripts independently 4 5Most of the scripts in this directory can be used independently to do file updates across all modules. 6They are also used and tested by `merge_repository.sh`. 7 8## Merge repository into the monorepo 9 10Built by running [merge_repository.sh](merge_repository.sh). 11 12The script creates a new Git repository in `monorepo/google-cloud-java` by merging 13the repositories in the input. 14After running the script locally, you can `cd` into the generated repository and build the project. 15 16```shell 17cd monorepo/google-cloud-java 18mvn test -T C1 -B 19``` 20 21### Input 22 23The file `repos.txt` lists all the split repos to include in the aggregation into the monorepo. 24 25### Output 26 27See: [bootstrap_output](https://github.com/googleapis/google-cloud-java/tree/bootstrap_output) branch. 28 29### Diffs 30 31The workflow also generates a diff between the current `main` branch and the generated aggregation of modules from split repos. 32See: `boostrap_outout_diff_{event}` branches. 33
readme_update.sh
1#!/bin/bash 2# This script should run as a part of new-library generation process. 3# This script introduces release-please annotations if they don't exist in the readme file 4 5for module in $(find . -mindepth 2 -maxdepth 2 -name pom.xml | sort | xargs dirname); do 6 7 if [[ "${module}" = *java-core ]] || [[ "${module}" = *java-shared-dependencies ]]; then 8 continue 9 fi 10 11 readme_file="${module}/README.md" 12 13 if [ -e ${readme_file} ] && ! [[ $(grep "x-version-update-start" ${readme_file}) ]]; then 14 15 artifactId_line=$(grep --max-count=1 'artifactId' "${readme_file}") 16 17 prefix=" <artifactId>" 18 suffix="</artifactId>" 19 string=${artifactId_line} 20 new_string=${string#"$prefix"} 21 artifactId=${new_string%"$suffix"} 22 23 echo "Handling ${artifactId}" 24 25 line_number=$(grep -n -m 1 "<dependency>" ${readme_file} | sed 's/\([0-9]*\).*/\1/') 26 start_line=${line_number}-2 27 line_number_end=$(grep -n -m 1 "Scala" ${readme_file} | sed 's/\([0-9]*\).*/\1/') 28 end_line=${line_number_end}+4 29 30 start_line_append="<!-- {x-version-update-start:${artifactId}:released} -->" 31 32 printf '%s\n' H ${start_line}i "${start_line_append}" . w | ed -s ${readme_file} 33 printf '%s\n' H ${end_line}i "<!-- {x-version-update-end} -->" . w | ed -s ${readme_file} 34 35 fi 36 37done 38