Skip to content

[6.2] Check version has been updated when publishing a release #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
echo "swift_format_version=$SWIFT_FORMAT_VERSION" >> "$GITHUB_OUTPUT"
- name: Checkout repository
uses: actions/checkout@v4
- name: Check version matches
run: |
grep '"${{ steps.swift_format_version.outputs.swift_format_version }}"' Sources/swift-format/PrintVersion.swift
Copy link
Member

@TTOzzi TTOzzi Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also take into account the prerelease format, such as "602.0.0-prerelease-$(date +'%Y-%m-%d')" 🤔
Or, to avoid being affected by prerelease variations, it might be better to use github.event.inputs.swift_format_version instead of steps.swift_format_version.outputs.swift_format_version.

- name: Create release commits
id: create_release_commits
run: |
Expand All @@ -81,10 +84,6 @@ jobs:
git add Package.swift
git commit -m "Change swift-syntax dependency to ${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}"

sed -E -i "s#print\(\".*\"\)#print\(\"${{ steps.swift_format_version.outputs.swift_format_version }}\"\)#" Sources/swift-format/PrintVersion.swift
git add Sources/swift-format/PrintVersion.swift
git commit -m "Change version to ${{ steps.swift_format_version.outputs.swift_format_version }}"

{
echo 'release_commit_patch<<EOF'
git format-patch "$BASE_COMMIT"..HEAD --stdout
Expand Down
2 changes: 1 addition & 1 deletion Sources/swift-format/PrintVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

func printVersionInformation() {
// TODO: Automate updates to this somehow.
print("main")
print("6.2.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more appropriate if it were in the form of "602.0.0"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, this is an interesting point. We really have two versions here - one is swift-format as a library, using the same semantic versioning as swift-syntax. Another is swift-format in the toolchain, which uses the toolchain versioning scheme.

Which also means the check I added here doesn't work 🤔

}