Skip to content

Commit efaabe5

Browse files
authored
Update main.yml
1 parent ba4c1a0 commit efaabe5

File tree

1 file changed

+57
-93
lines changed

1 file changed

+57
-93
lines changed

β€Ž.github/workflows/main.ymlβ€Ž

Lines changed: 57 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -48,106 +48,73 @@ jobs:
4848
echo "RUSTFLAGS=-C target-feature=+a53 -C opt-level=z -C link-arg=-s" >> $GITHUB_ENV
4949
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
5050
51-
# Create build script with interactive menu
52-
cat > /home/runner/build-menu.sh << 'EOF'
51+
# Create editable build script
52+
cat > /home/runner/build-config.sh << 'EOF'
5353
#!/bin/bash
5454

55-
# Default build profile
56-
DEFAULT_FLAGS="-C target-feature=+a53 -C opt-level=z -C link-arg=-s"
55+
# =============================================
56+
# RUST BUILD CONFIGURATION SCRIPT
57+
# Edit this file to change build settings!
58+
# =============================================
5759

58-
echo "========================================"
59-
echo " RUST CROSS-COMPILATION BUILDER"
60-
echo "========================================"
61-
echo "Target: aarch64-unknown-linux-musl"
62-
echo "Current RUSTFLAGS: ${RUSTFLAGS:-$DEFAULT_FLAGS}"
63-
echo ""
64-
65-
PS3='Pilih build profile [1-5]: '
66-
options=(
67-
"Small size (opt-level=z) - untuk OpenWrt"
68-
"Fast (opt-level=3) - performa maksimal"
69-
"Balanced (opt-level=2) - default cargo"
70-
"Debug (no optimizations) - debugging"
71-
"Custom RUSTFLAGS - input manual"
72-
)
73-
74-
select opt in "${options[@]}"
75-
do
76-
case $REPLY in
77-
1)
78-
export RUSTFLAGS="-C target-feature=+a53 -C opt-level=z -C link-arg=-s"
79-
echo "βœ“ Menggunakan: Small size optimization"
80-
break
81-
;;
82-
2)
83-
export RUSTFLAGS="-C target-feature=+a53 -C opt-level=3"
84-
echo "βœ“ Menggunakan: Fast optimization"
85-
break
86-
;;
87-
3)
88-
export RUSTFLAGS="-C target-feature=+a53 -C opt-level=2"
89-
echo "βœ“ Menggunakan: Balanced optimization"
90-
break
91-
;;
92-
4)
93-
export RUSTFLAGS=""
94-
echo "βœ“ Menggunakan: No optimization (debug)"
95-
break
96-
;;
97-
5)
98-
read -p "Masukkan RUSTFLAGS custom: " custom_flags
99-
export RUSTFLAGS="$custom_flags"
100-
echo "βœ“ Menggunakan: Custom flags"
101-
break
102-
;;
103-
*)
104-
echo "Pilihan invalid. Coba lagi."
105-
;;
106-
esac
107-
done
108-
109-
echo ""
110-
echo "RUSTFLAGS yang aktif: $RUSTFLAGS"
111-
echo ""
112-
113-
# Ask for build command
114-
read -p "Jalankan cargo build? (y/n): " -n 1 -r
115-
echo ""
116-
if [[ $REPLY =~ ^[Yy]$ ]]; then
117-
echo "πŸš€ Building dengan command:"
118-
echo "cargo build --release --target aarch64-unknown-linux-musl"
60+
# Default RUSTFLAGS for OpenWrt ARMv8
61+
export RUSTFLAGS="-C target-feature=+a53 -C opt-level=z -C link-arg=-s"
62+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER="aarch64-linux-gnu-gcc"
63+
64+
# Build function
65+
build_project() {
66+
echo "πŸ”¨ Building with settings:"
67+
echo " RUSTFLAGS: $RUSTFLAGS"
68+
echo " LINKER: $CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER"
69+
echo " TARGET: aarch64-unknown-linux-musl"
11970
echo ""
12071

121-
# Execute build
12272
cargo build --release --target aarch64-unknown-linux-musl
12373

12474
if [ $? -eq 0 ]; then
12575
echo ""
12676
echo "βœ… BUILD BERHASIL!"
127-
echo "Binary tersedia di: target/aarch64-unknown-linux-musl/release/"
128-
echo ""
77+
echo "πŸ“ Binary: target/aarch64-unknown-linux-musl/release/"
12978
ls -lh target/aarch64-unknown-linux-musl/release/
13079
else
13180
echo ""
13281
echo "❌ BUILD GAGAL!"
82+
return 1
13383
fi
84+
}
85+
86+
# Main execution
87+
if [ "$1" = "build" ]; then
88+
build_project
13489
else
135-
echo "Build dibatalkan."
136-
echo "Anda bisa jalankan manual dengan:"
137-
echo " cargo build --release --target aarch64-unknown-linux-musl"
90+
echo "Usage: ./build-config.sh build"
91+
echo ""
92+
echo "Edit this script to change RUSTFLAGS:"
93+
echo " nano build-config.sh"
94+
echo ""
95+
echo "Current RUSTFLAGS: $RUSTFLAGS"
13896
fi
13997
EOF
14098

