-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
166 lines (154 loc) · 5.84 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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. `2.0.0` or default `latest`).
required: false
custom-url:
description: Custom URL to the SDK installer. Useful for beta versions.
required: false
cache:
default: "true"
description: Cache installer.
required: false
gcc:
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.
# 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: prepare
id: cfg
shell: bash
run: |
OS_EXT="${{ (runner.os == 'Linux' && 'tar.gz') || (runner.os == 'macOS' && 'zip') || ( runner.os == 'Windows' && 'exe') }}"
RUNNER_OS_PART="${{ (runner.os == 'Linux' && '/Linux/') || (runner.os == 'macOS' && '/') || ( runner.os == 'Windows' && '/Windows/') }}"
URL="https://download.panic.com/playdate_sdk${RUNNER_OS_PART?}PlaydateSDK-${{ inputs.version }}.${OS_EXT?}"
echo "filename=sdk.$OS_EXT" >> $GITHUB_OUTPUT
echo "ext=$OS_EXT" >> $GITHUB_OUTPUT
echo "url=${{ inputs.custom-url || '$URL' }}" >> $GITHUB_OUTPUT
- name: get direct url
id: direct-url
shell: bash
run: |
trim() {
local trimmed="$1"
# Strip leading space.
trimmed="${trimmed## }"
# Strip trailing space.
trimmed="${trimmed%% }"
echo "$trimmed"
}
DIRECT_URL=$(curl -X HEAD -w "%{url_effective}" -I -L -s -S ${{ steps.cfg.outputs.url }} -o /dev/null)
DIRECT_URL=$(trim "$DIRECT_URL")
echo "direct url: $DIRECT_URL"
echo "url=$DIRECT_URL" >> $GITHUB_OUTPUT
echo "$DIRECT_URL" > ./TEMP_SDK_INSTALLER_URL
- name: hash url
id: hash
shell: bash
run: |
echo "url=${{ hashFiles('./TEMP_SDK_INSTALLER_URL') }}" >> $GITHUB_OUTPUT
echo "hash: ${{ hashFiles('./TEMP_SDK_INSTALLER_URL') }}"
rm ./TEMP_SDK_INSTALLER_URL
- name: Cache restore
if: inputs.cache == 'true'
uses: actions/cache/restore@v4
id: cache-restore
with:
path: ${{ steps.cfg.outputs.filename }}
key: ${{ runner.os }}-pd-sdk-${{ steps.hash.outputs.url }}
- name: download
# not using cache or have got cache-miss
if: (steps.cache-restore.outputs.cache-hit != 'true') || (inputs.cache != 'true')
shell: bash
run: >-
curl -L -sS --show-error --fail "${{ steps.direct-url.outputs.url }}" -o ${{ steps.cfg.outputs.filename }}
|| curl -L -sS --show-error --fail "${{ steps.cfg.outputs.url }}" -o ${{ steps.cfg.outputs.filename }}
- name: Cache save
id: cache-save
# cache-miss and using cache
if: (steps.cache-restore.outputs.cache-hit != 'true') && (inputs.cache == 'true')
uses: actions/cache/save@v4
with:
path: ${{ steps.cfg.outputs.filename }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: install
if: runner.os == 'macOS'
shell: bash
run: |
unzip ${{ steps.cfg.outputs.filename }}
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: install
if: runner.os == 'Linux'
shell: bash
run: |
mkdir _pd-sdk
tar -zxf ${{ steps.cfg.outputs.filename }} -C _pd-sdk
cd _pd-sdk/*/
# 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: install gnu-arm-gcc
if: runner.os == 'Linux' && inputs.gcc-arm != 'false'
shell: bash
run: |
sudo apt install -y gcc-arm-none-eabi
- name: install latest SDK
if: runner.os == 'Windows'
shell: powershell
# /D doesn't works
# run: Start-Process -Wait -FilePath "${{ steps.cfg.outputs.filename }}" -ArgumentList "/S","/D=D:\\PlaydateSDK"
run: Start-Process -Wait -FilePath "${{ steps.cfg.outputs.filename }}" -ArgumentList "/S"
- name: set env
if: runner.os == 'Windows'
shell: bash
run: |
PLAYDATE_SDK_PATH_lOCAL=$(realpath ~/Documents/PlaydateSDK)
echo "PLAYDATE_SDK_PATH=$PLAYDATE_SDK_PATH_lOCAL" >> "$GITHUB_ENV"
echo "$PLAYDATE_SDK_PATH_lOCAL/bin" >> $GITHUB_PATH
- name: install gnu-arm-gcc
if: runner.os == 'Windows' && inputs.gcc-arm != 'false'
shell: powershell
run: choco install --no-progress gcc-arm-embedded -y
- name: post setup
id: output
shell: bash
run: |
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"