Skip to content
Open
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
24 changes: 18 additions & 6 deletions .github/workflows/auto_update_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,38 @@ jobs:
run: |
git checkout -b $UPDATE_BRANCH $RELEASE_BRANCH

- name: Update PrintVersion.swift
- name: Update version and dependencies
id: update_version
run: |
FILE=Sources/swift-format/PrintVersion.swift
CHANGED=false

if grep -q "print(\"$VERSION\")" "$FILE"; then
echo "Version already $VERSION; skipping update."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
else
sed -i "s/print(\".*\")/print(\"$VERSION\")/" "$FILE"
CHANGED=true
fi

if grep -q "branch: \"$RELEASE_BRANCH\"" Package.swift; then
echo "swift-syntax branch already $RELEASE_BRANCH; skipping update."
else
sed -i '/swift-syntax\.git/s|branch: ".*"|branch: "'"$RELEASE_BRANCH"'"|' Package.swift
CHANGED=true
fi

sed -i "s/print(\".*\")/print(\"$VERSION\")/" "$FILE"
echo "changed=true" >> "$GITHUB_OUTPUT"
if [ "$CHANGED" = "true" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

- name: Commit and push changes
if: steps.update_version.outputs.changed == 'true'
run: |
git config user.name "swift-ci"
git config user.email "swift-ci@users.noreply.github.com"
git add Sources/swift-format/PrintVersion.swift
git add -A
git commit -m "Update version to $VERSION"
git push origin $UPDATE_BRANCH

Expand Down