From ecf6bab2b84ceffdf50f029813a02419a9ac1fd2 Mon Sep 17 00:00:00 2001 From: Alexander Koz Date: Thu, 27 Jun 2024 17:07:55 +0400 Subject: [PATCH] fix path for powershell --- .github/workflows/tests.yml | 16 +++++++++++-- README.md | 46 ++++++++++++++++++++++++++++++++----- action.yml | 13 ++++++++++- 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6593af1..e52a8dc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,10 @@ on: jobs: tests: - name: ${{ matrix.version }} on ${{ matrix.os }} ${{ matrix.cache && '+cache' || '' }} ${{ matrix.gcc && '+gcc' || '' }} + name: >- + ${{ matrix.version }} on + ${{ (contains(matrix.os, 'macos') && 'mac') || (contains(matrix.os, 'ubuntu') && 'linux') || (contains(matrix.os, 'windows') && 'win') || matrix.os }} + ${{ matrix.cache && '+cache' || '' }} ${{ matrix.gcc && '+gcc' || '' }} ${{ matrix.root-win-path && '+fix-path' || '' }} runs-on: ${{ matrix.os }} defaults: run: @@ -26,6 +29,7 @@ jobs: - 2.4.1 # specified version cache: [true, false] gcc: [true, false] + root-win-path: [true, false] steps: - uses: actions/checkout@v4 @@ -36,6 +40,7 @@ jobs: version: ${{ matrix.version }} cache: ${{ matrix.cache }} gcc: ${{ matrix.gcc }} + root-win-path: ${{ matrix.root-win-path }} - name: outputs run: | @@ -48,8 +53,15 @@ jobs: [ -d "$PLAYDATE_SDK_PATH" ] || (echo "::error ::Missing output PLAYDATE_SDK_PATH" && exit 1) - name: equality + if: (runner.os != 'Windows' || !matrix.root-win-path) && (steps.installer.outputs.root != env.PLAYDATE_SDK_PATH) run: | - [ "$PLAYDATE_SDK_PATH" == "${{ steps.installer.outputs.root }}" ] || (echo "::error ::Env not eq output: PLAYDATE_SDK_PATH" && exit 1) + echo "::error ::Env not eq output: $PLAYDATE_SDK_PATH != ${{ steps.installer.outputs.root }}" + exit 1 + - name: inequality + if: (runner.os == 'Windows' && matrix.root-win-path) && (steps.installer.outputs.root == env.PLAYDATE_SDK_PATH) + run: | + echo "::error ::Env is eq output: $PLAYDATE_SDK_PATH == ${{ steps.installer.outputs.root }}" + exit 1 - name: $PATH run: | diff --git a/README.md b/README.md index 8f20ed5..a972b50 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,15 @@ Also installs arm-gcc gnu toolchain. - `custom-url` - Custom URL to the SDK installer. Useful for beta versions. If set, `version` will be ignored. - `gcc` - `true` to install `gcc-arm-none-eabi` toolchain, `false` to don't. Default is `true`. (Linux & Windows only. On macOS, the sdk installer installs the toolchain itself.) +- `root-win-path` - `true` to convert path to windows path format. _Only for win- workers._ + It changes `outputs.root`, but not `$PLAYDATE_SDK_PATH`. + + +## Supported platforms + +- macOS +- Linux +- Windows ## Usage Example @@ -21,9 +30,9 @@ Also installs arm-gcc gnu toolchain. ```yaml - name: Install Playdate SDK id: playdate - uses: pd-rs/get-playdate-sdk@0.3 + uses: pd-rs/get-playdate-sdk@0.4 with: - version: 2.4.2 # possible values: version `x.x.x` or `latest` by default + version: 2.5.0 # possible values: version `x.x.x` or `latest` by default - name: usage run: | @@ -33,8 +42,33 @@ Also installs arm-gcc gnu toolchain. pdc --version # because SDK/bin already in PATH ``` -## Supported platforms -- macOS -- Linux -- Windows +### Windows and Powershell + +Note that `$PLAYDATE_SDK_PATH` and `outputs.root` are set in POSIX format. +If you want to use it in powershell you should fix it using one of following solutions: +1. enable `root-win-path` _(see [inputs](#parameters))_ +1. fix the env for powershell from bash with: + ```yaml + - if: runner.os == 'Windows' + shell: bash + run: | + PLAYDATE_SDK_PATH=$(cygpath -w "$PLAYDATE_SDK_PATH") + echo "PLAYDATE_SDK_PATH=$PLAYDATE_SDK_PATH" >> $GITHUB_ENV + ``` + So you'll get fixed `$PLAYDATE_SDK_PATH` for powershell and normal `outputs.root` in POSIX +1. enable `root-win-path` _(see [inputs](#parameters))_ __and__ fix the env for powershell from bash with: + ```yaml + - name: Install Playdate SDK + id: playdate + uses: pd-rs/get-playdate-sdk@0.4 + with: + root-win-path: true + + - run: echo "PLAYDATE_SDK_PATH=$PLAYDATE_SDK_PATH" >> $GITHUB_ENV + env: PLAYDATE_SDK_PATH: ${{ steps.playdate.outputs.root }} + if: runner.os == 'Windows' + shell: bash + + ``` + So you'll get both paths fixed for powershell - `$PLAYDATE_SDK_PATH` and `outputs.root`. diff --git a/action.yml b/action.yml index 9dfdc2c..d822a48 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,10 @@ inputs: default: "true" description: Install gcc-arm-none-eabi toolchain required: false + root-win-path: + default: "false" + description: Convert path to windows path format. Ignored on non-win workers. If enabled changes `outputs.root`, but not `$PLAYDATE_SDK_PATH`. + required: false # path: # default: default # description: SDK installation path. Optional. @@ -151,5 +155,12 @@ runs: id: output shell: bash run: | - echo "root=$PLAYDATE_SDK_PATH" >> $GITHUB_OUTPUT echo "version=$(cat $PLAYDATE_SDK_PATH/VERSION.txt)" >> $GITHUB_OUTPUT + # ${{ (runner.os == 'Windows' && inputs.root-win-path) && 'echo "root=$(cygpath -w "$PLAYDATE_SDK_PATH")" >> $GITHUB_OUTPUT' }} + + if ${{ runner.os == 'Windows' }} && ${{ inputs.root-win-path }}; then + PLAYDATE_SDK_PATH=$(cygpath -w "$PLAYDATE_SDK_PATH") + echo "fix root path" + fi + echo "root=$PLAYDATE_SDK_PATH" >> $GITHUB_OUTPUT + echo "set root to $PLAYDATE_SDK_PATH"