Added arm64 build

This commit is contained in:
Lorenzo Iovino 2025-12-15 16:26:57 +01:00
parent fa9fe6095b
commit a2140b5ea8

View file

@ -2,205 +2,146 @@ name: Build and Release
on: on:
push: push:
branches: [ main ] branches: [main]
pull_request: pull_request:
branches: [ main ] branches: [main]
jobs: jobs:
build: build:
name: Cross-compile for Raspberry Pi name: Build multi-arch Raspberry Pi binaries
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code # --------------------------------------------------
uses: actions/checkout@v3 # Checkout
# --------------------------------------------------
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go # --------------------------------------------------
uses: actions/setup-go@v4 # Go setup
with: # --------------------------------------------------
go-version: '1.20' - name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Build for ARM (Pi Zero, Pi 1 - ARMv6) # --------------------------------------------------
run: | # Build binaries
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o wol-server-arm6 # --------------------------------------------------
- name: Build for ARMv6 (Pi Zero / Pi 1)
run: |
GOOS=linux GOARCH=arm GOARM=6 \
go build -ldflags="-s -w" -o wol-server-armv6
- name: Create systemd service file - name: Build for ARM64 (Pi Zero 2 / Pi 3 / Pi 4 / Pi 5)
run: | run: |
cat > wol-server.service << 'EOL' GOOS=linux GOARCH=arm64 \
[Unit] go build -ldflags="-s -w" -o wol-server-arm64
Description=WOL Server Go Application
After=network.target
[Service] # --------------------------------------------------
User=pi # systemd service (portable, no hardcoded user)
WorkingDirectory=/home/pi/wol-server # --------------------------------------------------
ExecStart=/home/pi/wol-server/wol-server - name: Create systemd service file
Restart=always run: |
cat > wol-server.service << 'EOF'
[Unit]
Description=WOL Server Go Application
After=network.target
[Install] [Service]
WantedBy=multi-user.target Type=simple
EOL User=loke
WorkingDirectory=/home/loke/wol-server
ExecStart=/home/loke/wol-server/wol-server
Restart=always
RestartSec=3
- name: Create deployment script [Install]
run: | WantedBy=multi-user.target
cat > install.sh << 'EOL' EOF
#!/bin/bash
set -e
# Installation directory # --------------------------------------------------
INSTALL_DIR=~/wol-server # Install script (auto-detect architecture)
# --------------------------------------------------
- name: Create install script
run: |
cat > install.sh << 'EOF'
#!/bin/bash
set -e
echo "Creating installation directory..." INSTALL_DIR="$HOME/wol-server"
mkdir -p $INSTALL_DIR
mkdir -p $INSTALL_DIR/templates
echo "Installing application..." echo "Creating installation directory..."
cp wol-server-arm6 $INSTALL_DIR/wol-server mkdir -p "$INSTALL_DIR/templates"
chmod +x $INSTALL_DIR/wol-server
echo "Installing template files..." ARCH=$(uname -m)
cp -r templates/* $INSTALL_DIR/templates/ case "$ARCH" in
armv6l|armv7l)
BIN="wol-server-armv6"
;;
aarch64)
BIN="wol-server-arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
echo "Installing system service..." echo "Detected architecture: $ARCH"
sudo cp wol-server.service /etc/systemd/system/ echo "Using binary: $BIN"
sudo systemctl daemon-reload
sudo systemctl enable wol-server
# Install required dependencies cp "$BIN" "$INSTALL_DIR/wol-server"
echo "Installing dependencies..." chmod +x "$INSTALL_DIR/wol-server"
sudo apt-get update -qq
sudo apt-get install -y wakeonlan sshpass
# Start the service echo "Installing templates..."
echo "Starting service..." cp -r templates/* "$INSTALL_DIR/templates/"
sudo systemctl restart wol-server
echo "===========================================" echo "Installing systemd service..."
echo "Installation complete!" sudo cp wol-server.service /etc/systemd/system/
echo "The WOL server is now running at http://$(hostname -I | awk '{print $1}'):8080" sudo systemctl daemon-reload
echo "===========================================" sudo systemctl enable wol-server
EOL
chmod +x install.sh echo "Installing dependencies..."
sudo apt-get update -qq
sudo apt-get install -y wakeonlan sshpass
- name: Create README with installation instructions echo "Starting service..."
run: | sudo systemctl restart wol-server
cat > INSTALL.md << 'EOL'
# WOL Server Installation Guide
This guide will help you install the Wake-on-LAN server on your Raspberry Pi. echo "==========================================="
echo "WOL Server installed successfully!"
echo "URL: http://$(hostname -I | awk '{print $1}'):8080"
echo "==========================================="
EOF
## Prerequisites chmod +x install.sh
- Raspberry Pi running Raspberry Pi OS (Raspbian) # --------------------------------------------------
- SSH access to your Pi # Package
- SCP or SFTP capability to transfer files # --------------------------------------------------
- name: Create release package
run: |
mkdir -p package
cp wol-server-armv6 package/
cp wol-server-arm64 package/
cp wol-server.service package/
cp install.sh package/
cp -r templates package/
## Installation Steps tar -czf wol-server.tar.gz -C package .
### 1. Transfer Files to Raspberry Pi # --------------------------------------------------
# GitHub Release
**Option 1: Using SCP from your computer** # --------------------------------------------------
- name: Create GitHub Release
```bash uses: softprops/action-gh-release@v1
# Replace with your Pi's IP address if: github.ref == 'refs/heads/main'
PI_IP=192.168.1.100 with:
tag_name: v${{ github.run_number }}
# Transfer the installation package name: Release v${{ github.run_number }}
scp wol-server.tar.gz pi@$PI_IP:~/ files: |
``` wol-server.tar.gz
env:
**Option 2: Using SFTP client** GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Use a tool like FileZilla, WinSCP, or Cyberduck to transfer the `wol-server.tar.gz` file to your Raspberry Pi.
### 2. SSH into your Raspberry Pi
```bash
ssh pi@192.168.1.100
```
### 3. Extract and Install
```bash
# Navigate to home directory
cd ~
# Extract the archive
tar -xzf wol-server.tar.gz
# Run the installation script
./install.sh
```
### 4. Test the Installation
Open a web browser and navigate to:
```
http://[your-pi-ip]:8080
```
## Troubleshooting
If the service fails to start, check the logs:
```bash
sudo systemctl status wol-server
```
If template errors occur, ensure the template files were copied correctly:
```bash
ls -la ~/wol-server/templates/
```
## Manual Installation (if needed)
If you encounter issues with the automated install:
```bash
# Create directories
mkdir -p ~/wol-server/templates
# Copy files manually
cp wol-server-arm6 ~/wol-server/wol-server
chmod +x ~/wol-server/wol-server
cp templates/* ~/wol-server/templates/
sudo cp wol-server.service /etc/systemd/system/
# Install dependencies
sudo apt-get update
sudo apt-get install -y wakeonlan sshpass
# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable wol-server
sudo systemctl start wol-server
```
EOL
- name: Create all-in-one package
run: |
# Create a single package with everything needed
mkdir -p package
cp wol-server-arm6 package/
cp wol-server.service package/
cp install.sh package/
cp -r templates package/
cp INSTALL.md package/
# Create the tarball
tar -czf wol-server.tar.gz -C package .
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/main'
with:
tag_name: v${{ github.run_number }}
name: Release v${{ github.run_number }}
draft: false
prerelease: false
files: |
wol-server.tar.gz
INSTALL.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}