-
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.
Elixir build script to export releases.
- Loading branch information
Showing
30 changed files
with
1,788 additions
and
448 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,245 @@ | ||
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 | ||
for file <- files do | ||
File.rm_rf!(file) | ||
end | ||
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}/**/*") | ||
{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"}, | ||
{"android", "arm64"} | ||
] | ||
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, _} -> "#{System.get_env("HOME")}/Library/Application Support/Godot/export_templates/#{version}/" | ||
end | ||
File.mkdir_p!(templatedir) | ||
debug_file = if from_platform == "windows" do | ||
"#{@extract_dir_extracted}/godot.#{from_platform}.template_debug.double.#{from_arch}.llvm.exe" | ||
else | ||
"#{@extract_dir_extracted}/godot.#{from_platform}.template_debug.double.#{from_arch}" | ||
end | ||
|
||
release_file = if from_platform == "windows" do | ||
"#{@extract_dir_extracted}/godot.#{from_platform}.template_release.double.#{from_arch}.llvm.exe" | ||
else | ||
"#{@extract_dir_extracted}/godot.#{from_platform}.template_release.double.#{from_arch}" | ||
end | ||
|
||
if target_platform == "linuxbsd" do | ||
File.rename("#{templatedir}#{target_platform}_debug_#{target_arch}.exe", "#{templatedir}linux_debug_#{target_arch}.exe") | ||
File.rename("#{templatedir}#{target_platform}_release_#{target_arch}.exe", "#{templatedir}linux_release_#{target_arch}.exe") | ||
end | ||
if target_platform == "windows" do | ||
File.rename("#{templatedir}#{target_platform}_debug_#{target_arch}.exe", "#{templatedir}windows_debug_#{target_arch}.exe") | ||
File.rename("#{templatedir}#{target_platform}_release_#{target_arch}.exe", "#{templatedir}windows_release_#{target_arch}.exe") | ||
end | ||
if @os_family == {:win32, :nt} do | ||
user_profile = System.get_env("USERPROFILE") | ||
if File.exists?(debug_file) do | ||
File.cp!(debug_file, "#{user_profile}/AppData/Roaming/Godot/export_templates/#{version}/windows_debug_#{target_arch}.exe", force: true) | ||
else | ||
IO.puts("Debug file not found: #{debug_file}") | ||
end | ||
if File.exists?(release_file) do | ||
File.cp!(release_file, "#{user_profile}/AppData/Roaming/Godot/export_templates/#{version}/windows_release_#{target_arch}.exe", force: true) | ||
else | ||
IO.puts("Release file not found: #{release_file}") | ||
end | ||
end | ||
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 | ||
|
||
arguments = ["--headless", "--path", ".", "--import"] | ||
System.cmd(editor_file, arguments) | ||
|
||
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) | ||
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_extracted}/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.