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