with one click
godot-setup-export
用于设置 Godot 项目的多平台导出,配置导出预设、图标、功能标签、构建脚本或 CI/CD 流水线
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
用于设置 Godot 项目的多平台导出,配置导出预设、图标、功能标签、构建脚本或 CI/CD 流水线
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | godot-setup-export |
| version | 1.0.0 |
| displayName | Godot 导出配置 |
| description | 用于设置 Godot 项目的多平台导出,配置导出预设、图标、功能标签、构建脚本或 CI/CD 流水线 |
| author | Godot Superpowers Team |
| license | MIT |
| repository | https://github.com/anomalyco/godot-superpowers |
| homepage | https://github.com/anomalyco/godot-superpowers/tree/main/mini-skills/godot-setup-export |
| category | Godot |
| type | tool |
| difficulty | intermediate |
| audience | developers |
| keywords | ["godot","export","build","ci/cd","github-actions","cross-platform","windows","mac","linux","web","mobile"] |
| platforms | ["linux","macos","windows"] |
自动化 Godot 项目的多平台导出配置。
设置导出是一项繁琐、容易出错且需要平台特定知识的工作。本技能生成导出预设、配置图标和启动画面、设置功能标签、创建构建脚本,并与 CI/CD 流水线集成。
适合使用:
不适合用于:
| 任务 | 工具/方法 |
|---|---|
| 生成导出预设 | godot --headless --generate-export-presets |
| 设置图标 | export_presets.cfg icon 字段 |
| 配置功能标签 | project.godot [feature] 部分 |
| 自动化构建 | GitHub Actions 工作流 |
| 自定义脚本 | export_presets.cfg custom_template/release |
Windows 桌面:
[preset.0]
name="Windows Desktop"
platform="Windows Desktop"
export_filter="all_resources"
include_filter=""
export_files=[]
include_filter=""
export_path="builds/windows/Game.exe"
custom_features=""
export_filter="scenes"
export_files=PackedStringArray("res://main.tscn")
[preset.0.options]
custom_template/release=""
custom_template/debug=""
binary_format/architecture="x86_64"
codesign/enable=false
icon="res://assets/icons/windows_icon.ico"
macOS:
[preset.1]
name="macOS"
platform="macOS"
export_filter="all_resources"
export_path="builds/macos/Game.zip"
[preset.1.options]
binary_format/architecture="universal"
codesign/certificate_file=""
codesign/identity=""
icon="res://assets/icons/mac_icon.icns"
export/distribution_type=1
Linux:
[preset.2]
name="Linux"
platform="Linux"
export_filter="all_resources"
export_path="builds/linux/Game.x86_64"
[preset.2.options]
binary_format/architecture="x86_64"
custom_template/release=""
icon="res://assets/icons/linux_icon.png"
Web:
[preset.3]
name="Web"
platform="Web"
export_filter="all_resources"
export_path="builds/web/index.html"
[preset.3.options]
custom_template/release=""
custom_template/debug=""
variant/size_limit=16777216
vram_texture_compression/for_desktop=true
html/canvas_resize_policy=2
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
Android:
[preset.4]
name="Android"
platform="Android"
export_filter="all_resources"
export_path="builds/android/Game.apk"
[preset.4.options]
gradle_build/use_gradle_build=false
gradle_build/export_format=0
gradle_build/min_sdk=21
gradle_build/target_sdk=33
version/code=1
version/name="1.0"
architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
keystore/debug=""
keystore/debug_user=""
keystore/debug_password=""
keystore/release=""
keystore/release_user=""
keystore/release_password=""
icon/export_identifier="com.example.game"
iOS:
[preset.5]
name="iOS"
platform="iOS"
export_filter="all_resources"
export_path="builds/ios/Game.xcodeproj"
[preset.5.options]
binary_format/architecture=1
application/app_store_team_id=""
application/bundle_identifier="com.example.game"
application/short_version="1.0"
application/version="1.0"
application/icon_interpolation=4
application/export_method_release=0
application/targeted_device_family=2
application/remove_simulator_arch=true
codesign/codesign=1
codesign/identity=""
codesign/provisioning_profile=""
| 平台 | 格式 | 尺寸 | 说明 |
|---|---|---|---|
| Windows | .ico | 256x256 | 多分辨率 ICO 文件 |
| macOS | .icns | 1024x1024 | Apple 图标格式 |
| Linux | .png | 256x256 | 标准 PNG |
| Web | .png | 512x512 | 用于 favicon/PWA |
| Android | .png | 512x512 | 支持自适应图标 |
| iOS | .png | 1024x1024 | App Store 图标 |
project.godot:
[application]
config/name="Game Name"
config/description="Game description"
run/main_scene="res://scenes/main.tscn"
config/features=PackedStringArray("4.2", "Mobile")
boot_splash/bg_color=Color(0.14, 0.14, 0.14, 1)
boot_splash/image="res://assets/splash/splash_screen.png"
boot_splash/fullsize=true
boot_splash/use_filter=true
[display]
window/size/viewport_width=1920
window/size/viewport_height=1080
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"
使用功能标签实现平台特定行为:
[feature_tags]
editor=false
standalone=true
debug=false
release=true
; Platform-specific features
windows=false
macos=false
linux=false
android=false
ios=false
web=false
mobile=false
desktop=false
在 GDScript 中使用:
# Platform-specific code
if OS.has_feature("mobile"):
# Mobile touch controls
touch_controls.visible = true
elif OS.has_feature("desktop"):
# Desktop keyboard/mouse
touch_controls.visible = false
# Debug vs release
if OS.has_feature("debug"):
show_debug_info()
enable_cheats()
@echo off
set PROJECT_PATH=%~dp0
set GODOT_PATH="C:\Program Files\Godot\Godot_v4.x.exe"
set BUILD_DIR=%PROJECT_PATH%builds\windows
if not exist %BUILD_DIR% mkdir %BUILD_DIR%
%GODOT_PATH% --headless --path %PROJECT_PATH% --export-release "Windows Desktop" "%BUILD_DIR%\Game.exe"
if %ERRORLEVEL% NEQ 0 (
echo Export failed!
exit /b 1
)
echo Export complete: %BUILD_DIR%\Game.exe
#!/bin/bash
set -e
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GODOT_PATH="/usr/bin/godot"
BUILD_DIR="$PROJECT_DIR/builds"
mkdir -p "$BUILD_DIR/linux" "$BUILD_DIR/macos" "$BUILD_DIR/web"
# Linux
$GODOT_PATH --headless --path "$PROJECT_DIR" \
--export-release "Linux" "$BUILD_DIR/linux/Game.x86_64"
# macOS
$GODOT_PATH --headless --path "$PROJECT_DIR" \
--export-release "macOS" "$BUILD_DIR/macos/Game.zip"
# Web
$GODOT_PATH --headless --path "$PROJECT_DIR" \
--export-release "Web" "$BUILD_DIR/web/index.html"
echo "All exports complete!"
$ProjectPath = $PSScriptRoot
$GodotPath = "C:\Program Files\Godot\Godot_v4.x.exe"
$BuildDir = Join-Path $ProjectPath "builds"
New-Item -ItemType Directory -Force -Path $BuildDir | Out-Null
$Presets = @(
@{ Name = "Windows Desktop"; Path = "$BuildDir\windows\Game.exe" },
@{ Name = "Linux"; Path = "$BuildDir\linux\Game.x86_64" }
)
foreach ($Preset in $Presets) {
$Dir = Split-Path $Preset.Path -Parent
New-Item -ItemType Directory -Force -Path $Dir | Out-Null
& $GodotPath --headless --path $ProjectPath `
--export-release $Preset.Name $Preset.Path
if ($LASTEXITCODE -ne 0) {
Write-Error "Export failed for $($Preset.Name)"
exit 1
}
}
Write-Host "Exports complete!"
name: Build and Export
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
env:
GODOT_VERSION: 4.2.1
EXPORT_NAME: game-name
jobs:
export-windows:
name: Windows Export
runs-on: ubuntu-22.04
container:
image: barichello/godot-ci:4.2.1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Godot
run: |
mkdir -p ~/.config/godot/
echo "[export_presets]" > ~/.config/godot/editor_settings-4.tres
- name: Windows Build
run: |
mkdir -p build/windows
godot --headless --verbose --export-release "Windows Desktop" ./build/windows/$EXPORT_NAME.exe
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: windows
path: build/windows
export-linux:
name: Linux Export
runs-on: ubuntu-22.04
container:
image: barichello/godot-ci:4.2.1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Linux Build
run: |
mkdir -p build/linux
godot --headless --verbose --export-release "Linux" ./build/linux/$EXPORT_NAME.x86_64
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: linux
path: build/linux
export-web:
name: Web Export
runs-on: ubuntu-22.04
container:
image: barichello/godot-ci:4.2.1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Web Build
run: |
mkdir -p build/web
godot --headless --verbose --export-release "Web" ./build/web/index.html
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: web
path: build/web
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/web
export-android:
name: Android Export
runs-on: ubuntu-22.04
container:
image: barichello/godot-ci:4.2.1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Android SDK
run: |
mkdir -p ~/.config/godot/
echo "[export_presets]" > ~/.config/godot/editor_settings-4.tres
- name: Android Build
run: |
mkdir -p build/android
godot --headless --verbose --export-release "Android" ./build/android/$EXPORT_NAME.apk
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: android
path: build/android
export-macos:
name: macOS Export
runs-on: ubuntu-22.04
container:
image: barichello/godot-ci:4.2.1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: macOS Build
run: |
mkdir -p build/macos
godot --headless --verbose --export-release "macOS" ./build/macos/$EXPORT_NAME.zip
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: macos
path: build/macos
create-release:
name: Create Release
needs: [export-windows, export-linux, export-web, export-android, export-macos]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
windows/*.exe
linux/*
android/*.apk
macos/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
| 错误 | 解决方案 |
|---|---|
| 缺少导出预设文件 | 运行一次 Godot 编辑器生成或复制模板 |
| 导出路径格式错误 | 所有平台使用正斜杠 |
| 图标无法加载 | 确保图标文件存在于指定路径 |
| Android 密钥库错误 | 设置调试密钥库或配置发布密钥库 |
| Web 导出失败 | 检查导出模板是否已安装 |
| CI/CD 找不到 Godot | 使用 godot-ci Docker 镜像或手动安装 Godot |
# Manual export via Godot editor
# 1. Open Project > Export
# 2. Click Add for each platform
# 3. Configure each preset manually
# 4. Click Export Project for each
# 5. Repeat every time you want to build
# export_presets.cfg - generated once, committed to repo
[preset.0]
name="Windows Desktop"
export_path="builds/windows/Game.exe"
...
[preset.1]
name="macOS"
export_path="builds/macos/Game.zip"
...
[preset.2]
name="Linux"
export_path="builds/linux/Game.x86_64"
...
[preset.3]
name="Web"
export_path="builds/web/index.html"
...
# Then run: ./build.sh or let GitHub Actions handle it automatically
my-game/
├── project.godot
├── export_presets.cfg # All export configurations
├── .github/
│ └── workflows/
│ └── export.yml # CI/CD pipeline
├── assets/
│ └── icons/
│ ├── windows_icon.ico
│ ├── mac_icon.icns
│ ├── linux_icon.png
│ ├── android_icon.png
│ └── ios_icon.png
├── scripts/
│ └── build.sh # Local build script
└── builds/ # Output directory (gitignored)
├── windows/
├── macos/
├── linux/
├── web/
└── android/
# Export release build
godot --headless --export-release "Preset Name" "output/path"
# Export debug build
godot --headless --export-debug "Preset Name" "output/path"
# Export with pack file only (no executable)
godot --headless --export-pack "Preset Name" "output.pck"
# Export from specific project path
godot --headless --path /path/to/project --export-release "Preset" "output"
# Verbose output for debugging
godot --headless --verbose --export-release "Preset" "output"
windows_x86_64.exe.ico 格式macos.zipweb.zip提交到仓库:
export_presets.cfg - 包含所有导出配置.github/workflows/export.yml - CI/CD 流水线build.sh、build.bat、build.ps1)添加到 .gitignore:
builds/
*.tmp
*.import
export_presets.cfg 是否存在于项目根目录当 Godot 代码中存在通过 get_node()、get_parent() 或直接引用产生的紧耦合依赖时使用。 检测耦合模式并将其转换为基于 Signal 的通信方式。组件变得独立、可测试且可复用。 在改进架构的同时精确保留原有行为。
当 Godot 代码中存在相互冲突的操作导致未定义行为时使用。检测同一属性在多处设置 (_ready、_process、代码+编辑器)、同一 Signal 多次连接、冲突的物理模式、 竞争的动画等问题。自动通过明确的所有权归属解决冲突。
用于创建带有自定义面板、停靠栏和工具的 Godot 编辑器插件。生成 plugin.cfg 配置、 EditorPlugin 脚本模板、自定义编辑器 UI 组件,并集成 ProjectSettings。按照 Godot 4.x 最佳实践创建完整的插件结构。
当 Godot 代码中存在硬编码的游戏数据(如 const 数组、字典或内嵌值)时使用。检测内联数据 如敌人属性、物品定义、关卡配置等。自动提取为 .tres Resource 文件,使数据在编辑器中 可见、易于修改,并支持数据驱动的设计。
当构建 Godot 功能时,代码使用 .new() 创建节点而非使用场景时触发。 检测 Timer.new()、Area2D.new()、Sprite2D.new() 等代码创建的对象。 自动生成 .tscn 场景文件,更新父脚本使用 @onready 引用,并创建可复用的组件库。
当 Godot 项目在编辑器(.tscn)和代码(.gd)之间存在位置冲突、相机跟随背景、 或运行时位置与编辑器预览不匹配时使用。编排所有 3 个位置同步子技能: sync-static-positions、sync-camera-positions 和 sync-parallax。 每个操作针对特定的位置冲突类型。