Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions .github/workflows/auto_update_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,38 @@ jobs:
git checkout -b $UPDATE_BRANCH $RELEASE_BRANCH

- name: Update PrintVersion.swift
id: update_version
run: |
FILE=Sources/swift-format/PrintVersion.swift

if grep -q "print(\"$VERSION\")" "$FILE"; then
echo "Version already $VERSION; skipping update."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi

sed -i "s/print(\".*\")/print(\"$VERSION\")/" "$FILE"
echo "changed=true" >> "$GITHUB_OUTPUT"

- name: Update automerge.yml
run: |
FILE=.github/workflows/automerge.yml

if grep -q "base_branch: $RELEASE_BRANCH" "$FILE"; then
echo "Branch already $RELEASE_BRANCH; skipping update."
exit 0
fi

sed -i "s/base_branch: .*/base_branch: $RELEASE_BRANCH/" "$FILE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since $RELEASE_BRANCH contains a slash (e.g. release/**), I think we should switch the delimiter to | to avoid conflicts.

Suggested change
sed -i "s/base_branch: .*/base_branch: $RELEASE_BRANCH/" "$FILE"
sed -i "s|base_branch:.*|base_branch: $RELEASE_BRANCH|" "$FILE"


- name: Checking for changes
id: change_check
run: |
if git diff --exit-code; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Commit and push changes
if: steps.update_version.outputs.changed == 'true'
if: steps.change_check.outputs.changed == 'true'
run: |
git config user.name "swift-ci"
git config user.email "[email protected]"
Expand All @@ -67,7 +84,7 @@ jobs:
git push origin $UPDATE_BRANCH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I explicitly added only PrintVersion.swift, so we should change this 🫣


- name: Create Pull Request
if: steps.update_version.outputs.changed == 'true'
if: steps.change_check.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
Expand Down