Skip to content

Commit 7378759

Browse files
authored
chore: adopt swiftorg metadata contract changes (#316)
1 parent f2a737f commit 7378759

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
swift: '5.0.0'
161161
development: false
162162
- os: macos-13
163-
swift: 'latest'
163+
swift: '5.9'
164164
development: false
165165
- os: windows-latest
166166
swift: '5.9'
@@ -216,6 +216,50 @@ jobs:
216216
if: runner.os == 'Windows'
217217
run: which link | grep "Microsoft Visual Studio" || exit 1
218218

219+
- name: Get cached installation
220+
id: get-tool
221+
if: failure()
222+
uses: actions/github-script@v7
223+
with:
224+
script: |
225+
const os = require('os');
226+
const fs = require('fs/promises');
227+
const toolCache = require('@actions/tool-cache');
228+
let arch = '';
229+
switch (os.arch()) {
230+
case 'x64':
231+
arch = 'x86_64';
232+
break;
233+
case 'arm64':
234+
arch = 'aarch64';
235+
break;
236+
default:
237+
arch = os.arch();
238+
break;
239+
}
240+
const key = process.env['SWIFT_SETUP_TOOL_KEY'];
241+
if (!key) {
242+
core.debug(`Toolcache not set`);
243+
return;
244+
}
245+
const tools = toolCache.findAllVersions(key, arch);
246+
if (!tools.length) {
247+
core.debug(`No tools found for "${key}" with arch ${arch}`);
248+
return;
249+
} else {
250+
core.debug(`Found tools "${tools.join(', ')}" for "${key}" with arch ${arch}`);
251+
}
252+
const tool = tools[0];
253+
await fs.access(tool);
254+
return { key: key, tool: tool };
255+
256+
- name: Upload cached installation as artifact
257+
if: always() && steps.get-tool.outputs.result != ''
258+
uses: actions/upload-artifact@v4
259+
with:
260+
name: ${{ fromJson(steps.get-tool.outputs.result).key }}-tool
261+
path: ${{ fromJson(steps.get-tool.outputs.result).tool }}
262+
219263
dry-run:
220264
name: Check action with dry run
221265
if: needs.ci.outputs.run == 'true'

dist/index.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/installer/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export abstract class ToolchainInstaller<Snapshot extends ToolchainSnapshot> {
7171

7272
if (tool && version) {
7373
tool = await toolCache.cacheDir(tool, key, version, arch)
74+
if (core.isDebug()) {
75+
core.exportVariable('SWIFT_SETUP_TOOL_KEY', key)
76+
}
7477
core.debug(`Added to tool cache at "${tool}"`)
7578
}
7679
if (

src/platform/versioned.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export abstract class VersionedPlatform<
109109
const pDownloadName =
110110
platform.dir ?? platform.name.replaceAll(/\s+/g, '').toLowerCase()
111111
const download = `${release.tag}-${pDownloadName}${this.archSuffix}.${this.downloadExtension}`
112-
return platform.archs.includes(this.arch)
112+
return platform.archs && platform.archs.includes(this.arch)
113113
? ({
114114
name: platform.name,
115115
date: release.date,

0 commit comments

Comments
 (0)