-
Notifications
You must be signed in to change notification settings - Fork 6
68 lines (60 loc) · 3.18 KB
/
update-smithy-gradle-plugin-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Get latest smithy gradle plugin version
on:
workflow_dispatch: # on button click
# Uncomment once permissions to create PRs has been added.
schedule:
# Runs every wednesday at 11
- cron: '0 11 * * WED'
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Fetch latest smithy-gradle-plugin version
id: fetch-latest
run: |
echo "latestSmithyGradle=$( \
curl -sL https://plugins.gradle.org/m2/software/amazon/smithy/smithy-gradle-plugin/maven-metadata.xml | \
grep latest | cut -d'>' -f2 | cut -d'<' -f1)" >> $GITHUB_OUTPUT
- name: Get current version
id: get-current
run: |
cat gradle.properties >> $GITHUB_OUTPUT
- name: Check if the current version of smithy-gradle-plugin should be updated
id: update-check
run: |
echo update-required=$( \
[ "${{ steps.get-current.outputs.smithyGradleVersion }}" = "${{ steps.fetch-latest.outputs.latestSmithyGradle }}" ] \
&& echo "false" || echo "true") >> $GITHUB_OUTPUT
- name: Set up new git branch for version bump
id: git-setup
if: steps.update-check.outputs.update-required == 'true'
run: |
git checkout -b "automation/bump-smithy-gradle-version/${{ steps.fetch-latest.outputs.latestSmithyGradle }}"
git config --global user.email "[email protected]"
git config --global user.name "Smithy Automation"
- name: Find and replace gradle version in properties files
id: replace-current-version-properties
if: steps.update-check.outputs.update-required == 'true'
run: |
find . -type f -name 'gradle.properties' \
-exec sed -i "s|smithyGradleVersion=${{ steps.get-current.outputs.smithyGradleVersion }}|smithyGradleVersion=${{ steps.fetch-latest.outputs.latestSmithyGradle }}|g" {} \;
- name: Find and replace gradle plugin versions in build files
id: sync-plugin-version
if: steps.update-check.outputs.update-required == 'true'
run: |
find . -type f -name 'build.gradle.kts' \
-exec sed -i '' "s/\(id(\"software\.amazon\.smithy\.gradle\.smithy-\([[:lower:]]*\)\")\.version(\"\)\([[:digit:]\.]*\)\")/\\1${{ steps.fetch-latest.outputs.latestSmithyGradle }}\")/" {} \;
- name: Create PR
if: steps.update-check.outputs.update-required == 'true'
run: |
git add .
git commit -m 'Update smithy-gradle Version'
git push --set-upstream origin "automation/bump-smithy-gradle-version/${{ steps.fetch-latest.outputs.latestSmithyGradle }}"
gh pr create \
--title "[Automation] smithy-gradle-plugin Version Bump - \`${{ steps.fetch-latest.outputs.latestSmithyGradle }}\`" \
--body "Automated pull request to bump smithy-gradle-plugin version from ${{ steps.get-current.outputs.smithyGradleVersion }} to ${{ steps.fetch-latest.outputs.latestSmithyGradle }}" \
--base main
echo "PR Created for version bump to ${{ steps.fetch-latest.outputs.latestSmithyGradle }}"
env:
GITHUB_TOKEN: ${{ secrets.PR_TOKEN }}