Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path for powershell #35

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -36,6 +40,7 @@ jobs:
version: ${{ matrix.version }}
cache: ${{ matrix.cache }}
gcc: ${{ matrix.gcc }}
root-win-path: ${{ matrix.root-win-path }}

- name: outputs
run: |
Expand All @@ -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: |
Expand Down
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@ 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

```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: |
Expand All @@ -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`.
13 changes: 12 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"