@@ -34,12 +34,12 @@ jobs:
34
34
echo "${{ github.triggering_actor }} is not allowed to create a release"
35
35
exit 1
36
36
fi
37
- define_tags :
38
- name : Determine dependent swift-syntax version and prerelease date
37
+ create_release_commits :
38
+ name : Create release commits
39
39
runs-on : ubuntu-latest
40
40
outputs :
41
- swift_syntax_tag : ${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}
42
41
swift_format_version : ${{ steps.swift_format_version.outputs.swift_format_version }}
42
+ release_commit_patch : ${{ steps.create_release_commits.outputs.release_commit_patch }}
43
43
steps :
44
44
- name : Determine swift-syntax tag to depend on
45
45
id : swift_syntax_tag
@@ -65,37 +65,81 @@ jobs:
65
65
fi
66
66
echo "Using swift-format version: $SWIFT_FORMAT_VERSION"
67
67
echo "swift_format_version=$SWIFT_FORMAT_VERSION" >> "$GITHUB_OUTPUT"
68
- test_debug :
69
- name : Test in Debug configuration
70
- uses : swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
71
- needs : define_tags
72
- with :
73
- pre_build_command : bash .github/workflows/create-release-commits.sh '${{ needs.define_tags.outputs.swift_syntax_tag }}' '${{ needs.define_tags.outputs.swift_format_version }}'
74
- # We require that releases of swift-format build without warnings
75
- build_command : swift test -Xswiftc -warnings-as-errors
76
- test_release :
77
- name : Test in Release configuration
68
+ - name : Checkout repository
69
+ uses : actions/checkout@v4
70
+ - name : Create release commits
71
+ id : create_release_commits
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
+ BASE_COMMIT=$(git rev-parse HEAD)
79
+
80
+ sed -E -i "s#branch: \"(main|release/[0-9]+\.[0-9]+)\"#from: \"${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}\"#" Package.swift
81
+ git add Package.swift
82
+ git commit -m "Change swift-syntax dependency to ${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}"
83
+
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
+ {
89
+ echo 'release_commit_patch<<EOF'
90
+ git format-patch "$BASE_COMMIT"..HEAD --stdout
91
+ echo EOF
92
+ } >> "$GITHUB_OUTPUT"
93
+ test :
94
+ name : Test in ${{ matrix.release && 'Release' || 'Debug' }} configuration
78
95
uses : swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
79
- needs : define_tags
96
+ needs : create_release_commits
97
+ strategy :
98
+ fail-fast : false
99
+ matrix :
100
+ release : [true, false]
80
101
with :
81
- pre_build_command : bash .github/workflows/create-release-commits.sh '${{ needs.define_tags.outputs.swift_syntax_tag }}' '${{ needs.define_tags.outputs.swift_format_version }}'
102
+ enable_windows_docker : false # Dockerless Windows is 5-10 minutes faster than Docker on Windows
103
+ linux_pre_build_command : |
104
+ git config --global --add safe.directory "$(realpath .)"
105
+ git config --local user.name 'swift-ci'
106
+ git config --local user.email '[email protected] '
107
+ git am << EOF
108
+ ${{ needs.create_release_commits.outputs.release_commit_patch }}
109
+ EOF
110
+ windows_pre_build_command : |
111
+ git config --local user.name "swift-ci"
112
+ git config --local user.email "[email protected] "
113
+ echo @"
114
+ ${{ needs.create_release_commits.outputs.release_commit_patch }}
115
+ "@ > $env:TEMP\patch.diff
116
+ # For some reason `git am` fails in Powershell with the following error. Executing it in cmd works...
117
+ # fatal: empty ident name (for <>) not allowed
118
+ cmd /c "type $env:TEMP\patch.diff | git am || (exit /b 1)"
82
119
# We require that releases of swift-format build without warnings
83
- build_command : swift test -c release -Xswiftc -warnings-as-errors
120
+ linux_build_command : swift test -Xswiftc -warnings-as-errors ${{ matrix.release && '-c release' || '' }}
121
+ windows_build_command : swift test -Xswiftc -warnings-as-errors ${{ matrix.release && '-c release' || '' }}
84
122
create_tag :
85
123
name : Create Tag
86
124
runs-on : ubuntu-latest
87
- needs : [check_triggering_actor, test_debug, test_release, define_tags ]
125
+ needs : [check_triggering_actor, test, create_release_commits ]
88
126
permissions :
89
127
contents : write
90
128
steps :
91
129
- name : Checkout repository
92
130
uses : actions/checkout@v4
93
- - name : Create release commits
94
- run : bash .github/workflows/create-release-commits.sh '${{ needs.define_tags.outputs.swift_syntax_tag }}' '${{ needs.define_tags.outputs.swift_format_version }}'
131
+ - name : Apply release commits
132
+ run : |
133
+ git config --global --add safe.directory "$(realpath .)"
134
+ git config --local user.name 'swift-ci'
135
+ git config --local user.email '[email protected] '
136
+ git am << EOF
137
+ ${{ needs.create_release_commits.outputs.release_commit_patch }}
138
+ EOF
95
139
- name : Tag release
96
140
run : |
97
- git tag "${{ needs.define_tags .outputs.swift_format_version }}"
98
- git push origin "${{ needs.define_tags .outputs.swift_format_version }}"
141
+ git tag "${{ needs.create_release_commits .outputs.swift_format_version }}"
142
+ git push origin "${{ needs.create_release_commits .outputs.swift_format_version }}"
99
143
- name : Create release
100
144
env :
101
145
GH_TOKEN : ${{ github.token }}
@@ -104,6 +148,6 @@ jobs:
104
148
# Only create a release automatically for prereleases. For real releases, release notes should be crafted by hand.
105
149
exit
106
150
fi
107
- gh release create "${{ needs.define_tags .outputs.swift_format_version }}" \
108
- --title "${{ needs.define_tags .outputs.swift_format_version }}" \
151
+ gh release create "${{ needs.create_release_commits .outputs.swift_format_version }}" \
152
+ --title "${{ needs.create_release_commits .outputs.swift_format_version }}" \
109
153
--prerelease
0 commit comments