Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 38d3ec2a6601c49886840c4bb6bf14d0c6a26807
Author: Kiri <[email protected]>
Date:   Sun Oct 20 17:25:38 2024 -0700

    Added the thing with the stuff.

commit f033327
Author: Kiri <[email protected]>
Date:   Sun Oct 20 17:15:15 2024 -0700

    BLAH BLAH BLAH BLAH

commit 311a9ff
Author: Kiri <[email protected]>
Date:   Sun Oct 20 17:04:48 2024 -0700

    I hate this.

commit 915dc06
Author: Kiri <[email protected]>
Date:   Sun Oct 20 16:52:27 2024 -0700

    Attempt again.

commit 509edf0
Author: Kiri <[email protected]>
Date:   Sun Oct 20 16:48:35 2024 -0700

    test again  blaaaaaah

commit 684e9b1
Author: Kiri <[email protected]>
Date:   Sun Oct 20 16:42:03 2024 -0700

    Testing another thing.

commit decab05
Author: Kiri <[email protected]>
Date:   Sun Oct 20 16:36:23 2024 -0700

    Automation test 1.

commit 26cb9e7
Author: Kiri <[email protected]>
Date:   Sun Oct 20 14:38:56 2024 -0700

    Pre-stream build work.

commit e6a128e
Author: Kiri <[email protected]>
Date:   Sun Oct 13 18:52:42 2024 -0700

    Initial (incomplete) work on build automation.
  • Loading branch information
ExpiredPopsicle committed Oct 21, 2024
1 parent 31753d9 commit 5298a57
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 47 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build

# on:
# push:
# pull_request:
# release:
# types: [published]

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
container: debian:bookworm

steps:

# Create the release, I guess?
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: Auto generated release
draft: false
prerelease: false

# Install git.
- name: Git
run: |
apt-get update
apt-get install -y git
# check out git repository.
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

