|
| 1 | +name: Deploy to GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pages: write |
| 12 | + id-token: write |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: "pages" |
| 16 | + cancel-in-progress: false |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + name: Build Examples |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Go |
| 26 | + uses: actions/setup-go@v5 |
| 27 | + with: |
| 28 | + go-version: '1.25' |
| 29 | + |
| 30 | + - name: Build CLI |
| 31 | + run: go build -o guix ./cmd/guix |
| 32 | + |
| 33 | + - name: Generate components |
| 34 | + run: ./guix generate -p examples/counter |
| 35 | + |
| 36 | + - name: Copy wasm_exec.js |
| 37 | + run: | |
| 38 | + GOROOT="$(go env GOROOT)" |
| 39 | + # Try lib/wasm first (Go 1.24+), then misc/wasm (older versions) |
| 40 | + if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then |
| 41 | + cp "$GOROOT/lib/wasm/wasm_exec.js" examples/counter/ |
| 42 | + elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then |
| 43 | + cp "$GOROOT/misc/wasm/wasm_exec.js" examples/counter/ |
| 44 | + else |
| 45 | + echo "wasm_exec.js not found in GOROOT, downloading from GitHub" |
| 46 | + curl -o examples/counter/wasm_exec.js https://raw.githubusercontent.com/golang/go/go1.25.0/lib/wasm/wasm_exec.js |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Build WASM |
| 50 | + working-directory: examples/counter |
| 51 | + run: GOOS=js GOARCH=wasm go build -o main.wasm . |
| 52 | + |
| 53 | + - name: Create Pages structure |
| 54 | + run: | |
| 55 | + mkdir -p _site |
| 56 | + mkdir -p _site/counter |
| 57 | + cp examples/counter/index.html _site/counter/ |
| 58 | + cp examples/counter/main.wasm _site/counter/ |
| 59 | + cp examples/counter/wasm_exec.js _site/counter/ |
| 60 | +
|
| 61 | + # Create index page with links to examples |
| 62 | + cat > _site/index.html << 'EOF' |
| 63 | + <!DOCTYPE html> |
| 64 | + <html lang="en"> |
| 65 | + <head> |
| 66 | + <meta charset="UTF-8"> |
| 67 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 68 | + <title>Guix Examples</title> |
| 69 | + <style> |
| 70 | + body { |
| 71 | + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; |
| 72 | + max-width: 800px; |
| 73 | + margin: 50px auto; |
| 74 | + padding: 20px; |
| 75 | + background: #f5f5f5; |
| 76 | + } |
| 77 | + .container { |
| 78 | + background: white; |
| 79 | + border-radius: 8px; |
| 80 | + padding: 30px; |
| 81 | + box-shadow: 0 2px 10px rgba(0,0,0,0.1); |
| 82 | + } |
| 83 | + h1 { color: #333; margin-top: 0; } |
| 84 | + .examples { |
| 85 | + list-style: none; |
| 86 | + padding: 0; |
| 87 | + } |
| 88 | + .examples li { |
| 89 | + margin: 15px 0; |
| 90 | + } |
| 91 | + .examples a { |
| 92 | + display: block; |
| 93 | + padding: 15px; |
| 94 | + background: #007bff; |
| 95 | + color: white; |
| 96 | + text-decoration: none; |
| 97 | + border-radius: 4px; |
| 98 | + transition: background 0.2s; |
| 99 | + } |
| 100 | + .examples a:hover { |
| 101 | + background: #0056b3; |
| 102 | + } |
| 103 | + .info { |
| 104 | + background: #e3f2fd; |
| 105 | + padding: 15px; |
| 106 | + border-radius: 4px; |
| 107 | + margin: 20px 0; |
| 108 | + } |
| 109 | + code { |
| 110 | + background: #f5f5f5; |
| 111 | + padding: 2px 6px; |
| 112 | + border-radius: 3px; |
| 113 | + font-family: 'Courier New', monospace; |
| 114 | + } |
| 115 | + </style> |
| 116 | + </head> |
| 117 | + <body> |
| 118 | + <div class="container"> |
| 119 | + <h1>🚀 Guix Examples</h1> |
| 120 | + <p><strong>Guix</strong> - Go-based UI language transpiling to WebAssembly</p> |
| 121 | +
|
| 122 | + <div class="info"> |
| 123 | + <h3>About Guix</h3> |
| 124 | + <p> |
| 125 | + Guix lets you write UI components in Go-like syntax that compile to WebAssembly. |
| 126 | + Features include virtual DOM, reactive state, and type-safe event handling. |
| 127 | + </p> |
| 128 | + </div> |
| 129 | +
|
| 130 | + <h2>Live Examples</h2> |
| 131 | + <ul class="examples"> |
| 132 | + <li> |
| 133 | + <a href="./counter/"> |
| 134 | + <strong>Counter</strong> - Basic component with props and template interpolation |
| 135 | + </a> |
| 136 | + </li> |
| 137 | + </ul> |
| 138 | +
|
| 139 | + <div class="info"> |
| 140 | + <h3>Learn More</h3> |
| 141 | + <p> |
| 142 | + Visit the <a href="https://github.com/gaarutyunov/guix">GitHub repository</a> |
| 143 | + for documentation, source code, and more examples. |
| 144 | + </p> |
| 145 | + </div> |
| 146 | + </div> |
| 147 | + </body> |
| 148 | + </html> |
| 149 | + EOF |
| 150 | +
|
| 151 | + - name: Setup Pages |
| 152 | + uses: actions/configure-pages@v4 |
| 153 | + |
| 154 | + - name: Upload artifact |
| 155 | + uses: actions/upload-pages-artifact@v3 |
| 156 | + with: |
| 157 | + path: '_site' |
| 158 | + |
| 159 | + deploy: |
| 160 | + name: Deploy to GitHub Pages |
| 161 | + environment: |
| 162 | + name: github-pages |
| 163 | + url: ${{ steps.deployment.outputs.page_url }} |
| 164 | + runs-on: ubuntu-latest |
| 165 | + needs: build |
| 166 | + steps: |
| 167 | + - name: Deploy to GitHub Pages |
| 168 | + id: deployment |
| 169 | + uses: actions/deploy-pages@v4 |
0 commit comments