Skip to content
Merged
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
46 changes: 45 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
swift: '5.0.0'
development: false
- os: macos-13
swift: 'latest'
swift: '5.9'
development: false
- os: windows-latest
swift: '5.9'
Expand Down Expand Up @@ -216,6 +216,50 @@ jobs:
if: runner.os == 'Windows'
run: which link | grep "Microsoft Visual Studio" || exit 1

- name: Get cached installation
id: get-tool
if: failure()
uses: actions/github-script@v7
with:
script: |
const os = require('os');
const fs = require('fs/promises');
const toolCache = require('@actions/tool-cache');
let arch = '';
switch (os.arch()) {
case 'x64':
arch = 'x86_64';
break;
case 'arm64':
arch = 'aarch64';
break;
default:
arch = os.arch();
break;
}
const key = process.env['SWIFT_SETUP_TOOL_KEY'];
if (!key) {
core.debug(`Toolcache not set`);
return;
}
const tools = toolCache.findAllVersions(key, arch);
if (!tools.length) {
core.debug(`No tools found for "${key}" with arch ${arch}`);
return;
} else {
core.debug(`Found tools "${tools.join(', ')}" for "${key}" with arch ${arch}`);
}
const tool = tools[0];
await fs.access(tool);
return { key: key, tool: tool };

- name: Upload cached installation as artifact
if: always() && steps.get-tool.outputs.result != ''
uses: actions/upload-artifact@v4
with:
name: ${{ fromJson(steps.get-tool.outputs.result).key }}-tool
path: ${{ fromJson(steps.get-tool.outputs.result).tool }}

dry-run:
name: Check action with dry run
if: needs.ci.outputs.run == 'true'
Expand Down
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/installer/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export abstract class ToolchainInstaller<Snapshot extends ToolchainSnapshot> {

if (tool && version) {
tool = await toolCache.cacheDir(tool, key, version, arch)
if (core.isDebug()) {
core.exportVariable('SWIFT_SETUP_TOOL_KEY', key)
}
core.debug(`Added to tool cache at "${tool}"`)
}
if (
Expand Down
2 changes: 1 addition & 1 deletion src/platform/versioned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export abstract class VersionedPlatform<
const pDownloadName =
platform.dir ?? platform.name.replaceAll(/\s+/g, '').toLowerCase()
const download = `${release.tag}-${pDownloadName}${this.archSuffix}.${this.downloadExtension}`
return platform.archs.includes(this.arch)
return platform.archs && platform.archs.includes(this.arch)
? ({
name: platform.name,
date: release.date,
Expand Down