-
Notifications
You must be signed in to change notification settings - Fork 6
/
package.sh
executable file
·55 lines (43 loc) · 1.63 KB
/
package.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
#!/usr/bin/env bash
# Best way to use this script is to run it in the form:
# -------------------------------------------------------
# PANACUS_TARGET="x86_64-unknown-linux-musl" ./package.sh
# -------------------------------------------------------
# Output is in the pkg directory
NAME="panacus"
EXEC="panacus"
VERSION="$(cargo read-manifest | jq .version | sed "s/\"//g")"
ARCH="${PANACUS_TARGET}"
# ARCH="x86_64-unknown-linux-musl"
# ARCH="x86_64-apple-darwin"
# ARCH="aarch64-apple-darwin"
echo "Packaging ${NAME}, ${EXEC}, ${VERSION}, ${ARCH}"
cargo fmt && \
cargo check && \
cargo test || exit 1
echo "Building release"
cargo build --release --target ${ARCH} || exit 1
echo "Finished building release"
if [ ! -d ./pkg ]; \
then \
mkdir ./pkg; \
fi
if [ -d ./pkg/${NAME}-${VERSION}_${ARCH} ]; \
then \
echo "Current version number already exists! Removing old files!"; \
rm -rf ./pkg/${NAME}-${VERSION}_${ARCH}; \
fi
mkdir ./pkg/${NAME}-${VERSION}_${ARCH}
cp -r ./scripts ./pkg/${NAME}-${VERSION}_${ARCH}/
cp -r ./docs ./pkg/${NAME}-${VERSION}_${ARCH}/
mkdir ./pkg/${NAME}-${VERSION}_${ARCH}/bin
cp target/${ARCH}/release/${EXEC} ./pkg/${NAME}-${VERSION}_${ARCH}/bin/
strip ./pkg/${NAME}-${VERSION}_${ARCH}/bin/${EXEC}
ln -s ../scripts/$NAME-visualize.py ./pkg/${NAME}-${VERSION}_${ARCH}/$NAME-visualize
cp LICENSE ./pkg/${NAME}-${VERSION}_${ARCH}/
bash ./set-version.sh
cp README.md ./pkg/${NAME}-${VERSION}_${ARCH}/
cp -r examples ./pkg/${NAME}-${VERSION}_${ARCH}/
cd ./pkg && tar -czf ./${NAME}-${VERSION}_${ARCH}.tar.gz ./${NAME}-${VERSION}_${ARCH}
echo "Cleaning up ./pkg/${NAME}-${VERSION}_${ARCH}"
rm -rf ./${NAME}-${VERSION}_${ARCH}