# Do the build.
- name: Build
run: |
Build/run_this_inside_debian_container_to_build.bsh
- name: Upload Assets to Release with a wildcard
uses: csexton/release-asset-action@v3
with:
pattern: "Build/Builds/Dist/SnekStudio_*"
github-token: ${{ secrets.GITHUB_TOKEN }}
release-url: ${{ steps.create_release.outputs.upload_url }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ addons/KiriPythonRPCWrapper/Wheels

# Stuff we removed right before release
StuffToRemove

# Extra junk from the build.
Build/build_vars.sh
Build/Builds
Empty file added Build/Builds/.gdignore
Empty file.
60 changes: 60 additions & 0 deletions Build/DownloadPythonRequirements.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# FIXME: This file is kinda rough. We should probably clean it up. But we need
# build automation NOW.

extends SceneTree

var updater : KiriPythonBuildUpdater = null
var frame_count = 0

func _initialize():
pass

func _process(_delta):

if frame_count == 0:

# Instantiate the updater.
updater = load("res://addons/KiriPythonRPCWrapper/UpdateUI/PythonBuildUpdateUI.tscn").instantiate()
root.add_child(updater)

# Start Python downloads per-platform.
updater._start_github_download("Windows")
updater._start_github_download("Linux")
# FIXME: MacOS.

for platform in updater._current_downloads.keys():
var download_request : HTTPRequest = updater._current_downloads[platform]
download_request.request_completed.connect(
func(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray):
if result == HTTPRequest.RESULT_SUCCESS and response_code == 200:
print("Download finished (", response_code, ") for platform: ", platform)
else:
push_error("Download failed (", result, ") (", response_code, ") for platform: ", platform)
quit(1))

# FIXME: Add MacOS.
if updater._check_platform_file_ready("Windows") and \
updater._check_platform_file_ready("Linux"):

# Download pip requirements.
var succeeded = true
if not updater.download_platform_requirements("Windows", true):
succeeded = false
if not updater.download_platform_requirements("Linux", true):
succeeded = false
# FIXME: MacOS.

if not succeeded:
push_error("Something went wrong!")
quit(1)

# We're done! Wrap it up.
updater.queue_free()
return true

# Keep going.
frame_count += 1
return false

func _finalize():
pass
7 changes: 7 additions & 0 deletions Build/WriteBuildVars.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends SceneTree

func _initialize():
var f : FileAccess = FileAccess.open("res://Build/build_vars.sh", FileAccess.WRITE)
f.store_string("VERSION=" + ProjectSettings.get("application/config/version") + "\n")
f.close()
quit(0)
93 changes: 93 additions & 0 deletions Build/build.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

GODOT_RELEASE_URL="https://github.com/godotengine/godot/releases/download/4.3-stable/Godot_v4.3-stable_linux.x86_64.zip"
GODOT_EXPORT_TEMPLATE_URL="https://github.com/godotengine/godot/releases/download/4.3-stable/Godot_v4.3-stable_export_templates.tpz"
GODOT_EXPORT_TEMPLATE_VERSION="4.3.stable"

set -e

cd "$(dirname "$0")/.."
pushd .

# Download Godot.
cd Build
echo "Downloading Godot..."
if [ \! -e godot.zip ]; then
curl -sfL -o godot.zip "${GODOT_RELEASE_URL}"
fi

# Download templates.
echo "Downloading export templates..."
if [ \! -e godot_templates.tpz ]; then
curl -sfL -o godot_templates.tpz "${GODOT_EXPORT_TEMPLATE_URL}"
fi

# Extract Godot.
echo "Extracting Godot..."
if [ \! -e GodotBinary ]; then
mkdir GodotBinary
fi
cd GodotBinary
unzip -o ../godot.zip
cd ..

# Extract export templates.
echo "Extracting export templates..."
mkdir -p "$HOME/.local/share/godot/export_templates/${GODOT_EXPORT_TEMPLATE_VERSION}"
unzip -j godot_templates.tpz -d "$HOME/.local/share/godot/export_templates/${GODOT_EXPORT_TEMPLATE_VERSION}"


GODOT="$(realpath "$(ls GodotBinary/*.x86_64)")"
echo "Godot binary path: ${GODOT}"

popd




# Write out build variables and read them in.
"${GODOT}" \
--disable-render-loop \
--no-header \
--headless --script \
Build/WriteBuildVars.gd
source Build/build_vars.sh



# We have to do this or it can't see a bunch of the classes.

"${GODOT}" --headless --path . \
--import

# Fetch all Python dependencies.

"${GODOT}" --headless --path . \
--script Build/DownloadPythonRequirements.gd


# Actually do the builds.

"${GODOT}" --headless --path . \
--export-release "Linux/X11" Build/Builds/SnekStudio_Linux/snekstudio

"${GODOT}" --headless --path . \
--export-debug "Windows Desktop" Build/Builds/SnekStudio_Windows/snekstudio.exe

# Package them.

pushd .
cd Build/Builds
tar czvf "SnekStudio_Linux_${VERSION}.tar.gz" SnekStudio_Linux
zip -r "SnekStudio_Windows_${VERSION}.zip" SnekStudio_Windows

# Make the output directory

if [ \! -e Dist ]; then
mkdir Dist
fi

# Move stuff into it.

mv -f *.tar.gz *.zip Dist/

11 changes: 11 additions & 0 deletions Build/build_inside_docker.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# This is NOT a script to be run inside a container. It is a script that runs something inside a container

cd "$(dirname "$0")/.."

#echo "docker run -v /build:. debian"
docker run --rm \
-v "$(realpath .)":/build \
debian \
"/build/Build/run_this_inside_debian_container_to_build.bsh"
10 changes: 10 additions & 0 deletions Build/run_this_inside_debian_container_to_build.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

cd "$(dirname "$0")"

bash ./setup_debian_container.bsh

bash ./build.bsh

9 changes: 9 additions & 0 deletions Build/setup_debian_container.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

apt-get update

apt-get install -y \
curl unzip zip libfontconfig1

27 changes: 20 additions & 7 deletions addons/KiriPythonRPCWrapper/UpdateUI/PythonBuildUpdateUI.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@tool
extends Control
class_name KiriPythonBuildUpdater

# These names must match the output from
# KiriPythonBuildWrangler.get_host_os_name().
Expand Down Expand Up @@ -181,16 +182,18 @@ func _update_platform_dropdowns():

func _update_download_button_progress():
for platform_name in _current_downloads.keys():

var download_percent : float = 100.0 * \
_current_downloads[platform_name].get_downloaded_bytes() / \
_current_downloads[platform_name].get_body_size()

_platform_buttons[platform_name].disabled = true

if _current_downloads[platform_name].get_body_size() == -1:
# We still don't know what the remote file size is.
_platform_buttons[platform_name].text = "Starting..."
else:
# Change the button text to show a download percentage.
var download_percent : float = 100.0 * \
_current_downloads[platform_name].get_downloaded_bytes() / \
_current_downloads[platform_name].get_body_size()
_platform_buttons[platform_name].text = "Downloading: " + \
str(int(download_percent)) + "%"

Expand Down Expand Up @@ -446,15 +449,23 @@ func _get_latest_version_releaseinfo_completed(
%Button_UpdateReleaseAssets.disabled = false
_cleanup_request()

func _on_button_download_requirements_pressed(platform_name) -> void:
func _on_button_download_requirements_pressed(platform_name : String) -> void:
download_platform_requirements(platform_name)
_update_platform_ui()

func download_platform_requirements(platform_name : String, automated : bool = false) -> bool:

_load_platform_status()

var download_path : String = get_script().resource_path.get_base_dir().path_join("../Wheels")

print("Unpacking Python...")
var python_instance : KiriPythonWrapperInstance = KiriPythonWrapperInstance.new("")
if python_instance.setup_python(true) == false:
OS.alert("You need to download a Python build for your host platform first!")
if not automated:
OS.alert("You need to download a Python build for your host platform first!")
push_error("You need to download a Python build for your host platform first!")
return false

print("Writing requirements file...")
DirAccess.make_dir_recursive_absolute(download_path)
Expand Down Expand Up @@ -500,13 +511,15 @@ func _on_button_download_requirements_pressed(platform_name) -> void:

# Handle errors or write a success indicator.
if pip_download_return != 0:
OS.alert("Pip failed (platform: " + platform_name + "): " + str(output))
if not automated:
OS.alert("Pip failed (platform: " + platform_name + "): " + str(output))
push_error("Pip failed (platform: ", platform_name, "): ", output)
return false
else:
var last_requirements_file : FileAccess = \
FileAccess.open(
this_platform_download_path.path_join("requirements.txt"),
FileAccess.WRITE)
last_requirements_file.store_string(_platform_status["requirements"])

_update_platform_ui()
return true
Loading

0 comments on commit 5298a57

Please sign in to comment.