Skip to content

Commit

Permalink
chore: add .aab artifact, change logo and package name (#354)
Browse files Browse the repository at this point in the history
* chore: bigger logo and set params for export presets

* add library to the artifacts

* test build .aab

* add persistent cache for self-hosted runners

* try fix

* try fix 2

* fix dependencies

* test

* test

* test

* test bigrunner

* test ubuntu-runner

* test bigrunner

* Update .github/workflows/android-build.yml

Signed-off-by: Lean Mendoza <leandro@decentraland.org>

* Update .github/workflows/android-build.yml

Signed-off-by: Lean Mendoza <leandro@decentraland.org>

---------

Signed-off-by: Lean Mendoza <leandro@decentraland.org>
  • Loading branch information
leanmendoza authored Mar 4, 2024
1 parent 66f6dd4 commit 3e86109
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 32 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ name: Android Build

jobs:
build:
runs-on: self-hosted-ubuntu
runs-on: bigrunner
container:
image: docker://kuruk/dcl-godot-android-builder:latest
volumes:
- /home/user/.cache/devgodot:/github/home/.cache/devgodot

steps:
- uses: actions/checkout@v4
Expand All @@ -33,9 +35,18 @@ jobs:
- name: Build
run: |
bash build-android-apk.sh
# if libdecentraland_godot_lib.so does not exist, the build failed, nothing to upload
- name: Copy artifacts
if: success() || failure()
run: |
mkdir -p android-artifacts
mv godot/lib/android/arm64/libdecentraland_godot_lib.so android-artifacts/
mv android.apk android-artifacts/ || true
mv android-unsigned.aab android-artifacts/ || true
- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: Android APK
path: |
android.apk
path: android-artifacts/
24 changes: 21 additions & 3 deletions build-android-apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,28 @@ export GODOT_ANDROID_KEYSTORE_DEBUG_PATH=/opt/debug.keystore
export GODOT_ANDROID_KEYSTORE_DEBUG_USER=androiddebugkey
export GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD=android

echo "Export Godot APK"
cd ${EXPLORER_PATH}/godot/

${EXPLORER_PATH}/.bin/godot/godot4_bin \
-e --headless --export-debug Android ${EXPLORER_PATH}/android.apk
# Build the .aab without x86_64 architecture
echo "Export Godot android.apk"
${EXPLORER_PATH}/.bin/godot/godot4_bin -e --headless --export-debug Android ${EXPLORER_PATH}/android.apk || true


# Build the .aab without x86_64 architecture
echo "Setting up to export godot .aab"
# Use aab
sed -i 's/gradle_build\/export_format=0/gradle_build\/export_format=1/' ${EXPLORER_PATH}/godot/export_presets.cfg
# remove x86_64
sed -i 's/architectures\/x86_64=true/architectures\/x86_64=false/' ${EXPLORER_PATH}/godot/export_presets.cfg
# remove signed
sed -i 's/package\/signed=true/package\/signed=false/' ${EXPLORER_PATH}/godot/export_presets.cfg

# copy debug libraries
cp -r ${EXPLORER_PATH}/godot/android/build/libs/debug/arm64-v8a ${EXPLORER_PATH}/godot/android/build/libs/release/arm64-v8a
cp -r ${EXPLORER_PATH}/godot/android/build/libs/debug/libwebrtc.jar ${EXPLORER_PATH}/godot/android/build/libs/release/libwebrtc.jar

# Build the .aab without x86_64 architecture
echo "Export Godot AAB"
${EXPLORER_PATH}/.bin/godot/godot4_bin -e --headless --export-release Android ${EXPLORER_PATH}/android-unsigned.aab || true

echo "Finished"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="4eac82390be376f53b4f92e28f3b3ee6"
dest_md5="3e8c84ffa647348c948ac91db818bdcf"
source_md5="e60045b7d0d816dca3f0941c7747ee5c"
dest_md5="39f79f3330791e099a0edb2bce5760a9"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="2e461242100f90b03ddb844392efd40b"
source_md5="d24a29091258869a9145a333411adc96"
dest_md5="37b0167aecebe79077276640b80b9824"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="f8cda194e8450cc330bcc3ca8073ef22"
source_md5="8c7551ef70767c549a1acebc8d1f7ad5"
dest_md5="8c313d8be829f5387c6e91044b992ad4"

2 changes: 2 additions & 0 deletions godot/decentraland_godot_lib.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ linux.release.x86_64 = "res://lib/libdecentraland_godot_lib.so"
macos.debug = "res://lib/libdecentraland_godot_lib.dylib"
macos.release = "res://lib/libdecentraland_godot_lib.dylib"
android.debug.arm64 = "res://lib/android/arm64/libdecentraland_godot_lib.so"
android.release.arm64 = "res://lib/android/arm64/libdecentraland_godot_lib.so"
android.debug.x86_64 = "res://lib/android/x86_64/libdecentraland_godot_lib.so"
android.release.x86_64 = "res://lib/android/x86_64/libdecentraland_godot_lib.so"
ios.debug.arm64 = "res://lib/ios/libdecentraland_godot_lib.dylib"
ios.release.arm64 = "res://lib/ios/libdecentraland_godot_lib.dylib"
Binary file modified godot/decentraland_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions godot/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ architectures/x86=false
architectures/x86_64=true
version/code=1
version/name="1.0"
package/unique_name="org.godotengine.decentralandgodot"
package/name=""
package/unique_name="org.decentraland.godotexplorer"
package/name="Decentraland"
package/signed=true
package/app_category=2
package/retain_data_on_uninstall=false
Expand Down Expand Up @@ -438,7 +438,7 @@ application/export_method_debug=1
application/code_sign_identity_release=""
application/export_method_release=0
application/targeted_device_family=2
application/bundle_identifier="com.decentraland.godot"
application/bundle_identifier="org.decentraland.godotexplorer"
application/signature=""
application/short_version="1.0"
application/version="1.0"
Expand Down
4 changes: 2 additions & 2 deletions godot/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ config_version=5

[application]

config/name="Decentraland Godot Rust"
config/description="Decentraland Godot Client - Protocol Squad"
config/name="Decentraland"
config/description="Decentraland Explorer powered by Decentraland DAO"
run/main_scene="res://src/main.tscn"
config/features=PackedStringArray("4.2")
config/icon="res://decentraland_logo.png"
Expand Down
2 changes: 1 addition & 1 deletion rust/decentraland-godot-lib/ios-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export RUSTY_V8_MIRROR=https://github.com/leanmendoza/rusty_v8/releases/download

GN_ARGS=use_custom_libcxx=false RUST_BACKTRACE=full cargo build --target aarch64-apple-ios -vv --verbose --release

mkdir ../../godot/lib/ios/ || true
mkdir -p ../../godot/lib/ios/
cp target/aarch64-apple-ios/release/libdecentraland_godot_lib.dylib ../../godot/lib/ios/libdecentraland_godot_lib.dylib
3 changes: 2 additions & 1 deletion rust/xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ zip = "0.5.*"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls", "blocking"] }
serde_json = { version = "1.0.92", features = ["raw_value"] }
glob = "*"
tokio = { version = "1.26.0", features = ["sync", "rt-multi-thread", "net"] }
tokio = { version = "1.26.0", features = ["sync", "rt-multi-thread", "net"] }
directories = "5.0.1"
2 changes: 2 additions & 0 deletions rust/xtask/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pub const GODOT4_BIN_BASE_URL: &str =

pub const GODOT4_EXPORT_TEMPLATES_BASE_URL: &str =
"https://github.com/godotengine/godot/releases/download/4.2.1-stable/Godot_v4.2.1-stable_export_templates.tpz";

pub const GODOT_CURRENT_VERSION: &str = "4.2.1";
11 changes: 9 additions & 2 deletions rust/xtask/src/export.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::{fs, io, path::Path};

use crate::{
consts::{BIN_FOLDER, EXPORTS_FOLDER, GODOT4_EXPORT_TEMPLATES_BASE_URL, GODOT_PROJECT_FOLDER},
consts::{
BIN_FOLDER, EXPORTS_FOLDER, GODOT4_EXPORT_TEMPLATES_BASE_URL, GODOT_CURRENT_VERSION,
GODOT_PROJECT_FOLDER,
},
copy_files::copy_ffmpeg_libraries,
install_dependency::{self, download_and_extract_zip, set_executable_permission},
path::adjust_canonicalization,
Expand Down Expand Up @@ -127,7 +130,11 @@ pub fn export() -> Result<(), anyhow::Error> {

pub fn prepare_templates() -> Result<(), anyhow::Error> {
let dest_path = format!("{BIN_FOLDER}godot/templates");
download_and_extract_zip(GODOT4_EXPORT_TEMPLATES_BASE_URL, dest_path.as_str())?;
download_and_extract_zip(
GODOT4_EXPORT_TEMPLATES_BASE_URL,
dest_path.as_str(),
Some(format!("{GODOT_CURRENT_VERSION}.export-templates.zip")),
)?;

Ok(())
}
56 changes: 52 additions & 4 deletions rust/xtask/src/install_dependency.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use directories::ProjectDirs;
use flate2::read::GzDecoder;
use reqwest::blocking::Client;
use serde_json::Value;
Expand All @@ -11,7 +12,10 @@ use zip::ZipArchive;
use crate::download_file::download_file;
use crate::export::prepare_templates;

use crate::consts::{BIN_FOLDER, GODOT4_BIN_BASE_URL, PROTOC_BASE_URL, RUST_LIB_PROJECT_FOLDER};
use crate::consts::{
BIN_FOLDER, GODOT4_BIN_BASE_URL, GODOT_CURRENT_VERSION, PROTOC_BASE_URL,
RUST_LIB_PROJECT_FOLDER,
};

fn create_directory_all(path: &Path) -> io::Result<()> {
if let Some(parent) = path.parent() {
Expand Down Expand Up @@ -84,13 +88,51 @@ fn get_protoc_url() -> Option<String> {
Some(format!("{PROTOC_BASE_URL}{os_url}"))
}

pub fn download_and_extract_zip(url: &str, destination_path: &str) -> Result<(), anyhow::Error> {
println!("Downloading {url:?}");
fn get_existing_cached_file(persistent_cache: Option<String>) -> Option<String> {
let persistent_cache = persistent_cache?;
let dirs = ProjectDirs::from("org", "decentraland", "devgodot")?;

fs::create_dir_all(dirs.cache_dir()).ok()?;
let cache_file_path = dirs.cache_dir().join(persistent_cache);
if cache_file_path.exists() {
Some(cache_file_path.to_str().unwrap().to_string())
} else {
None
}
}

fn get_persistent_path(persistent_cache: Option<String>) -> Option<String> {
let persistent_cache = persistent_cache?;
let dirs = ProjectDirs::from("org", "decentraland", "devgodot")?;
fs::create_dir_all(dirs.cache_dir()).ok()?;
let cache_file_path = dirs.cache_dir().join(persistent_cache);
Some(cache_file_path.to_str().unwrap().to_string())
}

pub fn download_and_extract_zip(
url: &str,
destination_path: &str,
persistent_cache: Option<String>,
) -> Result<(), anyhow::Error> {
if Path::new("./tmp-file.zip").exists() {
fs::remove_file("./tmp-file.zip")?;
}

download_file(url, "./tmp-file.zip")?;
// If the cached file exist, use it
if let Some(already_existing_file) = get_existing_cached_file(persistent_cache.clone()) {
println!("Getting cached file of {url:?}");
fs::copy(already_existing_file, "./tmp-file.zip")?;
} else {
println!("Downloading {url:?}");
download_file(url, "./tmp-file.zip")?;

// when the download is done, copy the file to the persistent cache if it applies
if let Some(persistent_cache) = persistent_cache {
let persistent_path = get_persistent_path(Some(persistent_cache)).unwrap();
fs::copy("./tmp-file.zip", persistent_path)?;
}
}

let file = File::open("./tmp-file.zip")?;
let mut zip_archive = ZipArchive::new(file)?;

Expand Down Expand Up @@ -154,22 +196,28 @@ pub fn get_godot_executable_path() -> Option<String> {
}

pub fn install(skip_download_templates: bool) -> Result<(), anyhow::Error> {
let persistent_path = get_persistent_path(Some("test.zip".into())).unwrap();
println!("Using persistent path: {persistent_path:?}");

install_dcl_protocol()?;

if env::consts::OS == "windows" {
download_and_extract_zip(
"https://github.com/GyanD/codexffmpeg/releases/download/6.0/ffmpeg-6.0-full_build-shared.zip",
format!("{BIN_FOLDER}ffmpeg").as_str(),
Some("ffmpeg-6.0-full_build-shared.zip".to_string()),
)?;
}

download_and_extract_zip(
get_protoc_url().unwrap().as_str(),
format!("{BIN_FOLDER}protoc").as_str(),
None,
)?;
download_and_extract_zip(
get_godot_url().unwrap().as_str(),
format!("{BIN_FOLDER}godot").as_str(),
Some(format!("{GODOT_CURRENT_VERSION}.executable.zip")),
)?;

let program_path = format!("{BIN_FOLDER}godot/{}", get_godot_executable_path().unwrap());
Expand Down
4 changes: 2 additions & 2 deletions rust/xtask/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub fn adjust_canonicalization<P: AsRef<std::path::Path>>(p: P) -> String {
pub fn adjust_canonicalization<P: AsRef<std::path::Path>>(p: P) -> String {
const VERBATIM_PREFIX: &str = r#"\\?\"#;
let p = p.as_ref().display().to_string();
if p.starts_with(VERBATIM_PREFIX) {
p[VERBATIM_PREFIX.len()..].to_string()
if let Some(stripped) = p.strip_prefix(VERBATIM_PREFIX) {
stripped.to_string()
} else {
p
}
Expand Down
13 changes: 6 additions & 7 deletions rust/xtask/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
path::adjust_canonicalization,
};

#[allow(clippy::too_many_arguments)]
pub fn run(
editor: bool,
release_mode: bool,
Expand Down Expand Up @@ -83,7 +84,7 @@ pub fn run(
args.push("--test");
}

if extras.len() > 0 {
if !extras.is_empty() {
for extra in &extras {
args.push(extra.as_str());
}
Expand Down Expand Up @@ -115,12 +116,10 @@ pub fn run(
test_ok.1 = false;
test_ok.2 = line;
}
} else {
if line.contains("test-exiting with code ") {
test_ok.0 = true;
test_ok.1 = line.contains("test-exiting with code 0");
test_ok.2 = line;
}
} else if line.contains("test-exiting with code ") {
test_ok.0 = true;
test_ok.1 = line.contains("test-exiting with code 0");
test_ok.2 = line;
}
}

Expand Down

0 comments on commit 3e86109

Please sign in to comment.