-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.sh
32 lines (25 loc) · 1.14 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Extract the project name and version from Cargo.toml
project_name=$(grep '^name' Cargo.toml | sed 's/name = "\(.*\)"/\1/' | tr -d '[:space:]')
version=$(grep '^version' Cargo.toml | sed 's/version = "\(.*\)"/\1/' | tr -d '[:space:]')
# Define architectures
architectures=("aarch64-apple-darwin" "x86_64-apple-darwin")
# Build for each architecture
for arch in "${architectures[@]}"; do
cargo build --release --target=$arch
# Extract architecture for naming
short_arch=$(echo $arch | sed 's/-apple-darwin//')
# Move the binary to the release directory with new naming convention
mkdir -p ./target/release/v${version}
mv ./target/$arch/release/$project_name ./target/release/v${version}/${project_name}.darwin-${short_arch}
done
# Change directory to release
cd ./target/release/v${version} || exit
# Create tar.gz and delete original binaries
for arch in "${architectures[@]}"; do
short_arch=$(echo $arch | sed 's/-apple-darwin//')
binary_name="${project_name}.darwin-${short_arch}"
mv ${binary_name} ${project_name}
tar -czf "${binary_name}.tar.gz" --no-xattr "${project_name}"
rm "${project_name}"
done