-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-build.sh
executable file
·70 lines (55 loc) · 1.44 KB
/
release-build.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Default version
VERSION="0.0.0"
# Parse command line arguments
while getopts "v:" opt; do
case $opt in
v)
VERSION="$OPTARG"
;;
\?)
echo "Error: Invalid option: -$OPTARG" >&2
echo "Usage: $0 -v VERSION"
echo "Example: $0 -v 0.1.0"
exit 1
;;
esac
done
# Output names with version
RELEASE_NAME="xoon-linux-x64-v${VERSION}"
DIR_NAME="xoon-${VERSION}"
echo "Building version ${VERSION}..."
# Backup the original main.rs
echo "Backing up main.rs..."
cp src/main.rs src/main.rs.bak
# Update version in main.rs
echo "Updating version in main.rs..."
sed -i "s/title(\"xoon\")/title(\"xoon-${VERSION}\")/" src/main.rs
# Clean previous builds
rm -rf ${DIR_NAME}
rm -f ${RELEASE_NAME}.tar.gz
# Build release version
echo "Building release version..."
cargo build --release --target x86_64-unknown-linux-gnu
# Create release directory
echo "Creating release directory..."
mkdir ${DIR_NAME}
# Copy files
echo "Copying files..."
cp target/x86_64-unknown-linux-gnu/release/xoon ${DIR_NAME}/
if [ -f README.md ]; then
cp README.md ${DIR_NAME}/
fi
# Set permissions
echo "Setting permissions..."
chmod +x ${DIR_NAME}/xoon
# Create tar.gz
echo "Creating archive..."
tar -czf ${RELEASE_NAME}.tar.gz ${DIR_NAME}/
# Clean up
echo "Cleaning up..."
rm -rf ${DIR_NAME}
# Restore the original main.rs
echo "Restoring main.rs..."
mv src/main.rs.bak src/main.rs
echo "Done! Archive created: ${RELEASE_NAME}.tar.gz"