Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
213 lines (204 loc) · 8.51 KB
/
Copy pathaction.yml
File metadata and controls
213 lines (204 loc) · 8.51 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Setup Godot Engine
description: 'GitHub Action to setup Godot Engine from official GitHub releases.'
inputs:
repo:
description: 'Repository to download Godot from (default: godotengine/godot)'
default: 'godotengine/godot'
version:
description: 'Godot version (e.g. 4.4-stable)'
required: true
release-tag:
description: 'If empty will use same as version.'
required: false
default: ''
bin-path:
description: 'Path for binaries to be installed to, relative to the current working directory of the action. This is the path that will be added to the system path.'
default: 'godot-bin'
download_editor:
description: 'Download Godot Editor binary'
default: 'true'
download_template:
description: 'Download Godot export templates'
default: 'false'
mono:
description: 'Download Mono version (C# support)'
default: 'false'
enable_cache:
description: 'Enable caching of downloaded files'
default: 'false'
author: Apps In a Cup
branding:
icon: 'terminal'
color: 'blue'
runs:
using: 'composite'
steps:
- name: Install Linux Dependencies
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-0 libgtk-3-0
- name: Cache Godot Editor
if: inputs.download_editor == 'true' && inputs.enable_cache == 'true'
id: cache-editor
uses: actions/cache@v4
with:
path: ${{ inputs.bin-path }}
key: godot-editor-${{ inputs.repo }}-${{ inputs.version }}-${{ inputs.mono }}-${{ runner.os }}
restore-keys: |
godot-editor-${{ inputs.repo }}-${{ inputs.version }}-${{ inputs.mono }}-
godot-editor-${{ inputs.repo }}-${{ inputs.version }}-
- name: Cache Godot Templates
if: inputs.download_template == 'true' && inputs.enable_cache == 'true'
id: cache-templates
uses: actions/cache@v4
with:
path: ${{ inputs.bin-path }}/templates
key: godot-templates-${{ inputs.repo }}-${{ inputs.version }}-${{ inputs.mono }}
restore-keys: |
godot-templates-${{ inputs.repo }}-${{ inputs.version }}-
- name: Download Godot Editor
if: inputs.download_editor == 'true' && (inputs.enable_cache != 'true' || steps.cache-editor.outputs.cache-hit != 'true')
shell: bash
run: |
GODOT_VERSION="${{ inputs.version }}"
GODOT_RELEASE="${{ inputs.release-tag }}"
if [ -z "$GODOT_RELEASE" ]; then
GODOT_RELEASE="$GODOT_VERSION"
fi
BIN_PATH="${{ inputs.bin-path }}"
MONO="${{ inputs.mono }}"
mkdir -p "$BIN_PATH"
# Detect OS using GitHub Actions runner.os
if [ "${{ runner.os }}" == "Linux" ]; then
GODOT_PLATFORM="linux.x86_64"
elif [ "${{ runner.os }}" == "macOS" ]; then
GODOT_PLATFORM="macos.universal"
elif [ "${{ runner.os }}" == "Windows" ]; then
GODOT_PLATFORM="win64.exe"
else
echo "Unknown OS: ${{ runner.os }}"; exit 1
fi
# Determine if mono build is needed
if [[ "$MONO" == "true" ]]; then
# Linux mono uses _ instead of . in platform
if [ "$GODOT_PLATFORM" == "linux.x86_64" ]; then
GODOT_EDITOR_NAME="Godot_v${GODOT_VERSION}_mono_linux_x86_64.zip"
# Windows mono uses win64 (not win64.exe) in filename
elif [ "$GODOT_PLATFORM" == "win64.exe" ]; then
GODOT_EDITOR_NAME="Godot_v${GODOT_VERSION}_mono_win64.zip"
else
GODOT_EDITOR_NAME="Godot_v${GODOT_VERSION}_mono_${GODOT_PLATFORM}.zip"
fi
else
GODOT_EDITOR_NAME="Godot_v${GODOT_VERSION}_${GODOT_PLATFORM}.zip"
fi
GODOT_RELEASE_URL="https://github.com/${{ inputs.repo }}/releases/download/${GODOT_RELEASE}/$GODOT_EDITOR_NAME"
echo "Downloading $GODOT_RELEASE_URL"
curl -L "$GODOT_RELEASE_URL" -o godot_editor.zip
unzip -o godot_editor.zip -d "$BIN_PATH"
chmod -R +x "$BIN_PATH"/*
- name: Setup Godot Environment
shell: bash
run: |
BIN_PATH="${{ inputs.bin-path }}"
DOWNLOAD_EDITOR="${{ inputs.download_editor }}"
# Always set environment variables if editor is enabled
if [[ "$DOWNLOAD_EDITOR" == "true" ]]; then
# Detect OS using GitHub Actions runner.os
if [ "${{ runner.os }}" == "Linux" ]; then
GODOT_PLATFORM="linux.x86_64"
elif [ "${{ runner.os }}" == "macOS" ]; then
GODOT_PLATFORM="macos.universal"
elif [ "${{ runner.os }}" == "Windows" ]; then
GODOT_PLATFORM="win64.exe"
else
echo "Unknown OS: ${{ runner.os }}"; exit 1
fi
# Find the Godot binary depending on platform
GODOT_BIN_PATH=""
if [[ "$GODOT_PLATFORM" == macos* ]]; then
GODOT_BIN_PATH=$(find "$BIN_PATH" -type f -path "*/Godot.app/Contents/MacOS/Godot" | head -n 1)
elif [[ "$GODOT_PLATFORM" == win* ]]; then
GODOT_BIN_PATH=$(find "$BIN_PATH" -type f -name "*_console.exe" | head -n 1)
if [[ -z "$GODOT_BIN_PATH" ]]; then
GODOT_BIN_PATH=$(find "$BIN_PATH" -type f -name "*.exe" | head -n 1)
fi
else
GODOT_BIN_PATH=$(find "$BIN_PATH" -type f -executable -name "Godot*" | head -n 1)
fi
if [[ -n "$GODOT_BIN_PATH" ]]; then
# Convert to absolute path (portable way)
if [[ "$GODOT_BIN_PATH" != /* ]]; then
GODOT_BIN_PATH_ABS="$(pwd)/$GODOT_BIN_PATH"
else
GODOT_BIN_PATH_ABS="$GODOT_BIN_PATH"
fi
echo "GODOT4=$GODOT_BIN_PATH_ABS" >> $GITHUB_ENV
echo "GODOT4_BIN=$GODOT_BIN_PATH_ABS" >> $GITHUB_ENV
echo "$(dirname "$GODOT_BIN_PATH_ABS")" >> $GITHUB_PATH
fi
fi
- name: Download and Setup Godot Templates
shell: bash
if: inputs.download_template == 'true' && (inputs.enable_cache != 'true' || steps.cache-templates.outputs.cache-hit != 'true')
run: |
GODOT_VERSION="${{ inputs.version }}"
GODOT_RELEASE="${{ inputs.release-tag }}"
if [ -z "$GODOT_RELEASE" ]; then
GODOT_RELEASE="$GODOT_VERSION"
fi
BIN_PATH="${{ inputs.bin-path }}"
MONO="${{ inputs.mono }}"
mkdir -p "$BIN_PATH/templates"
# Detect OS using GitHub Actions runner.os
if [ "${{ runner.os }}" == "Linux" ]; then
PLATFORM="linux"
elif [ "${{ runner.os }}" == "macOS" ]; then
PLATFORM="macos"
elif [ "${{ runner.os }}" == "Windows" ]; then
PLATFORM="windows"
else
echo "Unknown OS: ${{ runner.os }}"; exit 1
fi
if [[ "$MONO" == "true" ]]; then
GODOT_TEMPLATE_NAME="Godot_v${GODOT_VERSION}_mono_export_templates.tpz"
else
GODOT_TEMPLATE_NAME="Godot_v${GODOT_VERSION}_export_templates.tpz"
fi
GODOT_TEMPLATE_URL="https://github.com/${{ inputs.repo }}/releases/download/${GODOT_RELEASE}/$GODOT_TEMPLATE_NAME"
echo "Downloading $GODOT_TEMPLATE_URL"
curl -L "$GODOT_TEMPLATE_URL" -o "$BIN_PATH/templates/$GODOT_TEMPLATE_NAME"
file=$(ls "$BIN_PATH/templates")
version_dot=$(echo "$GODOT_VERSION" | sed 's/-/./')
echo "Unzipping template"
echo "Version dot: $version_dot"
# Set export path based on platform (use HOME / APPDATA, avoid hardcoded /Users)
if [[ "$PLATFORM" == "macos" ]]; then
EXPORT_PATH="$HOME/Library/Application Support/Godot/export_templates/$version_dot"
elif [[ "$PLATFORM" == "linux" ]]; then
EXPORT_PATH="$HOME/.local/share/godot/export_templates/$version_dot"
else
# On Windows prefer APPDATA, fallback to HOME
if [ -n "$APPDATA" ]; then
EXPORT_PATH="$APPDATA/Godot/export_templates/$version_dot"
else
EXPORT_PATH="$HOME/AppData/Roaming/Godot/export_templates/$version_dot"
fi
fi
mkdir -p "$EXPORT_PATH"
# Create temp dir for extraction
TEMP_DIR=$(mktemp -d)
unzip -o "$BIN_PATH/templates/$file" -d "$TEMP_DIR"
# Move contents of templates folder to export path
if [ -d "$TEMP_DIR/templates" ]; then
mv "$TEMP_DIR/templates"/* "$EXPORT_PATH/"
else
# If no templates folder, move everything
mv "$TEMP_DIR"/* "$EXPORT_PATH/"
fi
# Clean up temp dir
rm -rf "$TEMP_DIR"
ls "$EXPORT_PATH"
echo "GODOT_TEMPLATE=$EXPORT_PATH" >> $GITHUB_ENV