Skip to content

Commit

Permalink
fix: modifiable parent directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jiro4989 committed Jul 8, 2024
1 parent 54dd991 commit e8476e9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
23 changes: 21 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ inputs:
description: >-
The Nim compiler installation directory.
default: '.nim_runtime'
parent-nim-install-directory:
description: >-
The Nim compiler installation parent directory.
It will be placed in the current directory if this parameter is empty.
default: ''
repo-token:
description: 'The GITHUB_TOKEN secret'
required: false
Expand All @@ -34,25 +39,39 @@ runs:
run: |
"${{ github.action_path }}/install_nim.sh" \
--nim-version "${{ inputs.nim-version }}" \
--parent-nim-install-directory "${{ inputs.parent-nim-install-directory }}" \
--nim-install-directory "${{ inputs.nim-install-directory }}" \
--os "${{ runner.os }}" \
--repo-token "${{ inputs.repo-token }}"
- name: Set PATH for Unix
shell: bash
run: |
echo "$PWD/${{ inputs.nim-install-directory }}/bin" >> "$GITHUB_PATH"
parent="${{ inputs.parent-nim-install-directory }}"
if [[ "${parent}" = "" ]]; then
parent="$PWD"
fi
echo "$parent/${{ inputs.nim-install-directory }}/bin" >> "$GITHUB_PATH"
echo "$HOME/.nimble/bin" >> "$GITHUB_PATH"
if: runner.os != 'Windows'

- name: Set PATH for Windows
shell: pwsh
run: |
echo "$Pwd\${{ inputs.nim-install-directory }}\bin" >> $Env:GITHUB_PATH
$parent = "${{ inputs.parent-nim-install-directory }}"
if ($parent -eq "") {
$parent = "$Pwd"
}
echo "$parent\${{ inputs.nim-install-directory }}\bin" >> $Env:GITHUB_PATH
mkdir -Force ~\.nimble\bin
(Resolve-Path ~\.nimble\bin).Path >> $Env:GITHUB_PATH
if: runner.os == 'Windows'

- name: Print nim directory
shell: bash
run: |
echo "installed nim fullpath: $(which nim)"
- name: Print nim version
shell: bash
run: nim -v
Expand Down
10 changes: 10 additions & 0 deletions install_nim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ nim_version="stable"
nim_install_dir=".nim_runtime"
os="Linux"
repo_token=""
parent_nim_install_dir=""
while ((0 < $#)); do
opt=$1
shift
Expand All @@ -48,6 +49,9 @@ while ((0 < $#)); do
--nim-install-directory)
nim_install_dir=$1
;;
--parent-nim-install-directory)
parent_nim_install_dir=$1
;;
--os)
os=$1
;;
Expand All @@ -57,6 +61,12 @@ while ((0 < $#)); do
esac
done

if [[ "$parent_nim_install_dir" = "" ]]; then
parent_nim_install_dir="$PWD"
fi

cd "$parent_nim_install_dir"

# build nim compiler for devel branch
if [[ "$nim_version" = "devel" ]]; then
if [[ "$os" = Windows ]]; then
Expand Down

0 comments on commit e8476e9

Please sign in to comment.