mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-26 00:32:45 +03:00
build-release: zip up the builds so they are ready for upload
This commit is contained in:
parent
26acb4b8b1
commit
ded8cd62f0
@ -3,37 +3,66 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import zipfile
|
||||
|
||||
def build_and_move(feature, tmp_dir):
|
||||
def get_system_info():
|
||||
# Get OS and architecture information
|
||||
os_info = subprocess.run(["uname"], capture_output=True, text=True, check=True).stdout.strip().lower()
|
||||
arch_info = subprocess.run(["uname", "-p"], capture_output=True, text=True, check=True).stdout.strip().lower()
|
||||
|
||||
if os_info == "linux":
|
||||
os_info = "unknown-linux-gnu"
|
||||
elif os_info == "darwin":
|
||||
os_info = "apple-darwin"
|
||||
|
||||
if arch_info == "arm":
|
||||
arch_info = "aarch64"
|
||||
|
||||
return arch_info, os_info
|
||||
|
||||
def build_and_move(feature, tmp_dir, architecture, os_name):
|
||||
print("\n" + "=" * 50)
|
||||
print(f"BUILDING {feature if feature else 'default'}")
|
||||
print("=" * 50 + "\n")
|
||||
|
||||
zip_prefix = f"kinode-{architecture}-{os_name}"
|
||||
if feature:
|
||||
subprocess.run(["cargo", "+nightly", "build", "--release", "--features", feature], check=True)
|
||||
binary_name = f"kinode-{feature}"
|
||||
zip_name = f"{zip_prefix}-{feature}.zip"
|
||||
else:
|
||||
subprocess.run(["cargo", "+nightly", "build", "--release"], check=True)
|
||||
binary_name = "kinode"
|
||||
zip_name = f"{zip_prefix}.zip"
|
||||
|
||||
# Move and rename the binary
|
||||
source_path = "target/release/kinode"
|
||||
binary_name = "kinode"
|
||||
source_path = f"target/release/{binary_name}"
|
||||
dest_path = os.path.join(tmp_dir, binary_name)
|
||||
shutil.move(source_path, dest_path)
|
||||
|
||||
def main():
|
||||
# Features to compile with
|
||||
features = ["", "simulation-mode"] # Add more features as needed
|
||||
# Create a zip archive of the binary
|
||||
zip_path = os.path.join(tmp_dir, zip_name)
|
||||
with zipfile.ZipFile(zip_path, 'w') as zipf:
|
||||
zipf.write(dest_path, os.path.basename(dest_path))
|
||||
|
||||
# Ensure the tmp directory is clean
|
||||
# Remove the original binary
|
||||
os.remove(dest_path)
|
||||
|
||||
def main():
|
||||
# Get system info
|
||||
architecture, os_name = get_system_info()
|
||||
|
||||
# Modify the temporary directory path
|
||||
tmp_dir = "/tmp/kinode-release"
|
||||
if os.path.exists(tmp_dir):
|
||||
shutil.rmtree(tmp_dir)
|
||||
os.makedirs(tmp_dir)
|
||||
|
||||
# Features to compile with; add more features as needed
|
||||
features = ["", "simulation-mode"]
|
||||
|
||||
# Loop through the features and build
|
||||
for feature in features:
|
||||
build_and_move(feature, tmp_dir)
|
||||
build_and_move(feature, tmp_dir, architecture, os_name)
|
||||
|
||||
print(f"Build and move process completed.\nFind release in {tmp_dir}.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user