-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2efd3ca
Showing
12 changed files
with
455 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Test ghcup action | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
runs-on: | ||
- ubuntu-latest | ||
- macos-latest | ||
- windows-latest | ||
runs-on: ${{ matrix.runs-on }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./ghcup | ||
with: | ||
version: "0.1.30.0" | ||
|
||
- run: ghcup list | ||
|
||
- shell: bash | ||
run: | | ||
echo "$BASH_VERSION" | ||
installed=( $(ghcup list -t ghc -c installed -r | cut -d' ' -f2) ) | ||
typeset -p installed | ||
if [[ ${#installed[@]} == 0 ]]; then | ||
echo "no version of GHC is currently installed." | ||
elif [[ ${#installed[@]} == 1 ]]; then | ||
echo "GHC version ${installed[0]} is currently installed." | ||
else | ||
echo "${#installed[*]} versions of GHCs are installed." | ||
for v in "${installed[@]}"; do | ||
ghcup whereis ghc "$v" | ||
echo | ||
done | ||
fi | ||
- run: ghcup install ghc latest --set | ||
- run: ghc --version | ||
|
||
- run: ghcup install cabal latest --set | ||
- run: cabal --version | ||
|
||
- run: ghcup install stack latest --set | ||
- run: stack --version | ||
|
||
- run: ghcup install hls latest --set | ||
- run: hls --version | ||
|
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,77 @@ | ||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
|
||
# Logs | ||
|
||
logs | ||
_.log | ||
npm-debug.log_ | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Caches | ||
|
||
.cache | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
|
||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
||
# Runtime data | ||
|
||
pids | ||
_.pid | ||
_.seed | ||
*.pid.lock | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
|
||
build/Release | ||
|
||
# Dependency directories | ||
|
||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
|
||
web_modules/ | ||
|
||
# TypeScript cache | ||
|
||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
|
||
.npm | ||
|
||
# Optional eslint cache | ||
|
||
.eslintcache | ||
|
||
# Optional REPL history | ||
|
||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
|
||
*.tgz | ||
|
||
# Yarn Integrity file | ||
|
||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
|
||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# IntelliJ based IDEs | ||
.idea | ||
|
||
# Finder (MacOS) folder config | ||
.DS_Store |
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,3 @@ | ||
.PHONY: dist/index.js | ||
dist/index.js: | ||
bun build --target=node --minify --outfile=$@ src/index.ts |
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,24 @@ | ||
name: GHCup | ||
description: Download a pre-built version of GHCup and add it to the PATH | ||
author: Andrea Bedini | ||
|
||
branding: | ||
icon: download | ||
|
||
inputs: | ||
version: | ||
description: Version to install | ||
required: true | ||
extra-release-channels: | ||
description: Additional release-channels | ||
required: true | ||
|
||
outputs: | ||
path: | ||
description: Path to the installed GHCup | ||
version: | ||
description: Version of the installed GHCup | ||
|
||
runs: | ||
using: node20 | ||
main: dist/index.js |
Binary file not shown.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "ghcup", | ||
"module": "src/index.ts", | ||
"type": "module", | ||
"devDependencies": { | ||
"@types/bun": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "^1.11.1", | ||
"@actions/exec": "^1.1.1", | ||
"@actions/io": "^1.1.3", | ||
"@actions/tool-cache": "^2.0.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { main } from "./main.ts" | ||
import core from "@actions/core"; | ||
|
||
try { | ||
main({ | ||
version: core.getInput("version"), | ||
extra_release_channels: core.getMultilineInput("extra-release-channels") | ||
}) | ||
} catch (error) { | ||
core.setFailed((error as Error).message); | ||
} |
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,95 @@ | ||
import * as path from 'path' | ||
import { chmod } from 'fs/promises'; | ||
|
||
import tc from '@actions/tool-cache'; | ||
import core, { platform } from '@actions/core'; | ||
import exec from '@actions/exec'; | ||
|
||
const ext = platform.isWindows ? ".exe" : ""; | ||
|
||
const metadata_url = "https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/develop/ghcup-0.0.8.yaml"; | ||
|
||
type Architecture = typeof platform.arch; | ||
type GHCupArch = 'aarch64' | 'armv7' | 'i386' | 'x86_64'; | ||
|
||
const ghcup_arch_map: Map<Architecture, GHCupArch> = new Map([ | ||
['arm64', 'aarch64'], | ||
['arm', 'armv7'], | ||
['ia32', 'i386'], | ||
['x64', 'x86_64'] | ||
]); | ||
|
||
type Platform = typeof platform.platform; | ||
type GHCupOS = 'apple-darwin' | 'linux' | 'mingw64'; | ||
|
||
const ghcup_os_map: Map<Platform, GHCupOS> = new Map([ | ||
['darwin', 'apple-darwin'], | ||
['linux', 'linux'], | ||
['win32', 'mingw64'] | ||
]); | ||
|
||
function ghcup_url(version: string, arch: GHCupArch, os: GHCupOS): string { | ||
return `https://downloads.haskell.org/ghcup/${version}/${arch}-${os}-ghcup-${version}${ext}`; | ||
} | ||
|
||
async function ghcup(version: string) { | ||
const ghcupDirectory = tc.find('ghcup', version) | ||
if (ghcupDirectory) { | ||
return ghcupDirectory | ||
} else { | ||
|
||
const arch = ghcup_arch_map.get(platform.arch); | ||
if (arch == undefined) { | ||
const msg = `GHCup does not support architecture ${platform.arch}`; | ||
// core.setFailed(msg); | ||
throw msg; | ||
} | ||
|
||
const os = ghcup_os_map.get(platform.platform); | ||
if (os == undefined) { | ||
const msg = `GHCup does not support platform ${platform.platform}` | ||
// core.setFailed(msg); | ||
throw msg; | ||
} | ||
|
||
const url = ghcup_url(version, arch, os); | ||
|
||
const tempDirectory = process.env['RUNNER_TEMP'] || ''; | ||
const ghcupExeName = `ghcup${ext}`; | ||
const dest = path.join(tempDirectory, ghcupExeName); | ||
|
||
const ghcupPath = await tc.downloadTool(url, dest); | ||
|
||
if (platform.isLinux || platform.isMacOS) { | ||
await chmod(ghcupPath, "0765"); | ||
} | ||
|
||
const ghcupDir = await tc.cacheFile(ghcupPath, ghcupExeName, "ghcup", version); | ||
core.addPath(ghcupDir); | ||
return path.join(ghcupDir, ghcupExeName); | ||
} | ||
} | ||
|
||
export type Opts = { | ||
version: string, | ||
extra_release_channels: string[] | ||
} | ||
|
||
export async function main(opts: Opts) { | ||
const ghcupPath = await ghcup(opts.version); | ||
core.debug(`ghcup is at ${ghcupPath}`); | ||
|
||
var { stdout } = await exec.getExecOutput(ghcupPath, ["--numeric-version"]); | ||
const effective_version = stdout.trim(); | ||
core.setOutput("version", effective_version); | ||
core.setOutput("path", ghcupPath) | ||
|
||
var { stdout } = await exec.getExecOutput(ghcupPath, ["whereis", "bindir"]); | ||
const bindir = stdout.trim(); | ||
core.debug(`ghcup bindir is ${bindir}`) | ||
core.addPath(bindir); | ||
|
||
for (const channel in opts.extra_release_channels) { | ||
await exec.exec(ghcupPath, ['config', 'add-release-channel', channel]); | ||
} | ||
} |
Oops, something went wrong.