1111env :
1212 REGISTRY : ghcr.io
1313 IMAGE_NAME : ${{ github.repository }}
14- NODE_VERSION : ' 18'
1514
1615jobs :
17- build :
16+ test-frontend :
1817 runs-on : ubuntu-latest
19- permissions :
20- contents : write
21- packages : write
22- id-token : write
23- attestations : write
2418
2519 steps :
2620 - name : Checkout repository
@@ -29,33 +23,74 @@ jobs:
2923 - name : Set up Node.js
3024 uses : actions/setup-node@v4
3125 with :
32- node-version : ${{ env.NODE_VERSION }}
26+ node-version : ' 20 '
3327 cache : ' npm'
28+ cache-dependency-path : frontend/package-lock.json
3429
35- - name : Install dependencies
30+ - name : Install frontend dependencies
31+ working-directory : ./frontend
3632 run : npm ci
3733
38- - name : Run linting
34+ - name : Run frontend linting
35+ working-directory : ./frontend
3936 run : npm run lint
4037
41- - name : Run type checking
38+ - name : Run frontend type checking
39+ working-directory : ./frontend
4240 run : npm run type-check
4341
44- - name : Build application
42+ - name : Build frontend
43+ working-directory : ./frontend
4544 run : npm run build
45+
46+ test-backend :
47+ runs-on : ubuntu-latest
48+
49+ steps :
50+ - name : Checkout repository
51+ uses : actions/checkout@v4
52+
53+ - name : Set up Go
54+ uses : actions/setup-go@v4
55+ with :
56+ go-version : ' 1.21'
57+ cache-dependency-path : backend/go.sum
58+
59+ - name : Install backend dependencies
60+ working-directory : ./backend
61+ run : go mod download
62+
63+ - name : Run backend tests
64+ working-directory : ./backend
65+ run : go test ./...
4666
47- - name : Create build archive
48- if : github.event_name == 'release'
67+ - name : Run backend linting
68+ working-directory : ./backend
4969 run : |
50- tar -czf tsflow-build.tar.gz dist/
51- sha256sum tsflow-build.tar.gz > checksums.txt
70+ go fmt ./...
71+ go vet ./...
72+
73+ - name : Build backend
74+ working-directory : ./backend
75+ run : go build -o tsflow-backend ./main.go
76+
77+ build-and-push :
78+ runs-on : ubuntu-latest
79+ needs : [test-frontend, test-backend]
80+ permissions :
81+ contents : read
82+ packages : write
83+ id-token : write
84+ attestations : write
85+
86+ steps :
87+ - name : Checkout repository
88+ uses : actions/checkout@v4
5289
5390 - name : Set up Docker Buildx
54- if : github.event_name != 'pull_request'
5591 uses : docker/setup-buildx-action@v3
5692
5793 - name : Convert repository name to lowercase
58- if : github.event_name != 'pull_request'
5994 run : |
6095 echo "IMAGE_NAME_LOWER=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
6196
@@ -65,61 +100,193 @@ jobs:
65100 with :
66101 registry : ${{ env.REGISTRY }}
67102 username : ${{ github.actor }}
68- password : ${{ secrets.GH_TOKEN }}
103+ password : ${{ secrets.GITHUB_TOKEN }}
104+
105+ - name : Extract metadata
106+ id : meta
107+ uses : docker/metadata-action@v5
108+ with :
109+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}
110+ tags : |
111+ type=ref,event=branch
112+ type=ref,event=pr
113+ type=sha
114+ type=raw,value=latest,enable={{is_default_branch}}
69115
70116 - name : Build and push Docker image
71- if : github.event_name != 'pull_request'
117+ id : build
72118 uses : docker/build-push-action@v5
73119 with :
74120 context : .
75121 platforms : linux/amd64,linux/arm64
76- push : true
77- tags : |
78- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:latest
79- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:${{ github.sha }}
80- labels : |
81- org.opencontainers.image.source=${{ github.event.repository.html_url }}
82- org.opencontainers.image.revision=${{ github.sha }}
83- org.opencontainers.image.title=TSFlow
84- org.opencontainers.image.description=Tailscale Network Flow Visualizer
122+ push : ${{ github.event_name != 'pull_request' }}
123+ tags : ${{ steps.meta.outputs.tags }}
124+ labels : ${{ steps.meta.outputs.labels }}
85125 cache-from : type=gha
86126 cache-to : type=gha,mode=max
87127
128+ - name : Generate artifact attestation
129+ if : github.event_name != 'pull_request'
130+ uses : actions/attest-build-provenance@v1
131+ with :
132+ subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}
133+ subject-digest : ${{ steps.build.outputs.digest }}
134+ push-to-registry : true
135+
136+ release :
137+ runs-on : ubuntu-latest
138+ needs : [build-and-push]
139+ if : github.event_name == 'release'
140+ permissions :
141+ contents : write
142+
143+ steps :
144+ - name : Checkout repository
145+ uses : actions/checkout@v4
146+
147+ - name : Set up Node.js
148+ uses : actions/setup-node@v4
149+ with :
150+ node-version : ' 20'
151+ cache : ' npm'
152+ cache-dependency-path : frontend/package-lock.json
153+
154+ - name : Set up Go
155+ uses : actions/setup-go@v4
156+ with :
157+ go-version : ' 1.21'
158+ cache-dependency-path : backend/go.sum
159+
160+ - name : Build frontend
161+ working-directory : ./frontend
162+ run : |
163+ npm ci
164+ npm run build
165+
166+ - name : Build backend binaries
167+ working-directory : ./backend
168+ run : |
169+ go mod download
170+
171+ # Build for multiple platforms
172+ GOOS=linux GOARCH=amd64 go build -o ../dist/tsflow-linux-amd64 ./main.go
173+ GOOS=linux GOARCH=arm64 go build -o ../dist/tsflow-linux-arm64 ./main.go
174+ GOOS=darwin GOARCH=amd64 go build -o ../dist/tsflow-darwin-amd64 ./main.go
175+ GOOS=darwin GOARCH=arm64 go build -o ../dist/tsflow-darwin-arm64 ./main.go
176+ GOOS=windows GOARCH=amd64 go build -o ../dist/tsflow-windows-amd64.exe ./main.go
177+
178+ - name : Create release archives
179+ run : |
180+ mkdir -p release
181+
182+ # Create frontend build archive
183+ cd frontend
184+ tar -czf ../release/tsflow-frontend-${{ github.ref_name }}.tar.gz dist/
185+ cd ..
186+
187+ # Create combined archive with frontend + backend binaries
188+ mkdir -p tsflow-${{ github.ref_name }}
189+ cp -r frontend/dist tsflow-${{ github.ref_name }}/
190+ cp -r dist/* tsflow-${{ github.ref_name }}/
191+ cp docker-compose.yml tsflow-${{ github.ref_name }}/
192+ cp env.example tsflow-${{ github.ref_name }}/
193+ cp README.md tsflow-${{ github.ref_name }}/
194+
195+ tar -czf release/tsflow-${{ github.ref_name }}.tar.gz tsflow-${{ github.ref_name }}/
196+
197+ # Generate checksums
198+ cd release
199+ sha256sum *.tar.gz > checksums.txt
200+ cd ..
201+
202+ - name : Convert repository name to lowercase
203+ run : |
204+ echo "IMAGE_NAME_LOWER=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
205+
88206 - name : Upload release assets
89- if : github.event_name == 'release'
90207 uses : softprops/action-gh-release@v1
91208 with :
92209 files : |
93- tsflow-build .tar.gz
94- checksums.txt
210+ release/* .tar.gz
211+ release/ checksums.txt
95212 body : |
96213 ## TSFlow ${{ github.ref_name }}
97214
98215 A modern web application for visualizing and analyzing network traffic flows within Tailscale networks.
99216
100- ### Docker Installation
217+ ### 🐳 Docker Installation (Recommended)
218+
219+ **Quick Start:**
220+ ```bash
221+ # Create environment file
222+ curl -o .env https://raw.githubusercontent.com/${{ github.repository }}/main/env.example
223+ # Edit .env with your Tailscale credentials
224+
225+ # Run with Docker
226+ docker run -d \
227+ -p 8080:8080 \
228+ --env-file .env \
229+ --name tsflow \
230+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:${{ github.ref_name }}
231+ ```
232+
233+ **Docker Compose:**
101234 ```bash
102- docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:latest
103- docker run -p 3000:3000 -p 3001:3001 \
104- -e TAILSCALE_TAILNET="your-tailnet" \
105- -e TAILSCALE_ACCESS_TOKEN="your-access-token" \
106- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:latest
235+ # Download and extract release
236+ wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/tsflow-${{ github.ref_name }}.tar.gz
237+ tar -xzf tsflow-${{ github.ref_name }}.tar.gz
238+ cd tsflow-${{ github.ref_name }}
239+
240+ # Configure environment
241+ cp env.example .env
242+ # Edit .env with your credentials
243+
244+ # Run with Docker Compose
245+ docker-compose up -d
107246 ```
108247
109- ### Manual Installation
110- 1. Download the build archive from the assets below
111- 2. Extract: `tar -xzf tsflow-build.tar.gz`
112- 3. Serve the `dist/` directory with any static file server
113- 4. Set up the API server separately using `server.js`
248+ ### 📦 Manual Installation
249+
250+ **Binary Installation:**
251+ 1. Download the appropriate binary for your platform from the assets below
252+ 2. Download the frontend build: `tsflow-frontend-${{ github.ref_name }}.tar.gz`
253+ 3. Extract frontend: `tar -xzf tsflow-frontend-${{ github.ref_name }}.tar.gz`
254+ 4. Set environment variables (see `env.example`)
255+ 5. Run the binary: `./tsflow-<platform>`
256+
257+ **Supported Platforms:**
258+ - Linux (amd64, arm64)
259+ - macOS (amd64, arm64)
260+ - Windows (amd64)
261+
262+ ### 🛠 Development Setup
114263
115- ### Development Setup
116264 ```bash
117265 git clone https://github.com/${{ github.repository }}.git
118266 cd tsflow
119- npm install
120- npm run dev:full
267+
268+ # Backend
269+ cd backend && go mod download && go run main.go &
270+
271+ # Frontend
272+ cd frontend && npm install && npm run build
121273 ```
274+
275+ ### 📋 What's Included
276+
277+ - **Go Backend**: High-performance API server with Tailscale integration
278+ - **React Frontend**: Modern web interface with real-time visualization
279+ - **Docker Support**: Production-ready containerization
280+ - **Multi-platform Binaries**: Native builds for all major platforms
281+
282+ ### 🚀 Features
283+
284+ - Real-time network topology visualization
285+ - Comprehensive traffic analytics and filtering
286+ - Device management and monitoring
287+ - No CORS issues (backend handles all API calls)
288+ - Production-ready architecture
122289 draft : false
123290 prerelease : false
124291 env :
125- GH_TOKEN : ${{ secrets.GH_TOKEN }}
292+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments