✨ Supports being called by other repositories as an action
This commit is contained in:
39
.github/workflows/test-action.yml
vendored
Normal file
39
.github/workflows/test-action.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: 'Test Pake Action'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
url:
|
||||
description: 'URL to package'
|
||||
required: true
|
||||
default: 'https://weekly.tw93.fun'
|
||||
name:
|
||||
description: 'App name'
|
||||
required: true
|
||||
default: 'TestApp'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Build Pake App
|
||||
id: build
|
||||
uses: ./
|
||||
with:
|
||||
url: ${{ github.event.inputs.url }}
|
||||
name: ${{ github.event.inputs.name }}
|
||||
debug: true
|
||||
|
||||
- name: Upload Package
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: pake-app
|
||||
path: ${{ steps.build.outputs.package-path }}
|
||||
97
README_ACTION.md
Normal file
97
README_ACTION.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Pake GitHub Action
|
||||
|
||||
Transform any webpage into a lightweight desktop app with a single GitHub Actions step.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```yaml
|
||||
- name: Build Pake App
|
||||
uses: tw93/Pake@v3
|
||||
with:
|
||||
url: 'https://example.com'
|
||||
name: 'MyApp'
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
| Parameter | Description | Required | Default |
|
||||
|-----------|-------------|----------|---------|
|
||||
| `url` | Target URL to package | ✅ | |
|
||||
| `name` | Application name | ✅ | |
|
||||
| `output-dir` | Output directory | | `dist` |
|
||||
| `icon` | Custom app icon URL/path | | |
|
||||
| `width` | Window width | | `1200` |
|
||||
| `height` | Window height | | `780` |
|
||||
| `debug` | Enable debug mode | | `false` |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output | Description |
|
||||
|--------|-------------|
|
||||
| `package-path` | Path to the generated package |
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```yaml
|
||||
name: Build Web App
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: tw93/Pake@v3
|
||||
with:
|
||||
url: 'https://weekly.tw93.fun'
|
||||
name: 'WeeklyApp'
|
||||
```
|
||||
|
||||
### With Custom Icon
|
||||
|
||||
```yaml
|
||||
- uses: tw93/Pake@v3
|
||||
with:
|
||||
url: 'https://example.com'
|
||||
name: 'MyApp'
|
||||
icon: 'https://example.com/icon.png'
|
||||
width: 1400
|
||||
height: 900
|
||||
```
|
||||
|
||||
### Multi-Platform Build
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: tw93/Pake@v3
|
||||
with:
|
||||
url: 'https://example.com'
|
||||
name: 'CrossPlatformApp'
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Auto Setup**: Installs Rust, Node.js dependencies, builds Pake CLI
|
||||
2. **Build App**: Runs `pake` command with your parameters
|
||||
3. **Package Output**: Finds and moves the generated package to output directory
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
- **Linux**: `.deb` packages (Ubuntu runners)
|
||||
- **macOS**: `.app` and `.dmg` packages (macOS runners)
|
||||
- **Windows**: `.exe` and `.msi` packages (Windows runners)
|
||||
|
||||
Use GitHub's matrix strategy to build for multiple platforms simultaneously.
|
||||
|
||||
## Testing
|
||||
|
||||
Try the action with our test workflow: [test-action.yml](.github/workflows/test-action.yml)
|
||||
112
action.yml
Normal file
112
action.yml
Normal file
@@ -0,0 +1,112 @@
|
||||
name: 'Pake Web App Builder'
|
||||
description: 'Transform any webpage into a lightweight desktop app using Rust and Tauri'
|
||||
author: 'tw93'
|
||||
branding:
|
||||
icon: 'package'
|
||||
color: 'blue'
|
||||
|
||||
inputs:
|
||||
url:
|
||||
description: 'Target URL to package'
|
||||
required: true
|
||||
|
||||
name:
|
||||
description: 'Application name'
|
||||
required: true
|
||||
|
||||
output-dir:
|
||||
description: 'Output directory for packages'
|
||||
required: false
|
||||
default: 'dist'
|
||||
|
||||
icon:
|
||||
description: 'Custom app icon URL or path'
|
||||
required: false
|
||||
|
||||
width:
|
||||
description: 'Window width'
|
||||
required: false
|
||||
default: '1200'
|
||||
|
||||
height:
|
||||
description: 'Window height'
|
||||
required: false
|
||||
default: '780'
|
||||
|
||||
debug:
|
||||
description: 'Enable debug mode'
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
outputs:
|
||||
package-path:
|
||||
description: 'Path to the generated package'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Setup Environment
|
||||
shell: bash
|
||||
run: |
|
||||
# Install Node.js dependencies
|
||||
npm install
|
||||
|
||||
# Build Pake CLI if not exists
|
||||
if [ ! -f "dist/cli.js" ]; then
|
||||
npm run cli:build
|
||||
fi
|
||||
|
||||
# Ensure node is accessible in subsequent steps
|
||||
echo "$(npm bin)" >> $GITHUB_PATH
|
||||
|
||||
# Install Rust/Cargo if needed
|
||||
if ! command -v cargo &> /dev/null; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
source ~/.cargo/env
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
fi
|
||||
|
||||
- name: Build Pake App
|
||||
shell: bash
|
||||
run: |
|
||||
# Build arguments
|
||||
ARGS=("${{ inputs.url }}")
|
||||
|
||||
ARGS+=("--name" "${{ inputs.name }}")
|
||||
|
||||
if [ -n "${{ inputs.icon }}" ]; then
|
||||
ARGS+=("--icon" "${{ inputs.icon }}")
|
||||
fi
|
||||
|
||||
ARGS+=("--width" "${{ inputs.width }}")
|
||||
ARGS+=("--height" "${{ inputs.height }}")
|
||||
|
||||
if [ "${{ inputs.debug }}" == "true" ]; then
|
||||
ARGS+=("--debug")
|
||||
fi
|
||||
|
||||
# Create output directory
|
||||
mkdir -p "${{ inputs.output-dir }}"
|
||||
export PAKE_CREATE_APP=1
|
||||
|
||||
# Run Pake CLI
|
||||
echo "🔧 Running: node dist/cli.js ${ARGS[*]}"
|
||||
node dist/cli.js "${ARGS[@]}"
|
||||
|
||||
# Find generated package and set output
|
||||
PACKAGE=$(find src-tauri/target -type f \( -name "*.deb" -o -name "*.exe" -o -name "*.msi" -o -name "*.dmg" \) 2>/dev/null | head -1)
|
||||
|
||||
# If no file packages found, look for .app directory (macOS)
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
PACKAGE=$(find src-tauri/target -type d -name "*.app" 2>/dev/null | head -1)
|
||||
fi
|
||||
if [ -n "$PACKAGE" ]; then
|
||||
# Move to output directory
|
||||
BASENAME=$(basename "$PACKAGE")
|
||||
mv "$PACKAGE" "${{ inputs.output-dir }}/$BASENAME" 2>/dev/null || cp -r "$PACKAGE" "${{ inputs.output-dir }}/$BASENAME"
|
||||
echo "package-path=${{ inputs.output-dir }}/$BASENAME" >> $GITHUB_OUTPUT
|
||||
echo "✅ Package created: ${{ inputs.output-dir }}/$BASENAME"
|
||||
else
|
||||
echo "❌ No package found"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user