-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
60 lines (50 loc) · 1.48 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
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
#!/bin/sh
# Variables
REPO="pythcoiner/modbus485_debugger"
TAG="v0.1.1"
NAME="modbus485_debugger"
RELEASE_TITLE="Modbus485 Debugger $TAG"
CHANGELOG_PATH="changelog.txt"
RELEASE_NOTES=$(cat "$CHANGELOG_PATH")
BUILD_DIR="build"
# Ensure cargo is installed
if ! command -v cargo &> /dev/null
then
echo "cargo could not be found. Please install Rust and Cargo."
exit 1
fi
# Clean build directory
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
# Build for Linux
echo "Building for Linux..."
cargo build --release
cp "target/release/$NAME" "$BUILD_DIR/$NAME-$TAG-x86_64-linux-gnu"
# Build for Windows
echo "Building for Windows..."
cargo build --release --target=x86_64-pc-windows-gnu
cp "target/x86_64-pc-windows-gnu/release/$NAME.exe" "$BUILD_DIR/$NAME-$TAG-x86_64-windows-gnu.exe"
## remove tag
#git tag -d "$TAG"
## Remove from remote repository
#git push --delete origin "$TAG"
#git push --delete github "$TAG"
# Tagging
git tag "$TAG"
git push origin "$TAG"
git push github "$TAG"
# Create a GitHub release
gh release create "$TAG" \
--repo "$REPO" \
--title "$RELEASE_TITLE" \
--notes "$RELEASE_NOTES" \
"$BUILD_DIR/$NAME-$TAG-x86_64-linux-gnu" \
"$BUILD_DIR/$NAME-$TAG-x86_64-windows-gnu.exe"
# Create a GitLab release
glab release create "$TAG" \
--repo "rust/modbus485_debugger" \
--name "$RELEASE_TITLE" \
--notes "$RELEASE_NOTES" \
"$BUILD_DIR/$NAME-$TAG-x86_64-linux-gnu" \
"$BUILD_DIR/$NAME-$TAG-x86_64-windows-gnu.exe"
echo "Release $TAG created successfully"