Skip to content

Commit 9002fc3

Browse files
Stefan ErnstStefan Ernst
authored andcommitted
Switched to parallel arm runner
1 parent 860448c commit 9002fc3

2 files changed

Lines changed: 181 additions & 94 deletions

File tree

.github/workflows/docker.yml

Lines changed: 74 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ env:
1919

2020
jobs:
2121
build:
22-
name: Build & Push
23-
runs-on: ubuntu-latest
22+
name: Build (${{ matrix.platform }})
23+
runs-on: ${{ matrix.runner }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- platform: linux/amd64
29+
runner: ubuntu-latest
30+
- platform: linux/arm64
31+
runner: ubuntu-24.04-arm
2432
steps:
2533
- name: Checkout code
2634
uses: actions/checkout@v4
2735

28-
- name: Set up QEMU
29-
uses: docker/setup-qemu-action@v3
30-
3136
- name: Set up Docker Buildx
3237
uses: docker/setup-buildx-action@v3
3338

@@ -44,38 +49,76 @@ jobs:
4449
uses: docker/metadata-action@v5
4550
with:
4651
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47-
tags: |
48-
# Set latest tag for default branch
49-
type=raw,value=latest,enable={{is_default_branch}}
50-
# Branch name
51-
type=ref,event=branch
52-
# PR number
53-
type=ref,event=pr,prefix=pr-
54-
# Semantic versioning from tags
55-
type=semver,pattern={{version}}
56-
type=semver,pattern={{major}}.{{minor}}
57-
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
58-
# Git SHA
59-
type=sha,prefix=sha-
6052

61-
- name: Build and push
53+
- name: Build and push by digest
6254
id: build
6355
uses: docker/build-push-action@v6
6456
with:
6557
context: .
66-
platforms: linux/amd64,linux/arm64
67-
push: ${{ github.event_name != 'pull_request' }}
68-
tags: ${{ steps.meta.outputs.tags }}
58+
platforms: ${{ matrix.platform }}
6959
labels: ${{ steps.meta.outputs.labels }}
70-
cache-from: type=gha
71-
cache-to: type=gha,mode=max
72-
sbom: true
73-
provenance: mode=max
60+
cache-from: type=gha,scope=${{ matrix.platform }}
61+
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
62+
outputs: ${{ github.event_name != 'pull_request' && format('type=image,name={0},push-by-digest=true,name-canonical=true,push=true', format('{0}/{1}', env.REGISTRY, env.IMAGE_NAME)) || 'type=docker' }}
63+
64+
- name: Export digest
65+
if: github.event_name != 'pull_request'
66+
run: |
67+
mkdir -p /tmp/digests
68+
digest="${{ steps.build.outputs.digest }}"
69+
touch "/tmp/digests/${digest#sha256:}"
7470
75-
- name: Generate artifact attestation
71+
- name: Upload digest
7672
if: github.event_name != 'pull_request'
77-
uses: actions/attest-build-provenance@v2
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
76+
path: /tmp/digests/*
77+
if-no-files-found: error
78+
retention-days: 1
79+
80+
merge:
81+
name: Merge Manifests
82+
runs-on: ubuntu-latest
83+
if: github.event_name != 'pull_request'
84+
needs: build
85+
steps:
86+
- name: Download digests
87+
uses: actions/download-artifact@v4
88+
with:
89+
path: /tmp/digests
90+
pattern: digests-*
91+
merge-multiple: true
92+
93+
- name: Set up Docker Buildx
94+
uses: docker/setup-buildx-action@v3
95+
96+
- name: Log in to Container Registry
97+
uses: docker/login-action@v3
98+
with:
99+
registry: ${{ env.REGISTRY }}
100+
username: ${{ github.actor }}
101+
password: ${{ secrets.GITHUB_TOKEN }}
102+
103+
- name: Extract metadata
104+
id: meta
105+
uses: docker/metadata-action@v5
78106
with:
79-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
80-
subject-digest: ${{ steps.build.outputs.digest }}
81-
push-to-registry: true
107+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
108+
tags: |
109+
type=raw,value=latest,enable={{is_default_branch}}
110+
type=ref,event=branch
111+
type=semver,pattern={{version}}
112+
type=semver,pattern={{major}}.{{minor}}
113+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
114+
type=sha,prefix=sha-
115+
116+
- name: Create manifest list
117+
working-directory: /tmp/digests
118+
run: |
119+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
120+
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
121+
122+
- name: Inspect image
123+
run: |
124+
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

BUILD.md

Lines changed: 107 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@ This document explains how to build Windshift for multiple platforms.
44

55
## Quick Build
66

7-
### Build Everything (Recommended)
7+
### Using the Makefile (Recommended)
8+
89
```bash
9-
# Build both server and ws client for all platforms
10-
./build-all.sh
10+
# Build everything (frontend + server)
11+
make all
1112

12-
# Clean and build everything
13-
./build-all.sh --clean
13+
# Clean and rebuild
14+
make clean && make all
1415

15-
# Build only the server
16-
./build-all.sh --server-only
16+
# Build server only
17+
make build
1718

18-
# Build only the ws client
19-
./build-all.sh --client-only
19+
# Build frontend only
20+
make frontend
2021

21-
# Get help
22-
./build-all.sh --help
22+
# Show all available make targets
23+
make help
2324
```
2425

2526
### Manual Build
27+
2628
```bash
2729
# Build frontend
2830
cd frontend
@@ -41,22 +43,69 @@ cd ../..
4143

4244
## Build Output
4345

44-
The build script creates the following structure:
46+
### Development Builds (Makefile)
47+
48+
The Makefile produces binaries in the project root:
49+
50+
```
51+
windshift # Main server binary (current platform)
52+
windshift_unix # Linux binary (from make build-linux)
53+
windshift.exe # Windows binary (from make build-windows)
54+
```
55+
56+
### Release Builds (release.sh)
57+
58+
The release script creates a `dist/` structure:
4559

4660
```
4761
dist/
48-
├── server/
62+
├── binaries/
4963
│ ├── windshift-linux-amd64
5064
│ ├── windshift-linux-arm64
5165
│ ├── windshift-windows-amd64.exe
5266
│ ├── windshift-darwin-amd64
5367
│ └── windshift-darwin-arm64
54-
└── client/
55-
├── ws-linux-amd64
56-
├── ws-linux-arm64
57-
├── ws-windows-amd64.exe
58-
├── ws-darwin-amd64
59-
└── ws-darwin-arm64
68+
└── releases/
69+
├── windshift-v1.0.0-linux-amd64.tar.gz
70+
├── windshift-v1.0.0-linux-arm64.tar.gz
71+
├── windshift-v1.0.0-windows-amd64.zip
72+
├── windshift-v1.0.0-darwin-amd64.tar.gz
73+
├── windshift-v1.0.0-darwin-arm64.tar.gz
74+
└── SHA256SUMS.txt
75+
```
76+
77+
## Cross-Platform/Release Builds
78+
79+
### Using the Makefile
80+
81+
```bash
82+
# Cross-compile for Linux
83+
make build-linux
84+
85+
# Cross-compile for Windows
86+
make build-windows
87+
```
88+
89+
### Using release.sh (Full Release)
90+
91+
```bash
92+
# Full release with binaries + Docker + GitHub release
93+
./release.sh release -v v1.0.0 -n releases/v1.0.0.md
94+
95+
# Build binaries and packages locally (no publish)
96+
./release.sh build -v v1.0.0
97+
98+
# Build and push Docker images only
99+
./release.sh push -v v1.0.0-dev
100+
101+
# Dry run to preview actions
102+
./release.sh release -v v1.0.0 -n releases/v1.0.0.md --dry-run
103+
104+
# Skip frontend build (use existing dist/)
105+
./release.sh build --skip-frontend
106+
107+
# Show help
108+
./release.sh --help
60109
```
61110

62111
## Supported Platforms
@@ -69,24 +118,6 @@ dist/
69118
| macOS (Intel) |||
70119
| macOS (Apple Silicon) |||
71120

72-
## Cross-Compilation
73-
74-
Go makes cross-compilation easy. You can build for any platform from any platform:
75-
76-
```bash
77-
# Build server for Linux from macOS/Windows
78-
GOOS=linux GOARCH=amd64 go build -o windshift-linux main.go
79-
80-
# Build ws client for Windows from Linux/macOS
81-
cd cmd/ws
82-
GOOS=windows GOARCH=amd64 go build -o ws-windows.exe
83-
cd ../..
84-
85-
# Build for ARM64 (Apple Silicon, ARM Linux)
86-
GOOS=darwin GOARCH=arm64 go build -o windshift-darwin-arm64 main.go
87-
GOOS=linux GOARCH=arm64 go build -o windshift-linux-arm64 main.go
88-
```
89-
90121
## Build Requirements
91122

92123
### For Server + Frontend
@@ -97,45 +128,48 @@ GOOS=linux GOARCH=arm64 go build -o windshift-linux-arm64 main.go
97128
### For WS Client Only
98129
- **Go 1.21+** - Client compilation only
99130

131+
### For Cross-Compilation (release.sh)
132+
- **Zig** - Cross-compilation toolchain (optional, native builds work without it)
133+
- **Docker + Buildx** - Multi-arch Docker images
134+
100135
## Usage Examples
101136

102137
### Linux
103138
```bash
104-
# Extract and run
105-
tar -xzf windshift-linux-amd64.tar.gz
106-
./dist/server/windshift-linux-amd64 &
107-
./dist/client/ws-linux-amd64 workspace list
139+
# After building
140+
./windshift &
141+
./cmd/ws/ws workspace list
108142
```
109143

110144
### Windows
111145
```bash
112-
# Extract and run
113-
dist\server\windshift-windows-amd64.exe
114-
dist\client\ws-windows-amd64.exe workspace list
146+
# After building
147+
windshift.exe
148+
cmd\ws\ws.exe workspace list
115149
```
116150

117151
### macOS
118152
```bash
119-
# Extract and run
120-
./dist/server/windshift-darwin-arm64 &
121-
./dist/client/ws-darwin-arm64 workspace list
153+
# After building
154+
./windshift &
155+
./cmd/ws/ws workspace list
122156
```
123157

124158
## Build Optimization
125159

126-
The build script uses these Go build flags for production:
160+
Production builds use these Go build flags:
127161

128162
- `-ldflags "-s -w"` - Strip debug information and reduce binary size
163+
- `-tags="!test"` - Exclude test code from production binaries
129164
- Version information embedded at build time
130-
- Static linking for standalone binaries
131165

132166
## Troubleshooting
133167

134168
### Frontend Build Issues
135169
```bash
136170
# Clear npm cache and reinstall
137171
cd frontend
138-
rm -rf node_modules package-lock.json
172+
rm -rf node_modules package-lock.json
139173
npm install
140174
npm run build
141175
```
@@ -154,21 +188,31 @@ go clean -modcache
154188

155189
**Windows**: If you don't have `zip` command available, Windows archives won't be created but binaries will still build.
156190

157-
**macOS**: If you get permission errors, make sure the build script is executable:
158-
```bash
159-
chmod +x build-all.sh
160-
```
191+
**macOS**: Darwin binaries can only be built on macOS hosts due to CGO requirements.
161192

162193
**Linux**: Ensure you have sufficient disk space. Cross-compilation creates multiple large binaries.
163194

164-
## Build Script Features
195+
## Makefile Targets
196+
197+
Run `make help` to see all available targets:
198+
199+
**Production builds:**
200+
- `make build` - Build production binary (excludes test code)
201+
- `make build-linux` - Cross-compile for Linux
202+
- `make build-windows` - Cross-compile for Windows
203+
- `make release` - Full production release build
204+
205+
**Development builds:**
206+
- `make dev-build` - Development binary (includes test utils)
207+
- `make dev` - Full development cycle
165208

166-
- 🎯 **Smart Platform Detection** - Automatically builds for all supported platforms
167-
- 🧹 **Clean Builds** - Optional cleanup of previous builds
168-
- 📦 **Modular Building** - Build server-only or client-only
169-
- 🎨 **Colorized Output** - Clear progress indication
170-
- 📊 **Build Summary** - Shows file sizes and locations
171-
- 🔧 **Error Handling** - Stops on any build failure
172-
- 📋 **Documentation** - Generates usage examples
209+
**Testing:**
210+
- `make test` - Run all unit tests
211+
- `make test-coverage` - Run tests with coverage report
212+
- `make test-verbose` - Run tests with verbose output
173213

174-
The build script is production-ready and handles edge cases like missing dependencies, wrong directories, and cross-platform differences.
214+
**Utilities:**
215+
- `make frontend` - Build frontend only
216+
- `make clean` - Clean build artifacts
217+
- `make deps` - Update dependencies
218+
- `make verify-size` - Compare binary sizes with/without tests

0 commit comments

Comments
 (0)