maxim-lobanov / setup-xcode

Set up your GitHub Actions workflow with a specific version of Xcode
MIT License
280 stars 28 forks source link

Use `.xcode-version` file #47

Open acevif opened 1 year ago

acevif commented 1 year ago

I am using fastlane and chxcode, and they read Xcode's version from the .xcode-version file.

How about making this action read version from the file?

If it comes true, the '.xcode-version' file becomes SSOT, Single Source of Truth for the version of Xcode. I think it could become a part of the best practice for iOS engineers.

Thanks.

maxim-lobanov commented 1 year ago

Hi 👋 , One possible problem that I see here is different syntax format.

This action uses semver notation. Fastlane docs describes the different notation (Gem::Version notation I guess?). For example:

it can cause confusion and different selected Xcode. Correct me if I am wrong.

bobergj commented 1 year ago

@maxim-lobanov:

Fastlane docs describes the different notation ([Gem::Version notation (https://www.rubydoc.info/github/rubygems/rubygems/Gem/Version) I guess?).

I believe the idea of the .xcode-version file comes from the (now defunct) fastlane ci project: https://github.com/fastlane/ci/blob/master/docs/xcode-version.md, and in the examples there only a plain version number string is allowed, not any match syntax such as ~> 8.1.0.

Also https://github.com/klaaspieter/chxcode, mentioned above, just matches on a plain string as far as I can see.

To alleviate this confusion, we could even add a (proposed) canonical description of the .xcode-version file format to this repo. Especially so since is https://github.com/fastlane/ci/blob/master/docs/xcode-version.md is archived.

8.1 will be resolved to 8.1.0 by fastlane and as 8.1.* (for example 8.1.2 as latest available) in this action

I think we could see this as a bug in fastlane, and that setup-xcode is doing the right thing. Edit: we could also have setup-xcode output a warning to the github action log in this case.

Related, there's also use of a .swift-version file in the community, for example by SwiftFormat: https://github.com/nicklockwood/SwiftFormat/blob/master/README.md#swift-version It could be interesting to make setup-xcode select an Xcode version based on .swift-version if .xcode-version isn't present.

mplorentz commented 1 year ago

FYI if you want to get this feature right now you can use @bobergj's fork. Replace

       - uses: maxim-lobanov/setup-xcode@v1
         with:
           xcode-version: 14.3

with

- uses: nomasystems/action-xcode-select@v0.1

in your Github Actions workflow yaml.