Skip to content

Commit

Permalink
fix: updater universal
Browse files Browse the repository at this point in the history
  • Loading branch information
vansangpfiev authored and hiento09 committed Oct 3, 2024
1 parent 42c1baf commit ad3499d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ jobs:
run: |
echo "{\"tag_name\": \"v${{ needs.get-update-version.outputs.new_version }}\"}" > version.json
aws s3 cp version.json s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/version.json
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-amd64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-arm64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-arm64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-universal-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-amd64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-universal-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-arm64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-universal-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-universal/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/linux-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/linux-amd64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/windows-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/windows-amd64/cortex-nightly.tar.gz
Expand Down
25 changes: 20 additions & 5 deletions engine/commands/cortex_upd_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ std::chrono::seconds GetTimeSinceEpochMillisec() {
using namespace std::chrono;
return duration_cast<seconds>(system_clock::now().time_since_epoch());
}

std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal() {
auto system_info = system_info_utils::GetSystemInfo();
if (system_info->os == "mac") {
CTL_INF("Change arch from " << system_info->arch << " to universal");
system_info->arch = "universal";
}
return system_info;
}

} // namespace

std::optional<std::string> CheckNewUpdate(
Expand Down Expand Up @@ -222,7 +232,7 @@ void CortexUpdCmd::Exec(const std::string& v) {
}

bool CortexUpdCmd::GetStable(const std::string& v) {
auto system_info = system_info_utils::GetSystemInfo();
auto system_info = GetSystemInfoWithUniversal();
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

// Download file
Expand Down Expand Up @@ -276,7 +286,7 @@ bool CortexUpdCmd::GetStable(const std::string& v) {
}

bool CortexUpdCmd::GetBeta(const std::string& v) {
auto system_info = system_info_utils::GetSystemInfo();
auto system_info = GetSystemInfoWithUniversal();
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

// Download file
Expand Down Expand Up @@ -407,11 +417,11 @@ bool CortexUpdCmd::HandleGithubRelease(const nlohmann::json& assets,
}

bool CortexUpdCmd::GetNightly(const std::string& v) {
auto system_info = system_info_utils::GetSystemInfo();
auto system_info = GetSystemInfoWithUniversal();
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

// Download file
std::string version = v.empty() ? "latest" : std::move(v);
std::string version = v.empty() ? "latest" : v;
std::string os_arch{system_info->os + "-" + system_info->arch};
const char* paths[] = {
"cortex",
Expand Down Expand Up @@ -447,7 +457,7 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
.localPath = localPath,
}}};

DownloadService().AddDownloadTask(
auto res = DownloadService().AddDownloadTask(
download_task, [](const DownloadTask& finishedTask) {
// try to unzip the downloaded file
CTL_INF("Downloaded engine path: "
Expand All @@ -462,6 +472,11 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
CTL_INF("Finished!");
});

if (res.has_error()) {
CLI_LOG("Download failed!");
return false;
}

// Replace binary file
auto executable_path = file_manager_utils::GetExecutableFolderContainerPath();
auto src =
Expand Down

0 comments on commit ad3499d

Please sign in to comment.