Update Spring Dependencies #1253
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #1. Get `SPRING_BOOT_VERSION` from [spring-boot-dependencies tags](https://github.com/spring-projects/spring-boot/tags). Get `SPRING_CLOUD_VERSION` from [spring-cloud-dependencies tags](https://github.com/spring-cloud/spring-cloud-release/tags). Note that spring-cloud version should compatible with spring-boot version. Refs: [Spring Cloud Release train Spring Boot compatibility](https://spring.io/projects/spring-cloud). | |
| #2. Run command `python .\sdk\spring\scripts\get_spring_boot_managed_external_dependencies.py -b ${SPRING_BOOT_VERSION} -c ${SPRING_CLOUD_VERSION}`. Then a file named `spring_boot_SPRING_BOOT_VERSION_managed_external_dependencies.txt` will be created in `.\sdk\spring\scripts`. | |
| #3. Run command `python .\sdk\spring\scripts\sync_external_dependencies.py -b ${SPRING_BOOT_VERSION} -sbmvn 3`. Then versions in `\eng\versioning\external_dependencies.txt` will be synchronized with `spring_boot_${SPRING_BOOT_VERSION}_managed_external_dependencies.txt`. | |
| #4. Run command `python .\eng\versioning\update_versions.py --sr` | |
| #5. Run command: `python .\sdk\spring\scripts\update_changelog.py -b ${SPRING_BOOT_VERSION} -c ${SPRING_CLOUD_VERSION}` to update changelog about Spring Boot and Spring Cloud dependencies versions in `/sdk/spring/CHANGELOG.md`. | |
| #6. When generate `spring_boot_${SPRING_BOOT_VERSION}_managed_external_dependencies.txt` file, delete the old version file. | |
| name: Update Spring Dependencies | |
| on: | |
| schedule: | |
| # * is a special character in YAML so you have to quote this string | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| repository: 'Azure/spring-cloud-azure-tools' | |
| - name: Generate Version File | |
| run: | | |
| mvn compile | |
| mvn exec:java -P github-actions -ntp -Dupdate-spring-dependencies=true | |
| - name: Confirm Whether to Update | |
| run: | | |
| if [[ ! -f 'spring-versions.txt' ]]; then | |
| echo "No new Spring Boot version, No updates!" | |
| elif grep -q - 'spring-versions.txt'; then | |
| echo "Has non-GA version, cancel update!" | |
| else | |
| echo "need_update_version=true" >> $GITHUB_ENV | |
| echo "spring_boot_version=$(sed -n '1p' spring-versions.txt)" >> $GITHUB_ENV | |
| echo "spring_cloud_version=$(sed -n '2p' spring-versions.txt)" >> $GITHUB_ENV | |
| echo "last_spring_boot_version=$(sed -n '3p' spring-versions.txt)" >> $GITHUB_ENV | |
| echo "last_spring_cloud_version=$(sed -n '4p' spring-versions.txt)" >> $GITHUB_ENV | |
| echo "pr_descriptions=$(cat pr-descriptions.txt)" >> $GITHUB_ENV | |
| echo "PR_TITLE=External dependencies upgrade - Spring Boot $(sed -n '1p' spring-versions.txt) and Spring Cloud $(sed -n '2p' spring-versions.txt)" >> $GITHUB_ENV | |
| fi | |
| - uses: actions/checkout@v3 | |
| if: ${{ env.need_update_version == 'true' }} | |
| with: | |
| repository: 'Azure/azure-sdk-for-java' | |
| path: 'azure-sdk-for-java' | |
| ref: main | |
| token: ${{ secrets.ACCESS_TOKEN }} | |
| fetch-depth: 1 | |
| - name: Generate spring_boot_managed_external_dependencies.txt | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| echo Updating Spring Boot Dependencies Version: ${{ env.spring_boot_version }} | |
| echo Updating Spring Cloud Dependencies Version: ${{ env.spring_cloud_version }} | |
| cd azure-sdk-for-java | |
| git checkout -b update-spring-dependencies | |
| pip install termcolor | |
| python ./sdk/spring/scripts/get_spring_boot_managed_external_dependencies.py -b ${{ env.spring_boot_version }} -c ${{ env.spring_cloud_version }} | |
| - name: Update external_dependencies.txt | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| cd azure-sdk-for-java | |
| pip install termcolor | |
| pip install in_place | |
| python ./sdk/spring/scripts/sync_external_dependencies.py -b ${{ env.spring_boot_version }} -sbmvn 4 | |
| - name: Update Versions | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| cd azure-sdk-for-java | |
| python ./eng/versioning/update_versions.py --sr | |
| - name: Update ChangeLog | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| cd azure-sdk-for-java | |
| python ./sdk/spring/scripts/update_changelog.py -b ${{ env.spring_boot_version }} -c ${{ env.spring_cloud_version }} | |
| - name: Close Old Pull Requests | |
| if: ${{ env.need_update_version == 'true' }} | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.ACCESS_TOKEN }} | |
| script: | | |
| const prTitle = process.env.PR_TITLE; | |
| const { data: pullRequests } = await github.rest.pulls.list({ | |
| owner: 'Azure', | |
| repo: 'azure-sdk-for-java', | |
| state: 'open' | |
| }); | |
| const oldPRs = pullRequests.filter(pr => pr.title === prTitle); | |
| for (const pr of oldPRs) { | |
| console.log(`Closing PR #${pr.number} with comment`); | |
| await github.rest.issues.createComment({ | |
| owner: 'Azure', | |
| repo: 'azure-sdk-for-java', | |
| issue_number: pr.number, | |
| body: 'This PR has been superseded by a newer update. Closing automatically.' | |
| }); | |
| await github.rest.pulls.update({ | |
| owner: 'Azure', | |
| repo: 'azure-sdk-for-java', | |
| pull_number: pr.number, | |
| state: 'closed' | |
| }); | |
| } | |
| - name: Push Commit | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| cd azure-sdk-for-java | |
| git config --global user.email github-actions@github.com | |
| git config --global user.name github-actions | |
| git rm ./sdk/spring/scripts/spring_boot_${{ env.last_spring_boot_version }}_managed_external_dependencies.txt | |
| git add -A | |
| git commit -m "Upgrade external dependencies to align with Spring Boot ${{ env.spring_boot_version }}" | |
| git push --force "https://${{ secrets.USER }}:${{ secrets.ACCESS_TOKEN }}@github.com/${{ secrets.USER }}/azure-sdk-for-java.git" | |
| - name: Create Pull Request | |
| if: ${{ env.need_update_version == 'true' }} | |
| uses: vsoch/pull-request-action@master | |
| env: | |
| PULL_REQUEST_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
| PULL_REQUEST_REPOSITORY: Azure/azure-sdk-for-java | |
| PULL_REQUEST_TITLE: "${{ env.PR_TITLE }}" | |
| PULL_REQUEST_FROM_BRANCH: "${{ secrets.USER }}:update-spring-dependencies" | |
| PULL_REQUEST_BRANCH: "main" | |
| PULL_REQUEST_BODY: "Updates external dependencies to align with Spring Boot version [${{ env.spring_boot_version }}](https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/${{ env.spring_boot_version }}/spring-boot-dependencies-${{ env.spring_boot_version }}.pom) from [${{ env.last_spring_boot_version }}](https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/${{ env.last_spring_boot_version }}/spring-boot-dependencies-${{ env.last_spring_boot_version }}.pom) and Spring Cloud version [${{ env.spring_cloud_version }}](https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/${{ env.spring_cloud_version }}/spring-cloud-dependencies-${{ env.spring_cloud_version }}.pom) from [${{ env.last_spring_cloud_version }}](https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/${{ env.last_spring_cloud_version }}/spring-cloud-dependencies-${{ env.last_spring_cloud_version }}.pom).\n${{ env.pr_descriptions }}\n\nThis PR is created by GitHub Actions: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" | |
| PULL_REQUEST_DRAFT: true |