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 9206509
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 17 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/package_for_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +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 libnss3 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0
- name: 🔧 Install the rust toolchain
uses: dtolnay/rust-toolchain@stable

Expand Down Expand Up @@ -46,5 +47,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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ target/

# Generated during runtime
/shmem

/video_compositor.app
/video_compositor
/video_compositor_linux_x86_64.tar.gz
/video_compositor_darwin_aarch64.app.tar.gz
/video_compositor_darwin_x86_64.app.tar.gz
14 changes: 14 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@ To release a new compositor version:
- Run `WORKFLOW_RUN_ID={WORKFLOW_RUN_ID} RELEASE_TAG={VERSION} ./scripts/release.sh` where `WORKFLOW_RUN_ID` is an ID from the previous step, and `VERSION` has a format `v{major}.{minor}.{patch}`. e.g. `WORKFLOW_RUN_ID=6302155380 RELEASE_TAG=v1.2.3 ./scripts/release.sh `


### Temporary workaround for macOS M1 binaries

Currently we do not have a CI to build for macOS M1, so for now compositor releases are run from a developer device.

To publish binaries for M1 devices, first follow instructions above for other platform. After GitHub release is created you can add binaries for M1 by running bellow command on M1 mac.

```bash
RELEASE_TAG={VERSION} cargo run --bin package_for_release --features standalone
```

e.g.
```bash
RELEASE_TAG=v1.2.3 cargo run --bin package_for_release --features standalone
```
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"
10 changes: 7 additions & 3 deletions src/bin/package_for_release/bundle_linux.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::Result;
use anyhow::{anyhow, Result};
use fs_extra::dir::{self, CopyOptions};
use log::info;
use std::fs;
Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn bundle_linux_app() -> Result<()> {
dir::copy(release_dir.join("lib"), tmp_dir, &CopyOptions::default())?;

info!("Create tar.gz archive.");
Command::new("tar")
let exit_code = Command::new("tar")
.args([
"-C",
root_dir_str,
Expand All @@ -61,7 +61,11 @@ pub fn bundle_linux_app() -> Result<()> {
"video_compositor",
])
.spawn()?
.wait()?;
.wait()?
.code();
if exit_code != Some(0) {
return Err(anyhow!("Command tar failed with exit code {:?}", exit_code));
}

Ok(())
}
60 changes: 54 additions & 6 deletions src/bin/package_for_release/bundle_macos.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,78 @@
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);
let exit_code = Command::new("gh")
.args([
"release",
"upload",
&release_tag,
&upload_path.display().to_string(),
])
.spawn()?
.wait()?;
if exit_code != Some(0) {
return Err(anyhow!("Command gh failed with exit code {:?}", exit_code));
}
} 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.");
let exit_code = Command::new("tar")
.args([
"-C",
root_dir_str,
"-czvf",
output_name,
"video_compositor.app",
])
.spawn()?
.wait()?
.code();
if exit_code != Some(0) {
return Err(anyhow!("Command tar failed with exit code {:?}", exit_code));
}

Ok(())
}

0 comments on commit 9206509

Please sign in to comment.