1name: New Client 2on: 3 schedule: 4 - cron: '0 2 * * *' # nightly at 2 am UTC 5 push: 6 branches: [ main ] 7 paths: 8 - generation/** 9 pull_request: 10 branches: [ main ] 11 paths: 12 - generation/** 13 14 workflow_dispatch: 15 16jobs: 17 generate: 18 runs-on: ubuntu-latest 19 env: 20 API_SHORT_NAME: apikeys 21 API_PRETTY_NAME: API Keys 22 steps: 23 - uses: actions/checkout@v3 24 - uses: actions/setup-python@v4 25 with: 26 python-version: '3.9' 27 cache: 'pip' # caching pip dependencies 28 - name: Get current week within the year 29 id: date 30 run: echo "::set-output name=week_of_year::$(date +'%W' --utc)" 31 - uses: actions/setup-java@v3 32 with: 33 distribution: zulu 34 java-version: 11 35 - run: java -version 36 - uses: actions/cache@v3 37 id: mvn-cache 38 with: 39 path: ~/.m2/repository 40 key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.week_of_year }} 41 - name: Install dependencies 42 run: pip install --require-hashes -r generation/new_client/requirements.txt 43 - name: Remove Client 44 run: | 45 rm -rf java-${API_SHORT_NAME} || true 46 sed -i "/${API_SHORT_NAME}/d" pom.xml 47 sed -i "/${API_SHORT_NAME}/d" gapic-libraries-bom/pom.xml 48 - name: Verify Client Removal 49 run: | 50 ! test -d java-${API_SHORT_NAME} 51 ! grep -q ${API_SHORT_NAME} pom.xml 52 ! grep -q ${API_SHORT_NAME} gapic-libraries-bom/pom.xml 53 - name: Generate 54 run: | 55 python generation/new_client/new-client.py generate \ 56 --api_shortname=${API_SHORT_NAME} \ 57 --proto-path=google/api/${API_SHORT_NAME} \ 58 --name-pretty="${API_PRETTY_NAME}" \ 59 --product-docs="https://github.com/googleapis/google-cloud-java/tree/main/java-${API_SHORT_NAME}" \ 60 --api-description="${API_PRETTY_NAME} Client lets you use ${API_PRETTY_NAME} API." \ 61 --googleapis-gen-url=https://yoshi-approver:${{ secrets.YOSHI_APPROVER_PRIVATE_TOKEN }}@github.com/googleapis/googleapis-gen.git 62 - name: Push to branch (helpful for troubleshooting) 63 run: | 64 [ -z "`git config user.email`" ] && git config --global user.email "${USERNAME:-script}@google.com" 65 [ -z "`git config user.name`" ] && git config --global user.name "${USERNAME:-script}" 66 git checkout -b newclient_output_${{ github.event_name }} 67 git add --all 68 git commit -m 'feat: re-generated ${API_SHORT_NAME}' 69 git remote add monorepo https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git 70 git fetch -q --unshallow monorepo 71 git push -f monorepo newclient_output_${{ github.event_name }} 72 - name: Verify Client Creation 73 run: | 74 test -d java-${API_SHORT_NAME} 75 grep -q ${API_SHORT_NAME} pom.xml 76 grep -q ${API_SHORT_NAME} gapic-libraries-bom/pom.xml 77 - name: Test 78 run: mvn -B -ntp test -T C1 79