Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed Mar 20, 2022
1 parent 29dc79e commit aefe3aa
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test
on:
pull_request:
push:
branches:
- main
- master

jobs:
tests:
name: ${{ matrix.version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: true
matrix:
os:
- macos-latest
- ubuntu-latest
# - windows-latest
version:
- latest
# - 1.9.2
steps:
- uses: actions/checkout@v2

- name: install SDK
id: installer
uses: ./
with:
version: ${{ matrix.version }}

- name: outputs
run: |
[ -d "${{ steps.installer.outputs.root }}" ] || (echo "::error ::Missing output SDK root" && exit 1)
# [ -z "${{ steps.installer.outputs.version }}" ] || (echo "::error ::Missing output version" && exit 1)
echo "version: ${{ steps.installer.outputs.version }}"
- name: ENV
run: |
[ -d "$PLAYDATE_SDK_PATH" ] || (echo "::error ::Missing output PLAYDATE_SDK_PATH" && exit 1)
- name: equality
run: |
[ "$PLAYDATE_SDK_PATH" == "${{ steps.installer.outputs.root }}" ] || (echo "::error ::Env not eq output: PLAYDATE_SDK_PATH" && exit 1)
- name: $PATH
run: |
which pdc || (echo "::error ::Missing pdc from PATH." && exit 1)
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Get Playdate SDK

This GitHub Action delivers specified [Playdate] SDK.

[Playdate]: https://play.date/dev/#cardSDK


## Parameters

- `version` - Specified version of the SDK. Optional. Default value is `latest`.
<!-- - `token` - GITHUB_TOKEN. Optional. -->

## Usage Example

Download the latest version of dove

```yaml
- name: Install Playdate SDK
id: playdate
uses: ./
with:
# optional, can be omitted
version: latest

- name: usage
run: |
echo "SDK root: $PLAYDATE_SDK_PATH"
echo "SDK root: ${{ steps.playdate.outputs.root }}"
echo "SDK version: ${{ steps.playdate.outputs.version }}"
pdc --version
```
87 changes: 87 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Get Playdate SDK
description: Download & install Playdate SDK.
author: Alex Koz
branding:
icon: package
color: yellow
inputs:
version:
default: latest
description: SDK version (ex. `1.9.1` or default `latest`).
required: false
# path:
# default: default
# description: SDK installation path. Optional.
# required: false
# token:
# description: GITHUB_TOKEN. Optional.
# required: false
outputs:
root:
description: Path of SDK root
value: ${{ steps.output.outputs.root }}
version:
description: Version of the installed SDK.
value: ${{ steps.output.outputs.version }}
runs:
using: "composite"
steps:
- name: download pkg
if: runner.os == 'macOS'
shell: bash
# env:
# SECRET_TOKEN: ${{inputs.token}}
run: |
# matrix.version < 1.9.3:
# url: https://download.panic.com/playdate_sdk/PlaydateSDK-${{ matrix.version }}.pkg
# matrix.version >= 1.9.3:
# url: https://download.panic.com/playdate_sdk/PlaydateSDK-${{ matrix.version }}.zip
curl -L --silent --show-error --fail "https://download.panic.com/playdate_sdk/PlaydateSDK-${{ matrix.version }}.zip" -o sdk.zip
unzip sdk.zip
sudo installer -store -pkg "PlaydateSDK.pkg" -target /
cat ~/.Playdate/config
echo "root: $PLAYDATE_SDK_PATH"
PLAYDATE_SDK_PATH="$(grep -E '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | awk '{print $2}')"
echo "PLAYDATE_SDK_PATH=$PLAYDATE_SDK_PATH" >> $GITHUB_ENV
- name: download tar.gz
if: runner.os == 'Linux'
shell: bash
# env:
# SECRET_TOKEN: ${{inputs.token}}
run: |
cd "${{ github.action_path }}"
curl -L --silent --show-error --fail "https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-${{ matrix.version }}.tar.gz" -o sdk.tar.gz
mkdir _pd-sdk
tar -zxf sdk.tar.gz -C _pd-sdk
cd _pd-sdk/*/
# TODO: fix permissions:
# sudo chown runner setup.sh && chmod +x setup.sh
sudo ./setup.sh || true
echo "PLAYDATE_SDK_PATH=$PWD" >> $GITHUB_ENV
echo "$PWD/bin" >> $GITHUB_PATH
- name: download exe
if: runner.os == 'Windows'
shell: bash
# env:
# SECRET_TOKEN: ${{inputs.token}}
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-running-a-script-using-powershell-core
run: |
echo "::error ::Windows not supported yet." && exit 1
cd "${{ github.action_path }}"
curl -L --silent --show-error --fail "https://download.panic.com/playdate_sdk/Windows/PlaydateSDK-${{ matrix.version }}.exe" -o sdk.exe
# TODO: install sdk.exe
echo "try 1"
./sdk.exe --quiet || true
echo "try 2"
./sdk.exe ?
# TODO: output the path
- name: post setup
id: output
shell: bash
run: |
echo "::set-output name=root::$PLAYDATE_SDK_PATH"
echo "::set-output name=version::$(cat $PLAYDATE_SDK_PATH/VERSION.txt)"

0 comments on commit aefe3aa

Please sign in to comment.