diff --git a/action.yaml b/action.yaml index 4e11d8d..20b473a 100644 --- a/action.yaml +++ b/action.yaml @@ -31,61 +31,6 @@ runs: - name: Setup MoonBit shell: nu {0} run: | - const CLI_HOST = 'https://cli.moonbitlang.com' - - const CLI_DOWNLOAD_PATH = { - Windows: 'windows', - Ubuntu: 'ubuntu_x86', - Darwin: 'macos_intel', - } - - export-env { - $env.config.color_config.leading_trailing_space_bg = { attr: n } - } - - # If current host is Windows - export def windows? [] { - # Windows / Darwin / Linux - (sys).host.name == 'Windows' - } - - # Create a line by repeating the unit with specified times - def build-line [ - times: int, - unit: string = '-', - ] { - 0..<$times | reduce -f '' { |i, acc| $unit + $acc } - } - - export def hr-line [ - width?: int = 90, - --color(-c): string = 'g', - --blank-line(-b), - --with-arrow(-a), - ] { - echo $'(ansi $color)(build-line $width)(if $with_arrow {'>'})(ansi reset)' - if $blank_line { char nl } - } - - # Download moonbit binary files to local - export def 'setup moonbit' [] { - let MOONBIT_BIN_DIR = [$nu.home-path '.moon'] | path join - const DEFAULT_BINS = ['moon', 'moonc', 'moonfmt', 'moonrun', 'mooninfo'] - const WINDOWS_BINS = ['moon.exe', 'moonc.exe', 'moonfmt.exe', 'moonrun.exe'] - mkdir $MOONBIT_BIN_DIR; cd $MOONBIT_BIN_DIR - let DOWNLOAD_PATH = $CLI_DOWNLOAD_PATH | get -i (sys).host.name - - if (windows?) { - $WINDOWS_BINS | each {|it| aria2c $'($CLI_HOST)/($DOWNLOAD_PATH)/($it)' } - } else { - $DEFAULT_BINS | each {|it| aria2c $'($CLI_HOST)/($DOWNLOAD_PATH)/($it)'; chmod +x $it } - } - - echo (char nl) - echo $'Contents of ($MOONBIT_BIN_DIR):'; hr-line -b - echo (ls -l $MOONBIT_BIN_DIR) - echo $MOONBIT_BIN_DIR | save -a $env.GITHUB_PATH - } - + use ${{ github.action_path }}/nu/moonbit.nu * setup moonbit