Skip to content

Commit

Permalink
Add workflow to automate PR for bumping Smithy (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
srchase committed Aug 31, 2023
1 parent 667b598 commit c7b6cb3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/update-smithy-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Get latest smithy release version
on:
workflow_dispatch: # on button click
schedule:
# Runs every wednesday at 10
- cron: '0 10 * * WED'

jobs:
get-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Fetch latest smithy version
id: fetch-latest
run: |
echo "latestSmithy=$( \
curl -sL https://api.github.com/repos/awslabs/smithy/releases/latest | \
jq -r '.tag_name')" >> $GITHUB_OUTPUT
- name: Get current versions
id: get-current
run: |
cat gradle.properties >> $GITHUB_OUTPUT
- name: Check if the current version of Smithy should be updated
id: update-check
run: |
echo update-required=$( \
[ "${{ steps.get-current.outputs.smithyVersion }}" = "${{ steps.fetch-latest.outputs.latestSmithy }}" ] \
&& 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-version/${{ steps.fetch-latest.outputs.latestSmithy }}"
git config --global user.email "github-aws-smithy-automation@amazon.com"
git config --global user.name "Smithy Automation"
- name: Find and replace
id: replace-current-version
if: steps.update-check.outputs.update-required == 'true'
run: |
find . -type f -name 'gradle.properties' \
-exec sed -i "s|smithyVersion=${{ steps.get-current.outputs.smithyVersion }}|smithyVersion=${{ steps.fetch-latest.outputs.latestSmithy }}|g" {} \;
- name: Create PR
if: steps.update-check.outputs.update-required == 'true'
run: |
git add .
git commit -m 'Update Smithy Version'
git push --set-upstream origin "automation/bump-smithy-version/${{ steps.fetch-latest.outputs.latestSmithy }}"
gh pr create \
--title "[Automation] Smithy Version Bump - \`${{ steps.fetch-latest.outputs.latestSmithy }}\`" \
--body "Automated pull request to bump Smithy version from ${{ steps.get-current.outputs.smithyVersion }} to ${{ steps.fetch-latest.outputs.latestSmithy }}" \
--base main
echo "PR Created for version bump to ${{ steps.fetch-latest.outputs.latestSmithy }}"
env:
GITHUB_TOKEN: ${{ secrets.PR_TOKEN }}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ publishing {

dependencies {
implementation "org.eclipse.lsp4j:org.eclipse.lsp4j:0.14.0"
implementation "software.amazon.smithy:smithy-build:[1.37.0, 2.0["
implementation "software.amazon.smithy:smithy-cli:[1.37.0, 2.0["
implementation "software.amazon.smithy:smithy-model:[1.37.0, 2.0["
implementation "software.amazon.smithy:smithy-build:[smithyVersion, 2.0["
implementation "software.amazon.smithy:smithy-cli:[smithyVersion, 2.0["
implementation "software.amazon.smithy:smithy-model:[smithyVersion, 2.0["
implementation 'com.disneystreaming.smithy:smithytranslate-formatter-jvm-java-api:0.3.10'

// Use JUnit test framework
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
smithyVersion=1.37.0

0 comments on commit c7b6cb3

Please sign in to comment.