141-
chmod +x /home/runner/build-menu.sh
99+
chmod +x /home/runner/build-config.sh
142100

143-
# Create quick build script (one-liner)
144-
cat > /home/runner/quick-build.sh << 'EOF'
101+
# Create alternative build profiles
102+
cat > /home/runner/build-fast.sh << 'EOF'
145103
#!/bin/bash
146-
# Quick build dengan default settings
147-
export RUSTFLAGS="-C target-feature=+a53 -C opt-level=z -C link-arg=-s"
104+
export RUSTFLAGS="-C target-feature=+a53 -C opt-level=3"
105+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER="aarch64-linux-gnu-gcc"
148106
cargo build --release --target aarch64-unknown-linux-musl
149107
EOF
150-
chmod +x /home/runner/quick-build.sh
108+
109+
cat > /home/runner/build-debug.sh << 'EOF'
110+
#!/bin/bash
111+
export RUSTFLAGS=""
112+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER="aarch64-linux-gnu-gcc"
113+
cargo build --target aarch64-unknown-linux-musl
114+
EOF
115+
116+
chmod +x /home/runner/build-fast.sh
117+
chmod +x /home/runner/build-debug.sh
151118

152119
- name: Install Tailscale
153120
run: |
@@ -175,7 +142,7 @@ EOF
175142
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
176143
sudo systemctl restart ssh
177144
178-
# Store SSH credentials safely
145+
# Store SSH credentials
179146
echo "SSH_USER=rustuser" >> $GITHUB_ENV
180147
echo "SSH_PASSWORD=$SSH_PASSWORD" >> $GITHUB_ENV
181148
@@ -223,24 +190,21 @@ EOF
223190
echo " Username: ${{ env.SSH_USER }}"
224191
echo " Password: ${{ env.SSH_PASSWORD }}"
225192
echo ""
226-
echo "πŸ”§ BUILD TOOLS:"
227-
echo " Rust target: aarch64-unknown-linux-musl"
228-
echo " Linker: aarch64-linux-gnu-gcc"
229-
echo " Default RUSTFLAGS: -C target-feature=+a53 -C opt-level=z -C link-arg=-s"
193+
echo "πŸ”§ BUILD SCRIPTS:"
194+
echo " ./build-config.sh build - Build dengan config editable"
195+
echo " ./build-fast.sh - Build untuk performa"
196+
echo " ./build-debug.sh - Build untuk debugging"
230197
echo ""
231-
echo "πŸ“‚ PROJECT STRUCTURE:"
232-
echo " Current directory: $(pwd)"
233-
echo " β”œβ”€β”€ Cargo.toml"
234-
echo " β”œβ”€β”€ src/main.rs"
235-
echo " └── build-menu.sh (interactive build script)"
198+
echo "⚑ QUICK USAGE:"
199+
echo " 1. ssh rustuser@${{ env.TAILSCALE_IP }}"
200+
echo " 2. Edit build config: nano build-config.sh"
201+
echo " 3. Build: ./build-config.sh build"
236202
echo ""
237-
echo "⚑ QUICK COMMANDS (setelah login SSH):"
238-
echo " ./build-menu.sh # Interactive build menu"
239-
echo " ./quick-build.sh # Quick build dengan default"
240-
echo " nano src/main.rs # Edit source code"
241-
echo " cargo build --release --target aarch64-unknown-linux-musl"
203+
echo "πŸ“ EDIT BUILD SETTINGS:"
204+
echo " Ubah RUSTFLAGS di build-config.sh:"
205+
echo " nano build-config.sh"
242206
echo ""
243-
echo "⏰ Runner akan aktif selama ${{ github.event.inputs.keep_alive_minutes }} menit"
207+
echo "⏰ Runner aktif: ${{ github.event.inputs.keep_alive_minutes }} menit"
244208
echo "========================================"
245209
echo ""
246210

0 commit comments

Comments
Β (0)