@@ -67,24 +67,41 @@ jobs:
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 : |
73
92
# Without this, we can't perform git operations in GitHub actions.
74
93
git config --global --add safe.directory "$(realpath .)"
75
94
git config --local user.name 'swift-ci'
76
95
git config --local user.email '[email protected] '
77
-
96
+
97
+ BRANCH_NAME="${GITHUB_REF#refs/heads/}"
98
+ git pull origin "$BRANCH_NAME"
78
99
BASE_COMMIT=$(git rev-parse HEAD)
79
100
80
101
sed -E -i "s#branch: \"(main|release/[0-9]+\.[0-9]+)\"#from: \"${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}\"#" Package.swift
81
102
git add Package.swift
82
103
git commit -m "Change swift-syntax dependency to ${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}"
83
104
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
105
{
89
106
echo 'release_commit_patch<<EOF'
90
107
git format-patch "$BASE_COMMIT"..HEAD --stdout
0 commit comments