-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from V-Sekai/justfile
Elixir build script to export releases.
- Loading branch information
Showing
30 changed files
with
1,804 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
branches: | ||
- main | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install unzip | ||
run: choco install unzip | ||
|
||
- name: Set up Elixir | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
elixir-version: '1.12' | ||
otp-version: '24.0' | ||
|
||
- name: Run build script | ||
run: | | ||
elixir --sname build -r buildscript.iex -e "BuildScript.all" | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-artifacts | ||
path: export/export_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://bjpqewbtgif6n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://dtvbu6i7jdfpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://nqhuvjyl5bf4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://b35htbko4hv85 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://bhvqwircniboq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://dioc7tw6snepa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://b7vj4bp81hjsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://18xcph2o0pci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://bhgqer41udrla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://c6ouln8g13834 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://cubfh2dm1g350 |
1 change: 1 addition & 0 deletions
1
addons/procedural_3d_grid/core/simple_sketcher/simple_sketch.gd.uid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://dheiq8csvlle8 |
1 change: 1 addition & 0 deletions
1
addons/procedural_3d_grid/core/simple_sketcher/simple_sketch.gdshader.uid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://c46ssct7fj6pj |
1 change: 1 addition & 0 deletions
1
addons/procedural_3d_grid/core/simple_sketcher/simple_sketch_shadow.gdshader.uid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://b2cjphncghsi8 |
1 change: 1 addition & 0 deletions
1
addons/procedural_3d_grid/core/simple_sketcher/sketch_tool.gd.uid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://dl6f33628oxnt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://beag45eu5igqb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://bcc178k783hmw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://cqeyvdcoi37qr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://c351cyh3u2n31 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
defmodule BuildScript do | ||
@url "https://github.com/V-Sekai/world-editor/releases/download/latest.v-sekai-editor-187/v-sekai-world.zip" | ||
@output "v-sekai-world.zip" | ||
@extract_dir "export" | ||
@extract_dir_extracted "#{@extract_dir}/temp" | ||
@os_family :os.type() | ||
@project_name "xr_grid" | ||
@expected_hash "F7AB549A676C52DD47F9D74C9308EBBE447ABFA1513C7E563B3C15809C0CE3E3" | ||
|
||
def all do | ||
pending_files_to_delete = editor_download() | ||
editor_sign() | ||
export_stage() | ||
cleanup_pending_files(pending_files_to_delete) | ||
end | ||
def editor_download do | ||
case verify_hash() do | ||
{:ok, _hash, _message} -> | ||
IO.puts("File hash matches, skipping download.") | ||
{:error, _hash, _message} -> | ||
download() | ||
case verify_hash() do | ||
{:ok, _hash, _message} -> | ||
IO.puts("Download complete and hash verified.") | ||
{:error, _hash, _message} -> | ||
IO.puts("Hash verification failed after download.") | ||
exit(:normal) | ||
end | ||
end | ||
pending_files_to_delete = extract() | ||
create_gdignore() | ||
pending_files_to_delete | ||
end | ||
|
||
defp cleanup_pending_files(files) do | ||
IO.inspect(files, label: "Pending files to delete") | ||
end | ||
|
||
def editor_sign do | ||
make_executable() | ||
sign_app() | ||
end | ||
|
||
def download do | ||
File.mkdir_p!(@extract_dir) | ||
System.cmd("curl", ["-L", @url, "-o", "#{@extract_dir}/#{@output}"]) | ||
end | ||
|
||
def verify_hash do | ||
case File.read("#{@extract_dir}/#{@output}") do | ||
{:ok, content} -> | ||
hash = :crypto.hash(:sha256, content) |> Base.encode16() | ||
IO.puts("Computed hash: #{hash}") | ||
if hash == @expected_hash do | ||
{:ok, hash, "Hash matches"} | ||
else | ||
{:error, hash, "Hash does not match"} | ||
end | ||
_ -> | ||
{:error, nil, "File not found"} | ||
end | ||
end | ||
|
||
def extract do | ||
File.mkdir_p!(@extract_dir_extracted) | ||
case System.cmd("tar", ["-xvf", "#{@extract_dir}/#{@output}", "-C", "#{@extract_dir_extracted}", "--strip-components=1"]) do | ||
{output, 0} -> | ||
IO.puts("Extraction output:\n#{output}") | ||
extracted_files = Path.wildcard("#{@extract_dir_extracted}/**/*") | ||
extracted_files | ||
{output, _} -> | ||
IO.puts("Failed to extract file. Output:\n#{output}") | ||
exit(:normal) | ||
end | ||
end | ||
|
||
def create_gdignore do | ||
File.touch("#{@extract_dir}/.gdignore") | ||
end | ||
|
||
def make_executable do | ||
case @os_family do | ||
{:win32, :nt} -> | ||
# Windows specific commands | ||
:ok | ||
{:unix, _} -> | ||
File.chmod("#{@extract_dir_extracted}/godot.macos.editor.double.arm64", 0o755) | ||
File.chmod("#{@extract_dir_extracted}/godot.macos.template_debug.double.arm64", 0o755) | ||
File.chmod("#{@extract_dir_extracted}/godot.macos.template_release.double.arm64", 0o755) | ||
File.chmod("#{@extract_dir_extracted}/godot_macos_editor_double.app/Contents/MacOS/Godot", 0o755) | ||
end | ||
end | ||
|
||
def sign_app do | ||
case @os_family do | ||
{:win32, :nt} -> | ||
# Windows specific commands | ||
:ok | ||
{:unix, :darwin} -> | ||
System.cmd("codesign", ["--deep", "--force", "--sign", "-", "#{@extract_dir_extracted}/godot.macos.editor.double.arm64"]) | ||
System.cmd("codesign", ["--deep", "--force", "--sign", "-", "#{@extract_dir_extracted}/godot.macos.template_debug.double.arm64"]) | ||
System.cmd("codesign", ["--deep", "--force", "--sign", "-", "#{@extract_dir_extracted}/godot.macos.template_release.double.arm64"]) | ||
System.cmd("codesign", ["--deep", "--force", "--sign", "-", "#{@extract_dir_extracted}/godot_macos_editor_double.app/Contents/MacOS/Godot"]) | ||
:ok | ||
_ -> | ||
:ok | ||
end | ||
end | ||
|
||
def export_stage do | ||
editor_path = case @os_family do | ||
{:win32, :nt} -> | ||
"#{@extract_dir_extracted}/godot.windows.editor.double.x86_64.llvm.exe" | ||
{:unix, :darwin} -> | ||
"#{@extract_dir_extracted}/godot.macos.editor.double.arm64" | ||
{:unix, _} -> | ||
"#{@extract_dir_extracted}/godot.linux.editor.double.x86_64" | ||
end | ||
|
||
if File.exists?(editor_path) do | ||
File.chmod(editor_path, 0o755) | ||
version = System.cmd(editor_path, ["--version"]) |> elem(0) |> String.trim() | ||
platforms = [ | ||
{"windows", "x86_64"}, | ||
{"linuxbsd", "x86_64"}, | ||
{"macos", "arm64"}, | ||
{"web", "wasm32"}, | ||
] | ||
for {target_platform, target_arch} <- platforms do | ||
export_template(platform_name(@os_family), platform_arch(@os_family), target_platform, target_arch, version) | ||
export_platform(platform_name(@os_family), platform_arch(@os_family), target_platform, target_arch) | ||
end | ||
else | ||
IO.puts("Editor path not found: #{editor_path}") | ||
end | ||
end | ||
|
||
defp platform_name({:win32, :nt}), do: "windows" | ||
defp platform_name({:unix, :darwin}), do: "macos" | ||
defp platform_name({:unix, _}), do: "linux" | ||
|
||
defp platform_arch({:win32, :nt}), do: "x86_64" | ||
defp platform_arch({:unix, :darwin}), do: "arm64" | ||
defp platform_arch({:unix, _}), do: "x86_64" | ||
|
||
def create_version_file(version) do | ||
content = """ | ||
## AUTOGENERATED BY BUILD | ||
const BUILD_LABEL = "#{version}" | ||
const BUILD_DATE_STR = "#{:os.system_time(:seconds) |> DateTime.from_unix!() |> DateTime.to_iso8601()}" | ||
const BUILD_UNIX_TIME = #{:os.system_time(:seconds)} | ||
""" | ||
File.mkdir_p!("addons/vsk_version") | ||
File.write!("addons/vsk_version/build_constants.gd", content) | ||
end | ||
|
||
def export_template(_from_platform, _from_arch, target_platform, target_arch, version) do | ||
version = String.replace(version, ".custom_build", "") | ||
create_version_file(version) | ||
|
||
templatedir = case @os_family do | ||
{:win32, :nt} -> | ||
"#{System.get_env("USERPROFILE")}/AppData/Roaming/Godot/export_templates/#{version}/" | ||
{:unix, :darwin} -> | ||
"#{System.get_env("HOME")}/Library/Application Support/Godot/export_templates/#{version}/" | ||
{:unix, _} -> | ||
"#{System.get_env("HOME")}/.local/share/godot/export_templates/#{version}/" | ||
end | ||
File.mkdir_p!(templatedir) | ||
|
||
debug_file = case target_platform do | ||
"linuxbsd" -> "#{@extract_dir_extracted}/godot.linuxbsd.template_debug.double.#{target_arch}" | ||
"windows" -> "#{@extract_dir_extracted}/godot.windows.template_debug.double.#{target_arch}.llvm.exe" | ||
"web" -> "#{@extract_dir_extracted}/godot.web.template_debug.double.wasm32.dlink.zip" | ||
"macos" -> "#{@extract_dir_extracted}/godot_macos_double.zip" | ||
"android" -> "#{@extract_dir_extracted}/android_debug.apk" | ||
_ -> raise "Unsupported platform: #{target_platform}" | ||
end | ||
|
||
release_file = case target_platform do | ||
"linuxbsd" -> "#{@extract_dir_extracted}/godot.linuxbsd.template_release.double.#{target_arch}" | ||
"windows" -> "#{@extract_dir_extracted}/godot.windows.template_release.double.#{target_arch}.llvm.exe" | ||
"web" -> "#{@extract_dir_extracted}/godot.web.template_release.double.wasm32.dlink.zip" | ||
"macos" -> "#{@extract_dir_extracted}/godot_macos_double.zip" | ||
"android" -> "#{@extract_dir_extracted}/android_release.apk" | ||
_ -> raise "Unsupported platform: #{target_platform}" | ||
end | ||
|
||
debug_file_name = case target_platform do | ||
"linuxbsd" -> "linux_debug.#{target_arch}" | ||
"windows" -> "windows_debug_#{target_arch}.exe" | ||
"web" -> "web_dlink_nothreads_debug.zip" | ||
"macos" -> "macos_debug_#{target_arch}" | ||
"android" -> "android_debug.apk" | ||
_ -> "#{target_platform}_debug_#{target_arch}" | ||
end | ||
|
||
release_file_name = case target_platform do | ||
"linuxbsd" -> "linux_release.#{target_arch}" | ||
"windows" -> "windows_release_#{target_arch}.exe" | ||
"web" -> "web_dlink_nothreads_release.zip" | ||
"macos" -> "macos_release_#{target_arch}" | ||
"android" -> "android_release.apk" | ||
_ -> "#{target_platform}_release_#{target_arch}" | ||
end | ||
|
||
File.cp!(debug_file, "#{templatedir}/#{debug_file_name}", force: true) | ||
File.cp!(release_file, "#{templatedir}/#{release_file_name}", force: true) | ||
end | ||
|
||
def export_platform(from_platform, from_arch, target_platform, target_arch) do | ||
File.rm_rf!("#{@extract_dir}/export_#{target_platform}_#{target_arch}") | ||
File.mkdir_p!("#{@extract_dir}/export_#{target_platform}_#{target_arch}") | ||
|
||
editor_file = if from_platform == "windows" and File.exists?("#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}.llvm.exe") do | ||
"#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}.llvm.exe" | ||
else | ||
"#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}" | ||
end | ||
env = [{"ANDROID_SDK_ROOT", "#{File.cwd!()}/android_sdk"}, {"JAVA_HOME", "#{File.cwd!()}/jdk"}] | ||
arguments = ["--headless", "--path", ".", "--import"] | ||
System.cmd(editor_file, arguments, env: env) | ||
|
||
output_file = "#{@extract_dir}/export_#{target_platform}_#{target_arch}/#{@project_name}" | ||
output_file = if target_platform == "windows", do: output_file <> ".exe", else: output_file | ||
|
||
arguments = ["--headless", "--path", ".", "--export-release", target_platform, output_file] | ||
System.cmd(editor_file, arguments, env: env) | ||
IO.puts(Enum.join(arguments, " ")) | ||
|
||
case target_platform do | ||
"windows" -> | ||
System.cmd("strip", [output_file]) | ||
pdb_file = "#{@extract_dir_extracted}/godot.#{target_platform}.template_release.double.#{from_arch}.llvm.pdb" | ||
if File.exists?(pdb_file) do | ||
File.cp!(pdb_file, "#{@extract_dir}/export_#{target_platform}_#{target_arch}/#{Path.basename(pdb_file)}") | ||
else | ||
IO.puts("PDB file not found: #{pdb_file}") | ||
end | ||
_ -> :ok | ||
end | ||
end | ||
|
||
def upload_stage do | ||
upload_artifacts("windows", "x86_64") | ||
upload_artifacts("linux", "x86_64") | ||
end | ||
|
||
def upload_artifacts(platform, arch) do | ||
File.mkdir_p!("#{@extract_dir}/game") | ||
File.mkdir_p!("#{@extract_dir}/editor") | ||
File.cp_r!("#{@extract_dir_extracted}/export_#{platform}_#{arch}", "#{@extract_dir}/game") | ||
File.cp_r!("#{@extract_dir_extracted}/export_#{platform}_#{arch}/xr_grid_#{platform}_#{arch}", "#{@extract_dir}/editor/xr_grid_#{platform}_#{arch}_editor") | ||
end | ||
end |
Oops, something went wrong.