|
1 | 1 | # select-xcode |
2 | | -GitHub action to select Xcode via 1. explicit input 2. .xcode-version file 3. env var |
| 2 | + |
| 3 | +A GitHub Actions composite action that selects a specific Xcode version on macOS runners via `xcode-select`. |
| 4 | + |
| 5 | +## Version resolution order |
| 6 | + |
| 7 | +The action resolves the Xcode version using the following priority: |
| 8 | + |
| 9 | +1. **`xcode-version` input** — explicit version passed to the action |
| 10 | +2. **`.xcode-version` file** — a file at the root of the repository containing the version string |
| 11 | +3. **`XCODE_VERSION` environment variable** — a variable already set in the workflow environment |
| 12 | + |
| 13 | +If none of the above provides a version, the action fails with a descriptive error message. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +### With an explicit version input |
| 18 | + |
| 19 | +```yaml |
| 20 | +- uses: LucaTools/select-xcode@main |
| 21 | + with: |
| 22 | + xcode-version: "26.2" |
| 23 | +``` |
| 24 | +
|
| 25 | +### With a `.xcode-version` file |
| 26 | + |
| 27 | +Commit a `.xcode-version` file to the root of your repository: |
| 28 | + |
| 29 | +``` |
| 30 | +26.2 |
| 31 | +``` |
| 32 | + |
| 33 | +Then use the action without any input: |
| 34 | + |
| 35 | +```yaml |
| 36 | +- uses: LucaTools/select-xcode@main |
| 37 | +``` |
| 38 | + |
| 39 | +### With a pre-set environment variable |
| 40 | + |
| 41 | +```yaml |
| 42 | +env: |
| 43 | + XCODE_VERSION: "26.2" |
| 44 | +
|
| 45 | +steps: |
| 46 | + - uses: LucaTools/select-xcode@main |
| 47 | +``` |
| 48 | + |
| 49 | +## Inputs |
| 50 | + |
| 51 | +| Name | Required | Default | Description | |
| 52 | +|-----------------|----------|---------|---------------------------------| |
| 53 | +| `xcode-version` | No | `""` | The version of Xcode to select. | |
| 54 | + |
| 55 | +## Full workflow example |
| 56 | + |
| 57 | +```yaml |
| 58 | +name: CI |
| 59 | +
|
| 60 | +on: |
| 61 | + push: |
| 62 | + branches: [main] |
| 63 | +
|
| 64 | +jobs: |
| 65 | + build: |
| 66 | + runs-on: macos-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | +
|
| 70 | + - uses: LucaTools/select-xcode@main |
| 71 | + with: |
| 72 | + xcode-version: "26.2" |
| 73 | +
|
| 74 | + - name: Build |
| 75 | + run: xcodebuild build -scheme MyApp |
| 76 | +``` |
| 77 | + |
| 78 | +## Requirements |
| 79 | + |
| 80 | +- Must run on a macOS runner (e.g. `macos-latest`, `macos-26`). |
| 81 | +- The requested Xcode version must be available at `/Applications/Xcode_<version>.app`. |
| 82 | + |
| 83 | +## License |
| 84 | + |
| 85 | +[MIT](LICENSE) |
0 commit comments