diff --git a/setup-poetry/action.yml b/setup-poetry/action.yml index b057571..f9925e2 100644 --- a/setup-poetry/action.yml +++ b/setup-poetry/action.yml @@ -24,34 +24,24 @@ runs: exit 1 fi shell: bash - - name: Set paths (Linux/Mac) - if: runner.os != 'Windows' + - name: Set paths run: | - # Use the "pipeline directory" so that tools that search the workspace - # directory for Python files will not find the Poetry cache. Use - # realpath to normalize the "../". - PIPELINE_DIR="$(realpath $GITHUB_WORKSPACE/..)" - POETRY_ROOT="$PIPELINE_DIR/.cache/poetry" - echo "POETRY_BIN_DIR=$POETRY_ROOT/bin" >> "$GITHUB_ENV" - echo "POETRY_CONFIG_DIR=$POETRY_ROOT/config" >> "$GITHUB_ENV" - echo "POETRY_HOME=$POETRY_ROOT/home" >> "$GITHUB_ENV" - echo "POETRY_HOME_BIN=$POETRY_ROOT/home/bin" >> "$GITHUB_ENV" - echo "$POETRY_ROOT/bin" >> "$GITHUB_PATH" + poetry_root="$RUNNER_TEMP/poetry" + poetry_home="$poetry_root/home" + poetry_bin="$poetry_root/bin" + poetry_config="$poetry_root/config" + if [[ "$RUNNER_OS" == "Windows" ]]; then + binary_folder_name="Scripts" + else + binary_folder_name="bin" + fi + + echo "POETRY_BIN_DIR=$poetry_bin" >> "$GITHUB_ENV" + echo "POETRY_CONFIG_DIR=$poetry_config" >> "$GITHUB_ENV" + echo "POETRY_HOME=$poetry_home" >> "$GITHUB_ENV" + echo "POETRY_HOME_BIN=$poetry_home/$binary_folder_name" >> "$GITHUB_ENV" + echo "$poetry_bin" >> "$GITHUB_PATH" shell: bash - - name: Set paths (Windows) - if: runner.os == 'Windows' - run: | - # Use the "pipeline directory" so that tools that search the workspace - # directory for Python files will not find the Poetry cache. Use - # Resolve-Path to normalize the "../". - $PIPELINE_DIR = (Resolve-Path -Path "$env:GITHUB_WORKSPACE\..").Path - $POETRY_ROOT = "$PIPELINE_DIR\.cache\poetry" - Add-Content $env:GITHUB_ENV "POETRY_BIN_DIR=$POETRY_ROOT\bin" - Add-Content $env:GITHUB_ENV "POETRY_CONFIG_DIR=$POETRY_ROOT\config" - Add-Content $env:GITHUB_ENV "POETRY_HOME=$POETRY_ROOT\home" - Add-Content $env:GITHUB_ENV "POETRY_HOME_BIN=$POETRY_ROOT\home\Scripts" - Add-Content $env:GITHUB_PATH "$POETRY_ROOT\bin" - shell: pwsh - name: Copy paths from $GITHUB_ENV to $GITHUB_OUTPUT id: copy-paths run: | @@ -88,4 +78,4 @@ runs: echo "RUNNER_TEMP=$RUNNER_TEMP" echo "RUNNER_TOOL_CACHE=$RUNNER_TOOL_CACHE" ls -al "$POETRY_BIN_DIR" "$POETRY_HOME" "$POETRY_HOME_BIN" || true - shell: bash \ No newline at end of file + shell: bash