|
| 1 | +name: Get latest smithy gradle plugin version |
| 2 | +on: |
| 3 | + workflow_dispatch: # on button click |
| 4 | + # Uncomment once permissions to create PRs has been added. |
| 5 | + schedule: |
| 6 | + # Runs every wednesday at 11 |
| 7 | + - cron: '0 11 * * WED' |
| 8 | + |
| 9 | +jobs: |
| 10 | + get-version: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Fetch latest smithy-gradle-plugin version |
| 16 | + id: fetch-latest |
| 17 | + run: | |
| 18 | + echo "latestSmithyGradle=$( \ |
| 19 | + curl -sL https://api.github.com/repos/smithy-lang/smithy-gradle-plugin/tags | \ |
| 20 | + jq -r '.[0].name')" >> $GITHUB_OUTPUT |
| 21 | + - name: Get current version |
| 22 | + id: get-current |
| 23 | + run: | |
| 24 | + cat gradle.properties >> $GITHUB_OUTPUT |
| 25 | + - name: Check if the current version of smithy-gradle-plugin should be updated |
| 26 | + id: update-check |
| 27 | + run: | |
| 28 | + echo update-required=$( \ |
| 29 | + [ "${{ steps.get-current.outputs.smithyGradleVersion }}" = "${{ steps.fetch-latest.outputs.latestSmithyGradle }}" ] \ |
| 30 | + && echo "false" || echo "true") >> $GITHUB_OUTPUT |
| 31 | + - name: Set up new git branch for version bump |
| 32 | + id: git-setup |
| 33 | + if: steps.update-check.outputs.update-required == 'true' |
| 34 | + run: | |
| 35 | + git checkout -b "automation/bump-smithy-gradle-version/${{ steps.fetch-latest.outputs.latestSmithyGradle }}" |
| 36 | + git config --global user.email "[email protected]" |
| 37 | + git config --global user.name "Smithy Automation" |
| 38 | + - name: Find and replace gradle version in properties files |
| 39 | + id: replace-current-version-properties |
| 40 | + if: steps.update-check.outputs.update-required == 'true' |
| 41 | + run: | |
| 42 | + find . -type f -name 'gradle.properties' \ |
| 43 | + -exec sed -i "s|smithyGradleVersion=${{ steps.get-current.outputs.smithyGradleVersion }}|smithyGradleVersion=${{ steps.fetch-latest.outputs.latestSmithyGradle }}|g" {} \; |
| 44 | + - name: Create PR |
| 45 | + if: steps.update-check.outputs.update-required == 'true' |
| 46 | + run: | |
| 47 | + git add . |
| 48 | + git commit -m 'Update smithy-gradle-plugin Version' |
| 49 | + git push --set-upstream origin "automation/bump-smithy-gradle-version/${{ steps.fetch-latest.outputs.latestSmithyGradle }}" |
| 50 | + gh pr create \ |
| 51 | + --title "[Automation] smithy-gradle-plugin Version Bump - \`${{ steps.fetch-latest.outputs.latestSmithyGradle }}\`" \ |
| 52 | + --body "Automated pull request to bump smithy gradle plugin version from ${{ steps.get-current.outputs.smithyGradleVersion }} to ${{ steps.fetch-latest.outputs.latestSmithyGradle }}" \ |
| 53 | + --base main |
| 54 | + echo "PR Created for version bump to ${{ steps.fetch-latest.outputs.latestSmithyGradle }}" |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} |
0 commit comments