Skip to content

Commit

Permalink
pack app in tar.gz
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozyra95 committed Sep 28, 2023
1 parent 2d5c4e7 commit 55ce25b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/package_for_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:
jobs:
linux:
runs-on: ubuntu-latest
container:
image: ubuntu:mantic-20230712
steps:
- name: 🛠 Install system dependencies
run: |
set -e
sudo apt-get update -y -qq
sudo apt-get install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev ffmpeg libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev
apt-get update -y -qq
apt-get install -y libegl1-mesa-dev libgl1-mesa-dri libxcb-xfixes0-dev ffmpeg libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev
# TMP until we need to build in docker container
apt-get install -y curl build-essential curl pkg-config libssl-dev libclang-dev git
- name: 🔧 Install the rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -46,5 +48,5 @@ jobs:

- uses: actions/upload-artifact@v3
with:
name: video_compositor.app
path: video_compositor.app
name: video_compositor_darwin_x86_64.app.tar.gz
path: video_compositor_darwin_x86_64.app.tar.gz
2 changes: 1 addition & 1 deletion scripts/compositor_runtime_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export LD_LIBRARY_PATH="$SCRIPT_DIR/lib:$LD_LIBRARY_PATH"
export MEMBRANE_VIDEO_COMPOSITOR_PROCESS_HELPER_PATH="$SCRIPT_DIR/video_compositor_process_helper"

"$SCRIPT_DIR/video_compositor_main" "$@"
exec "$SCRIPT_DIR/video_compositor_main" "$@"
2 changes: 2 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ mkdir -p "$ROOT_DIR/release_tmp"
cd "$ROOT_DIR/release_tmp"

gh run download "$WORKFLOW_RUN_ID" -n video_compositor_linux_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n video_compositor_darwin_x86_64.app.tar.gz
gh release create "$RELEASE_TAG"
gh release upload "$RELEASE_TAG" video_compositor_linux_x86_64.tar.gz
gh release upload "$RELEASE_TAG" video_compositor_darwin_x86_64.app.tar.gz

rm -rf "$ROOT_DIR/release_tmp"
53 changes: 47 additions & 6 deletions src/bin/package_for_release/bundle_macos.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,71 @@
use std::env;
use std::path::PathBuf;
use std::process::Command;

use anyhow::Result;
use log::info;

use crate::utils;
use compositor_chromium::cef::bundle_app;
use compositor_chromium::cef;

// const ARM_MAC_TARGET: &str = "aarch64-apple-darwin";
const ARM_MAC_TARGET: &str = "aarch64-apple-darwin";
const ARM_OUTPUT_FILE: &str = "video_compositor_darwin_aarch64.app.tar.gz";
const INTEL_MAC_TARGET: &str = "x86_64-apple-darwin";
const INTEL_OUTPUT_FILE: &str = "video_compositor_darwin_x86_64.app.tar.gz";

pub fn bundle_macos_app() -> Result<()> {
if cfg!(target_arch = "x86_64") {
bundle_app(INTEL_MAC_TARGET, INTEL_OUTPUT_FILE)?;
} else if cfg!(target_arch = "aarch64") {
bundle_app(ARM_MAC_TARGET, ARM_OUTPUT_FILE)?;
// We do not have CI with M1 yet, so this will be built locally for now.
let release_tag = env::var("RELEASE_TAG")?;
let root_dir_str = env!("CARGO_MANIFEST_DIR");
let root_dir: PathBuf = root_dir_str.into();
let upload_path = root_dir.join(ARM_OUTPUT_FILE);
Command::new("gh")
.args([
"release",
"upload",
&release_tag,
&upload_path.display().to_string(),
])
.spawn()?
.wait()?;
} else {
panic!("Unknown architecture")
}
Ok(())
}

fn bundle_app(target: &'static str, output_name: &'static str) -> Result<()> {
env_logger::init_from_env(
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
);
let root_dir_str = env!("CARGO_MANIFEST_DIR");
let root_dir: PathBuf = root_dir_str.into();
let build_dir = root_dir.join(format!("target/{INTEL_MAC_TARGET}/release"));
let build_dir = root_dir.join(format!("target/{target}/release"));
let tmp_dir = root_dir.join("video_compositor.app");

info!("Build main_process binary.");
utils::cargo_build("main_process", INTEL_MAC_TARGET)?;
utils::cargo_build("main_process", target)?;
info!("Build process_helper binary.");
utils::cargo_build("process_helper", INTEL_MAC_TARGET)?;
utils::cargo_build("process_helper", target)?;

info!("Create macOS bundle.");
bundle_app(&build_dir, &tmp_dir)?;
cef::bundle_app(&build_dir, &tmp_dir)?;

info!("Create tar.gz archive.");
Command::new("tar")
.args([
"-C",
root_dir_str,
"-czvf",
output_name,
"video_compositor.app",
])
.spawn()?
.wait()?;

Ok(())
}

0 comments on commit 55ce25b

Please sign in to comment.