mirror of
https://github.com/doolijb/serene-pub.git
synced 2026-07-09 15:58:23 +00:00
211 lines
8.8 KiB
YAML
211 lines
8.8 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
- "v*.*.*-alpha"
|
|
|
|
jobs:
|
|
build-and-release:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- target: linux-x64
|
|
os: ubuntu-latest
|
|
- target: linux-arm64
|
|
os: ubuntu-latest
|
|
- target: linux-arm
|
|
os: ubuntu-latest
|
|
- target: linux-ppc64
|
|
os: ubuntu-latest
|
|
# - target: macos-x64
|
|
# os: macos-latest
|
|
- target: macos-arm64
|
|
os: macos-latest
|
|
- target: windows-x64
|
|
os: windows-latest
|
|
- target: windows-arm64
|
|
os: windows-latest
|
|
runs-on: ${{ matrix.os }}
|
|
env:
|
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
node -e "const fs = require('fs'); try { fs.unlinkSync('package-lock.json'); } catch (e) { /* ignore */ }"
|
|
npm install
|
|
|
|
- name: Prepare SvelteKit
|
|
run: npx @sveltejs/kit sync
|
|
|
|
- name: Build app
|
|
run: npm run build
|
|
|
|
- name: Create platform-specific executables and icons
|
|
run: node scripts/create-executables.js
|
|
|
|
- name: Prepare production dependencies
|
|
shell: bash
|
|
run: |
|
|
# Install production dependencies
|
|
npm install --production
|
|
npm rebuild
|
|
|
|
# Clean node_modules with modclean, preserving license files
|
|
npx modclean --run --patterns="default:safe,default:caution,default:danger" --ignore="**/LICENSE,**/COPYING,**/NOTICE,**/README*,**/COPYRIGHT,**/AUTHORS,**/CONTRIBUTORS"
|
|
|
|
- name: Download Node.js runtime for target platform
|
|
shell: bash
|
|
run: |
|
|
echo "Downloading Node.js for ${{ matrix.target }}..."
|
|
mkdir -p temp-node
|
|
cd temp-node
|
|
|
|
case "${{ matrix.target }}" in
|
|
linux-x64)
|
|
NODE_URL="https://nodejs.org/dist/v20.13.1/node-v20.13.1-linux-x64.tar.xz"
|
|
curl -L -o node.tar.xz "$NODE_URL"
|
|
tar -xf node.tar.xz
|
|
cp node-v20.13.1-linux-x64/bin/node ../node
|
|
;;
|
|
linux-arm64)
|
|
NODE_URL="https://nodejs.org/dist/v20.13.1/node-v20.13.1-linux-arm64.tar.xz"
|
|
curl -L -o node.tar.xz "$NODE_URL"
|
|
tar -xf node.tar.xz
|
|
cp node-v20.13.1-linux-arm64/bin/node ../node
|
|
;;
|
|
linux-arm)
|
|
NODE_URL="https://nodejs.org/dist/v20.13.1/node-v20.13.1-linux-armv7l.tar.xz"
|
|
curl -L -o node.tar.xz "$NODE_URL"
|
|
tar -xf node.tar.xz
|
|
cp node-v20.13.1-linux-armv7l/bin/node ../node
|
|
;;
|
|
linux-ppc64)
|
|
NODE_URL="https://nodejs.org/dist/v20.13.1/node-v20.13.1-linux-ppc64le.tar.xz"
|
|
curl -L -o node.tar.xz "$NODE_URL"
|
|
tar -xf node.tar.xz
|
|
cp node-v20.13.1-linux-ppc64le/bin/node ../node
|
|
;;
|
|
macos-arm64)
|
|
NODE_URL="https://nodejs.org/dist/v20.13.1/node-v20.13.1-darwin-arm64.tar.gz"
|
|
curl -L -o node.tar.gz "$NODE_URL"
|
|
tar -xzf node.tar.gz
|
|
cp node-v20.13.1-darwin-arm64/bin/node ../node
|
|
;;
|
|
windows-x64)
|
|
NODE_URL="https://nodejs.org/dist/v20.13.1/node-v20.13.1-win-x64.zip"
|
|
curl -L -o node.zip "$NODE_URL"
|
|
unzip -q node.zip
|
|
cp node-v20.13.1-win-x64/node.exe ../node.exe
|
|
;;
|
|
windows-arm64)
|
|
NODE_URL="https://nodejs.org/dist/v20.13.1/node-v20.13.1-win-arm64.zip"
|
|
curl -L -o node.zip "$NODE_URL"
|
|
unzip -q node.zip
|
|
cp node-v20.13.1-win-arm64/node.exe ../node.exe
|
|
;;
|
|
esac
|
|
|
|
cd ..
|
|
rm -rf temp-node
|
|
|
|
# Verify the Node.js binary was downloaded
|
|
if [[ "${{ matrix.target }}" == windows-* ]]; then
|
|
if [ ! -f "node.exe" ]; then
|
|
echo "ERROR: Failed to download node.exe"
|
|
exit 1
|
|
fi
|
|
echo "Downloaded node.exe ($(du -h node.exe | cut -f1))"
|
|
else
|
|
if [ ! -f "node" ]; then
|
|
echo "ERROR: Failed to download node binary"
|
|
exit 1
|
|
fi
|
|
chmod +x node
|
|
echo "Downloaded node binary ($(du -h node | cut -f1))"
|
|
fi
|
|
|
|
- name: Bundle for ${{ matrix.target }}
|
|
run: node scripts/bundle-dist.js ${{ matrix.target }}
|
|
|
|
- name: Create production environment example
|
|
shell: bash
|
|
run: |
|
|
cd dist
|
|
DIST_DIR=$(ls -d serene-pub-*-${{ matrix.target }} 2>/dev/null | head -1)
|
|
if [ -z "$DIST_DIR" ]; then
|
|
echo "Error: No directory found matching serene-pub-*-${{ matrix.target }}"
|
|
ls -la
|
|
exit 1
|
|
fi
|
|
cat > "$DIST_DIR/.env.example" << 'EOF'
|
|
# Serene Pub 0.4.1 - Production Configuration
|
|
# Copy this file to .env in the same directory to customize settings
|
|
|
|
# ===========================================
|
|
# APPLICATION DATA DIRECTORY
|
|
# ===========================================
|
|
# Override default data directory location
|
|
# Default: OS-appropriate directory (~/.local/share/SerenePub on Linux, %APPDATA%/SerenePub on Windows, ~/Library/Application Support/SerenePub on macOS)
|
|
# Example for custom location:
|
|
# SERENE_PUB_DATA_DIR=/path/to/custom/data
|
|
|
|
# ===========================================
|
|
# SERVER CONFIGURATION
|
|
# ===========================================
|
|
# WebSocket server port
|
|
# Default: 3001
|
|
# SOCKETS_PORT=3001
|
|
|
|
# HTTP server port (main application)
|
|
# Default: 3000
|
|
# PORT=3000
|
|
|
|
# Disable automatic browser opening
|
|
# Default: Opens browser automatically on startup
|
|
# Set to 1 to disable auto-open
|
|
# SERENE_AUTO_OPEN=1
|
|
EOF
|
|
|
|
- name: Zip dist directory (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
cd dist
|
|
$distDir = Get-ChildItem -Directory -Name "serene-pub-*-${{ matrix.target }}" | Select-Object -First 1
|
|
if (-not $distDir) {
|
|
Write-Error "No directory found matching serene-pub-*-${{ matrix.target }}"
|
|
Get-ChildItem
|
|
exit 1
|
|
}
|
|
Compress-Archive -Path $distDir -DestinationPath "../serene-pub-${{ github.ref_name }}-${{ matrix.target }}.zip"
|
|
|
|
- name: Zip dist directory (Unix)
|
|
if: runner.os != 'Windows'
|
|
shell: bash
|
|
run: |
|
|
cd dist
|
|
DIST_DIR=$(ls -d serene-pub-*-${{ matrix.target }} 2>/dev/null | head -1)
|
|
if [ -z "$DIST_DIR" ]; then
|
|
echo "Error: No directory found matching serene-pub-*-${{ matrix.target }}"
|
|
ls -la
|
|
exit 1
|
|
fi
|
|
zip -r "../serene-pub-${{ github.ref_name }}-${{ matrix.target }}.zip" "$DIST_DIR"
|
|
|
|
- name: Upload release assets
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: serene-pub-*.zip
|
|
prerelease: ${{ contains(github.ref, 'alpha') }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|