Get latest smithy release version #91
This file contains 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
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@v4 | |
- name: Fetch latest smithy version | |
id: fetch-latest | |
run: | | |
echo "latestSmithy=$( \ | |
curl -sL https://api.github.com/repos/smithy-lang/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 "[email protected]" | |
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" {} \; | |
find . -type f -name 'smithy-build.json' \ | |
-exec sed -i "s|:${{ steps.get-current.outputs.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 }} |