generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extract platform-specific details into platform.ts * Update ci to work correctly for windows * Extract workflow script into its own file and update bundle * Use env variable for version to enable easier updates * Simplify platform code * Simplify platform code even further
- Loading branch information
1 parent
d42ebf9
commit 060d65f
Showing
7 changed files
with
154 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
if($args.count -ne 1) { | ||
Write-Host "This command requires 1 arg with the version to check" | ||
exit 1 | ||
} | ||
|
||
$result = pkl.exe --version | Select-String -Pattern $args[0] -Quiet | ||
|
||
if($result -eq "True") { | ||
exit 0 | ||
} else { | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os from 'node:os' | ||
|
||
type Platform = 'linux' | 'macos' | 'windows' | ||
type Architecture = 'amd64' | 'aarch64' | ||
|
||
type PlatformInfo = { | ||
githubSourceAssetName: string | ||
targetFileName: string | ||
} | ||
|
||
export function determinePlatformInfo(): PlatformInfo { | ||
const plat = determineOS() | ||
const arch = determineArch() | ||
|
||
return { | ||
githubSourceAssetName: determineGithubAsset(plat, arch), | ||
targetFileName: determineTargetFileName(plat) | ||
} | ||
} | ||
|
||
function determineOS(): Platform { | ||
switch (os.platform()) { | ||
case 'linux': | ||
return 'linux' | ||
case 'darwin': | ||
return 'macos' | ||
case 'win32': | ||
return 'windows' | ||
default: | ||
throw new Error('Unsupported platform') | ||
} | ||
} | ||
|
||
function determineArch(): Architecture { | ||
switch (os.arch()) { | ||
case 'arm64': | ||
return 'aarch64' | ||
case 'x64': | ||
return 'amd64' | ||
default: | ||
throw new Error('Unsupported architecture') | ||
} | ||
} | ||
|
||
function determineGithubAsset(plat: Platform, arch: Architecture): string { | ||
if (plat === 'windows') { | ||
return `pkl-windows-${arch}.exe` | ||
} | ||
|
||
return `pkl-${plat}-${arch}` | ||
} | ||
|
||
function determineTargetFileName(plat: Platform): string { | ||
switch (plat) { | ||
case 'windows': | ||
return 'pkl.exe' | ||
default: | ||
return 'pkl' | ||
} | ||
} |