Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79864ace88 | |||
| a2140b5ea8 |
1 changed files with 103 additions and 171 deletions
216
.github/workflows/build.yml
vendored
216
.github/workflows/build.yml
vendored
|
|
@ -2,205 +2,137 @@ 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
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: "1.22"
|
||||||
|
|
||||||
- name: Build for ARM (Pi Zero, Pi 1 - ARMv6)
|
- name: Build for ARMv6 (Pi Zero / Pi 1)
|
||||||
run: |
|
run: |
|
||||||
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o wol-server-arm6
|
GOOS=linux GOARCH=arm GOARM=6 \
|
||||||
|
go build -ldflags="-s -w" -o wol-server-armv6
|
||||||
|
|
||||||
|
- name: Build for ARM64 (Pi Zero 2 / Pi 3 / Pi 4 / Pi 5)
|
||||||
|
run: |
|
||||||
|
GOOS=linux GOARCH=arm64 \
|
||||||
|
go build -ldflags="-s -w" -o wol-server-arm64
|
||||||
|
|
||||||
- name: Create systemd service file
|
- name: Create systemd service file
|
||||||
run: |
|
run: |
|
||||||
cat > wol-server.service << 'EOL'
|
cat > wol-server.service << 'EOF'
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=WOL Server Go Application
|
Description=WOL Server Go Application
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=pi
|
Type=simple
|
||||||
WorkingDirectory=/home/pi/wol-server
|
User=loke
|
||||||
ExecStart=/home/pi/wol-server/wol-server
|
WorkingDirectory=/home/loke/wol-server
|
||||||
|
ExecStart=/home/loke/wol-server/wol-server
|
||||||
Restart=always
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOL
|
EOF
|
||||||
|
|
||||||
- name: Create deployment script
|
- name: Create install script
|
||||||
run: |
|
run: |
|
||||||
cat > install.sh << 'EOL'
|
cat > install.sh << 'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Installation directory
|
INSTALL_DIR="$HOME/wol-server"
|
||||||
INSTALL_DIR=~/wol-server
|
|
||||||
|
|
||||||
echo "Creating installation directory..."
|
echo "Creating installation directory..."
|
||||||
mkdir -p $INSTALL_DIR
|
mkdir -p "$INSTALL_DIR/templates"
|
||||||
mkdir -p $INSTALL_DIR/templates
|
|
||||||
|
|
||||||
echo "Installing application..."
|
ARCH=$(uname -m)
|
||||||
cp wol-server-arm6 $INSTALL_DIR/wol-server
|
case "$ARCH" in
|
||||||
chmod +x $INSTALL_DIR/wol-server
|
armv6l|armv7l)
|
||||||
|
BIN="wol-server-armv6"
|
||||||
|
;;
|
||||||
|
aarch64)
|
||||||
|
BIN="wol-server-arm64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture: $ARCH"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo "Installing template files..."
|
echo "Detected architecture: $ARCH"
|
||||||
cp -r templates/* $INSTALL_DIR/templates/
|
echo "Using binary: $BIN"
|
||||||
|
|
||||||
echo "Installing system service..."
|
cp "$BIN" "$INSTALL_DIR/wol-server"
|
||||||
|
chmod +x "$INSTALL_DIR/wol-server"
|
||||||
|
|
||||||
|
echo "Installing templates..."
|
||||||
|
cp -r templates/* "$INSTALL_DIR/templates/"
|
||||||
|
|
||||||
|
echo "Installing systemd service..."
|
||||||
sudo cp wol-server.service /etc/systemd/system/
|
sudo cp wol-server.service /etc/systemd/system/
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable wol-server
|
sudo systemctl enable wol-server
|
||||||
|
|
||||||
# Install required dependencies
|
|
||||||
echo "Installing dependencies..."
|
echo "Installing dependencies..."
|
||||||
sudo apt-get update -qq
|
sudo apt-get update -qq
|
||||||
sudo apt-get install -y wakeonlan sshpass
|
sudo apt-get install -y wakeonlan sshpass
|
||||||
|
|
||||||
# Start the service
|
|
||||||
echo "Starting service..."
|
echo "Starting service..."
|
||||||
sudo systemctl restart wol-server
|
sudo systemctl restart wol-server
|
||||||
|
|
||||||
echo "==========================================="
|
echo "==========================================="
|
||||||
echo "Installation complete!"
|
echo "WOL Server installed successfully!"
|
||||||
echo "The WOL server is now running at http://$(hostname -I | awk '{print $1}'):8080"
|
echo "URL: http://$(hostname -I | awk '{print $1}'):8080"
|
||||||
echo "==========================================="
|
echo "==========================================="
|
||||||
EOL
|
EOF
|
||||||
|
|
||||||
chmod +x install.sh
|
chmod +x install.sh
|
||||||
|
|
||||||
- name: Create README with installation instructions
|
- name: Create release package
|
||||||
run: |
|
run: |
|
||||||
cat > INSTALL.md << 'EOL'
|
|
||||||
# WOL Server Installation Guide
|
|
||||||
|
|
||||||
This guide will help you install the Wake-on-LAN server on your Raspberry Pi.
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
- Raspberry Pi running Raspberry Pi OS (Raspbian)
|
|
||||||
- SSH access to your Pi
|
|
||||||
- SCP or SFTP capability to transfer files
|
|
||||||
|
|
||||||
## Installation Steps
|
|
||||||
|
|
||||||
### 1. Transfer Files to Raspberry Pi
|
|
||||||
|
|
||||||
**Option 1: Using SCP from your computer**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Replace with your Pi's IP address
|
|
||||||
PI_IP=192.168.1.100
|
|
||||||
|
|
||||||
# Transfer the installation package
|
|
||||||
scp wol-server.tar.gz pi@$PI_IP:~/
|
|
||||||
```
|
|
||||||
|
|
||||||
**Option 2: Using SFTP client**
|
|
||||||
|
|
||||||
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
|
mkdir -p package
|
||||||
cp wol-server-arm6 package/
|
cp wol-server-armv6 package/
|
||||||
|
cp wol-server-arm64 package/
|
||||||
cp wol-server.service package/
|
cp wol-server.service package/
|
||||||
cp install.sh package/
|
cp install.sh package/
|
||||||
cp -r templates package/
|
cp -r templates package/
|
||||||
cp INSTALL.md package/
|
|
||||||
|
|
||||||
# Create the tarball
|
|
||||||
tar -czf wol-server.tar.gz -C package .
|
tar -czf wol-server.tar.gz -C package .
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Forgejo Release
|
||||||
id: create_release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
with:
|
run: |
|
||||||
tag_name: v${{ github.run_number }}
|
TAG="v${{ github.run_number }}"
|
||||||
name: Release v${{ github.run_number }}
|
API_URL="${{ github.server_url }}/api/v1"
|
||||||
draft: false
|
REPO="${{ github.repository }}"
|
||||||
prerelease: false
|
|
||||||
files: |
|
# Create release
|
||||||
wol-server.tar.gz
|
RELEASE_ID=$(curl -s -X POST \
|
||||||
INSTALL.md
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
env:
|
-H "Content-Type: application/json" \
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
"${API_URL}/repos/${REPO}/releases" \
|
||||||
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"Release ${TAG}\", \"draft\": false, \"prerelease\": false}" \
|
||||||
|
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
|
|
||||||
|
# Upload asset
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=wol-server.tar.gz" \
|
||||||
|
-F "attachment=@wol-server.tar.gz" > /dev/null
|
||||||
|
|
||||||
|
echo "Release ${TAG} created with asset wol-server.tar.gz"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue