67
67
echo "swift_format_version=$SWIFT_FORMAT_VERSION" >> "$GITHUB_OUTPUT"
68
68
- name : Checkout repository
69
69
uses : actions/checkout@v4
70
+ - name : Create version commit if version changed
71
+ run : |
72
+ # Without this, we can't perform git operations in GitHub actions.
73
+ git config --global --add safe.directory "$(realpath .)"
74
+ git config --local user.name 'swift-ci'
75
+ git config --local user.email '[email protected] '
76
+
77
+ BRANCH_NAME="${GITHUB_REF#refs/heads/}"
78
+
79
+ sed -E -i "s#print\(\".*\"\)#print\(\"${{ steps.swift_format_version.outputs.swift_format_version }}\"\)#" Sources/swift-format/PrintVersion.swift
80
+
81
+ if ! git diff --quiet Sources/swift-format/PrintVersion.swift; then
82
+ echo "Detected change in PrintVersion.swift — committing and pushing"
83
+ git add Sources/swift-format/PrintVersion.swift
84
+ git commit -m "Change version to ${{ steps.swift_format_version.outputs.swift_format_version }}"
85
+ git push origin HEAD:$BRANCH_NAME
86
+ else
87
+ echo "No changes in PrintVersion.swift — skipping commit/push"
88
+ fi
70
89
- name : Create release commits
71
90
id : create_release_commits
72
91
run : |
@@ -81,10 +100,6 @@ jobs:
81
100
git add Package.swift
82
101
git commit -m "Change swift-syntax dependency to ${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}"
83
102
84
- sed -E -i "s#print\(\".*\"\)#print\(\"${{ steps.swift_format_version.outputs.swift_format_version }}\"\)#" Sources/swift-format/PrintVersion.swift
85
- git add Sources/swift-format/PrintVersion.swift
86
- git commit -m "Change version to ${{ steps.swift_format_version.outputs.swift_format_version }}"
87
-
88
103
{
89
104
echo 'release_commit_patch<<EOF'
90
105
git format-patch "$BASE_COMMIT"..HEAD --stdout
0 commit comments