Skip to content

Commit 8d89617

Browse files
Implement "latest-stable" support (#5)
* add "latest-stable" keyword * rebuild app, update readme
1 parent e8ada21 commit 8d89617

File tree

7 files changed

+2503
-1288
lines changed

7 files changed

+2503
-1288
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010
runs-on: macos-latest
1111
strategy:
1212
matrix:
13-
xcode-version: [10.3, 11, 11.2, 11.4.0, 11.4.1, ^11.4.0, latest]
13+
xcode-version: [10.3, 11, 11.2, 11.4.0, 11.4.1, ^11.4.0, latest, latest-stable]
1414
fail-fast: false
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2
1818

19-
- name: setup-xcode
20-
uses: ./
19+
- uses: ./
2120
with:
2221
xcode-version: ${{ matrix.xcode-version }}

README.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,45 @@ The list of all available versions can be found in [virtual-environments](https:
66
# Available parameters
77
| Argument | Description | Format |
88
|-------------------------|--------------------------|--------------------|
9-
| `xcode-version` | Specify the Xcode version to use | `latest` keyword or any [semver](https://semver.org/) string |
9+
| `xcode-version` | Specify the Xcode version to use | `latest`, `latest-stable` or any [semver](https://semver.org/) string |
1010

11-
**Examples:** `latest`, `10`, `11.4`, `11.4.0`, `^11.4.0`
12-
13-
**Note:** `latest` *includes* beta releases that GitHub actions has installed.
11+
**Examples:** `latest`, `latest-stable`, `10`, `11.4`, `11.4.0`, `^11.4.0`
12+
**Note:**
13+
- `latest-stable` points to the latest stable version of Xcode
14+
- `latest` *includes* beta releases that GitHub actions has installed.
1415

1516
# Usage
17+
Set the latest stable Xcode version:
1618
```
17-
name: CI
18-
on: [push]
1919
jobs:
2020
build:
21-
name: Set
2221
runs-on: macos-latest
2322
steps:
24-
- name: setup-xcode
25-
uses: maxim-lobanov/setup-xcode@1.0
23+
- uses: maxim-lobanov/setup-xcode@1.1
2624
with:
27-
xcode-version: 11.4 # set the latest available Xcode 11.4.*
25+
xcode-version: latest-stable
26+
```
2827

29-
- name: setup-latest-xcode
30-
uses: maxim-lobanov/setup-xcode@1.0
28+
Set the latest Xcode version including beta releases:
29+
```
30+
jobs:
31+
build:
32+
runs-on: macos-latest
33+
steps:
34+
- uses: maxim-lobanov/setup-xcode@1.1
3135
with:
32-
xcode-version: latest # set the latest available Xcode 11.4.*
36+
xcode-version: latest
3337
```
3438

39+
Set the specific version of Xcode:
40+
```
41+
jobs:
42+
build:
43+
runs-on: macos-latest
44+
steps:
45+
- uses: maxim-lobanov/setup-xcode@1.1
46+
with:
47+
xcode-version: 11.4
48+
```
3549
# License
3650
The scripts and documentation in this project are released under the [MIT License](LICENSE)

__tests__/xcode-selector.test.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,26 @@ const fakeReadDirResults = [
2424
buildFsDirentItem("Xcode_11.4.app", { isSymbolicLink: true, isDirectory: false }),
2525
buildFsDirentItem("Xcode_11.4_beta.app", { isSymbolicLink: false, isDirectory: true }),
2626
buildFsDirentItem("Xcode_11.app", { isSymbolicLink: false, isDirectory: true }),
27+
buildFsDirentItem("Xcode_12_beta.app", { isSymbolicLink: false, isDirectory: true }),
2728
buildFsDirentItem("third_party_folder", { isSymbolicLink: false, isDirectory: true }),
2829
];
2930

3031
const fakeGetVersionsResult: XcodeVersion[] = [
31-
{ version: "11.4.0", path: "" },
32-
{ version: "11.2.1", path: "" },
33-
{ version: "11.2.0", path: "" },
34-
{ version: "11.0.0", path: "" },
35-
{ version: "10.3.0", path: "" }
32+
{ version: "12.0.0", path: "", stable: false },
33+
{ version: "11.4.0", path: "", stable: true },
34+
{ version: "11.2.1", path: "", stable: true },
35+
{ version: "11.2.0", path: "", stable: true },
36+
{ version: "11.0.0", path: "", stable: true },
37+
{ version: "10.3.0", path: "", stable: true }
3638
];
3739

3840
describe("XcodeSelector", () => {
3941
describe("getXcodeVersionFromAppPath", () => {
4042
it.each([
41-
["/temp/Xcode_11.app", { version: "11.0.0", path: "/temp/Xcode_11.app"}],
42-
["/temp/Xcode_11.2.app", { version: "11.2.0", path: "/temp/Xcode_11.2.app"}],
43-
["/temp/Xcode_11.2.1.app", { version: "11.2.1", path: "/temp/Xcode_11.2.1.app"}],
44-
["/temp/Xcode_11.2.1_beta.app", { version: "11.2.1", path: "/temp/Xcode_11.2.1_beta.app"}],
43+
["/temp/Xcode_11.app", { version: "11.0.0", path: "/temp/Xcode_11.app", stable: true }],
44+
["/temp/Xcode_11.2.app", { version: "11.2.0", path: "/temp/Xcode_11.2.app", stable: true }],
45+
["/temp/Xcode_11.2.1.app", { version: "11.2.1", path: "/temp/Xcode_11.2.1.app", stable: true }],
46+
["/temp/Xcode_11.2.1_beta.app", { version: "11.2.1", path: "/temp/Xcode_11.2.1_beta.app", stable: false }],
4547
["/temp/Xcode.app", null],
4648
["/temp/Xcode_11.2", null],
4749
["/temp/Xcode.11.2.app", null]
@@ -66,18 +68,20 @@ describe("XcodeSelector", () => {
6668
it("versions are filtered correctly", () => {
6769
const sel = new XcodeSelector();
6870
const expectedVersions: XcodeVersion[] = [
69-
{ version: "11.4.0", path: "/Applications/Xcode_11.4_beta.app" },
70-
{ version: "11.2.1", path: "/Applications/Xcode_11.2.1.app" },
71-
{ version: "11.1.0", path: "/Applications/Xcode_11.1.app" },
72-
{ version: "11.0.0", path: "/Applications/Xcode_11.app" }
71+
{ version: "12.0.0", path: "/Applications/Xcode_12_beta.app", stable: false},
72+
{ version: "11.4.0", path: "/Applications/Xcode_11.4_beta.app", stable: false },
73+
{ version: "11.2.1", path: "/Applications/Xcode_11.2.1.app", stable: true },
74+
{ version: "11.1.0", path: "/Applications/Xcode_11.1.app", stable: true },
75+
{ version: "11.0.0", path: "/Applications/Xcode_11.app", stable: true },
7376
];
7477
expect(sel.getAllVersions()).toEqual(expectedVersions);
7578
});
7679
});
7780

7881
describe("findVersion", () => {
7982
it.each([
80-
["latest", "11.4.0"],
83+
["latest", "12.0.0"],
84+
["latest-stable", "11.4.0"],
8185
["11", "11.4.0"],
8286
["11.x", "11.4.0"],
8387
["11.2.x", "11.2.1"],
@@ -102,7 +106,8 @@ describe("XcodeSelector", () => {
102106
let fsSpawnSpy: jest.SpyInstance;
103107
const xcodeVersion: XcodeVersion = {
104108
version: "11.4",
105-
path: "/Applications/Xcode_11.4.app"
109+
path: "/Applications/Xcode_11.4.app",
110+
stable: true
106111
};
107112

108113
beforeEach(() => {

dist/index.js

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;
@@ -1762,14 +1768,27 @@ module.exports = rcompare
17621768

17631769
"use strict";
17641770

1771+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1772+
if (k2 === undefined) k2 = k;
1773+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1774+
}) : (function(o, m, k, k2) {
1775+
if (k2 === undefined) k2 = k;
1776+
o[k2] = m[k];
1777+
}));
1778+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1779+
Object.defineProperty(o, "default", { enumerable: true, value: v });
1780+
}) : function(o, v) {
1781+
o["default"] = v;
1782+
});
17651783
var __importStar = (this && this.__importStar) || function (mod) {
17661784
if (mod && mod.__esModule) return mod;
17671785
var result = {};
1768-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1769-
result["default"] = mod;
1786+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1787+
__setModuleDefault(result, mod);
17701788
return result;
17711789
};
17721790
Object.defineProperty(exports, "__esModule", { value: true });
1791+
exports.XcodeSelector = void 0;
17731792
const child = __importStar(__webpack_require__(129));
17741793
const core = __importStar(__webpack_require__(470));
17751794
const fs = __importStar(__webpack_require__(747));
@@ -1791,7 +1810,8 @@ class XcodeSelector {
17911810
}
17921811
return {
17931812
version: version.version,
1794-
path: appPath
1813+
path: appPath,
1814+
stable: !match[2],
17951815
};
17961816
}
17971817
getAllVersions() {
@@ -1810,6 +1830,9 @@ class XcodeSelector {
18101830
if (versionSpec === "latest") {
18111831
return availableVersions[0];
18121832
}
1833+
if (versionSpec === "latest-stable") {
1834+
return availableVersions.filter(ver => ver.stable)[0];
1835+
}
18131836
return (_a = availableVersions.find(ver => semver.satisfies(ver.version, versionSpec))) !== null && _a !== void 0 ? _a : null;
18141837
}
18151838
setVersion(xcodeVersion) {
@@ -2253,11 +2276,23 @@ module.exports = inc
22532276

22542277
"use strict";
22552278

2279+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2280+
if (k2 === undefined) k2 = k;
2281+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2282+
}) : (function(o, m, k, k2) {
2283+
if (k2 === undefined) k2 = k;
2284+
o[k2] = m[k];
2285+
}));
2286+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
2287+
Object.defineProperty(o, "default", { enumerable: true, value: v });
2288+
}) : function(o, v) {
2289+
o["default"] = v;
2290+
});
22562291
var __importStar = (this && this.__importStar) || function (mod) {
22572292
if (mod && mod.__esModule) return mod;
22582293
var result = {};
2259-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
2260-
result["default"] = mod;
2294+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2295+
__setModuleDefault(result, mod);
22612296
return result;
22622297
};
22632298
Object.defineProperty(exports, "__esModule", { value: true });

0 commit comments

Comments
 (0)