Skip to content

Commit 603e6d8

Browse files
authored
Merge pull request #1 from simota/feature/release-setup
Add release infrastructure and build tooling
2 parents 5d91b03 + 2c40818 commit 603e6d8

5 files changed

Lines changed: 206 additions & 10 deletions

File tree

.github/workflows/release.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: "1.20"
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "20"
29+
30+
- name: Install pnpm
31+
uses: pnpm/action-setup@v4
32+
with:
33+
version: 10
34+
35+
- name: Run GoReleaser
36+
uses: goreleaser/goreleaser-action@v6
37+
with:
38+
distribution: goreleaser
39+
version: "~> v2"
40+
args: release --clean
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
# Build frontend before Go build
7+
- sh -c "cd web && pnpm install && pnpm run build"
8+
9+
builds:
10+
- id: devrouter
11+
main: ./cmd/devrouter
12+
binary: devrouter
13+
env:
14+
- CGO_ENABLED=0
15+
goos:
16+
- linux
17+
- darwin
18+
goarch:
19+
- amd64
20+
- arm64
21+
ldflags:
22+
- -s -w
23+
- -X main.version={{ .Version }}
24+
- -X main.commit={{ .ShortCommit }}
25+
- -X main.buildDate={{ .Date }}
26+
27+
archives:
28+
- id: default
29+
format: tar.gz
30+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
31+
files:
32+
- LICENSE
33+
- README.md
34+
35+
checksum:
36+
name_template: "checksums.txt"
37+
38+
changelog:
39+
sort: asc
40+
filters:
41+
exclude:
42+
- "^docs:"
43+
- "^test:"
44+
- "^ci:"
45+
- "^chore:"
46+
47+
release:
48+
github:
49+
owner: simota
50+
name: devrouter
51+
draft: false
52+
prerelease: auto
53+
name_template: "v{{ .Version }}"

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.PHONY: all build build-frontend build-go clean dev install test lint help
2+
3+
# Version info
4+
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
5+
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
6+
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
7+
8+
# Build flags
9+
LDFLAGS := -s -w \
10+
-X main.version=$(VERSION) \
11+
-X main.commit=$(COMMIT) \
12+
-X main.buildDate=$(DATE)
13+
14+
# Default target
15+
all: build
16+
17+
# Build everything (frontend + Go binary)
18+
build: build-frontend build-go
19+
20+
# Build frontend assets
21+
build-frontend:
22+
@echo "Building frontend..."
23+
cd web && pnpm install && pnpm run build
24+
25+
# Build Go binary (requires frontend to be built first)
26+
build-go:
27+
@echo "Building Go binary..."
28+
go build -ldflags "$(LDFLAGS)" -o devrouter ./cmd/devrouter
29+
30+
# Install binary to $GOPATH/bin
31+
install: build
32+
@echo "Installing devrouter..."
33+
go install -ldflags "$(LDFLAGS)" ./cmd/devrouter
34+
35+
# Clean build artifacts
36+
clean:
37+
@echo "Cleaning..."
38+
rm -f devrouter
39+
rm -rf internal/devrouter/web/dist/assets
40+
rm -f internal/devrouter/web/dist/index.html
41+
42+
# Run frontend dev server
43+
dev:
44+
cd web && pnpm run dev
45+
46+
# Run tests
47+
test:
48+
go test ./...
49+
cd web && pnpm run test
50+
51+
# Run linters
52+
lint:
53+
go vet ./...
54+
cd web && pnpm run check
55+
56+
# Help
57+
help:
58+
@echo "Available targets:"
59+
@echo " make build - Build frontend and Go binary"
60+
@echo " make build-frontend - Build frontend only"
61+
@echo " make build-go - Build Go binary only (requires frontend)"
62+
@echo " make install - Build and install to GOPATH/bin"
63+
@echo " make clean - Remove build artifacts"
64+
@echo " make dev - Run frontend dev server"
65+
@echo " make test - Run all tests"
66+
@echo " make lint - Run linters"

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ A local development router that eliminates port conflicts without modifying your
1717
## Quick Start
1818

1919
```bash
20-
# Install
21-
go install github.com/simota/devrouter/cmd/devrouter@latest
20+
# Install (download binary from GitHub Releases or build from source)
21+
# See Installation section below
2222

2323
# Start the global Traefik proxy
2424
devrouter daemon up
@@ -39,25 +39,51 @@ devrouter down /path/to/your/monorepo
3939
- macOS / Linux
4040
- Docker (Docker Desktop or Colima)
4141
- `docker` CLI with `docker compose`
42-
- Go 1.20+ (for building from source)
42+
43+
### Build Requirements (for building from source)
44+
45+
- Go 1.20+
46+
- Node.js 18+
47+
- pnpm (`npm install -g pnpm`)
4348

4449
## Installation
4550

46-
### From Source
51+
### Download Binary (Recommended)
52+
53+
Download the latest binary from [GitHub Releases](https://github.com/simota/devrouter/releases):
4754

4855
```bash
49-
go install github.com/simota/devrouter/cmd/devrouter@latest
56+
# macOS (Apple Silicon)
57+
curl -L https://github.com/simota/devrouter/releases/latest/download/devrouter_darwin_arm64.tar.gz | tar xz
58+
sudo mv devrouter /usr/local/bin/
59+
60+
# macOS (Intel)
61+
curl -L https://github.com/simota/devrouter/releases/latest/download/devrouter_darwin_amd64.tar.gz | tar xz
62+
sudo mv devrouter /usr/local/bin/
63+
64+
# Linux (amd64)
65+
curl -L https://github.com/simota/devrouter/releases/latest/download/devrouter_linux_amd64.tar.gz | tar xz
66+
sudo mv devrouter /usr/local/bin/
5067
```
5168

52-
### Build Locally
69+
### Build from Source
70+
71+
> **Note**: `go install github.com/simota/devrouter/cmd/devrouter@latest` does not work because the Web UI frontend assets need to be built first and embedded into the binary.
5372
5473
```bash
5574
git clone https://github.com/simota/devrouter.git
5675
cd devrouter
57-
go build -o devrouter ./cmd/devrouter
76+
make build
77+
sudo mv devrouter /usr/local/bin/
78+
```
79+
80+
Or install directly to `$GOPATH/bin`:
81+
82+
```bash
83+
make install
5884
```
5985

60-
The binary is placed in `$GOBIN` (or `$GOPATH/bin` if `GOBIN` is not set). Ensure it's in your `PATH`.
86+
Ensure `/usr/local/bin` or `$GOPATH/bin` is in your `PATH`.
6187

6288
## CLI Commands
6389

cmd/devrouter/main.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ import (
77
"os"
88
"os/signal"
99
"path/filepath"
10+
"runtime"
1011
"strings"
1112
"syscall"
1213
"time"
1314

1415
"devrouter/internal/devrouter"
1516
)
1617

17-
const version = "0.1.0"
18+
// Build-time variables (injected via ldflags)
19+
var (
20+
version = "dev"
21+
commit = "unknown"
22+
buildDate = "unknown"
23+
)
1824

1925
func main() {
2026
os.Exit(run())
@@ -31,7 +37,10 @@ func run() int {
3137
usage()
3238
return 0
3339
case "-v", "--version", "version":
34-
fmt.Println(version)
40+
fmt.Printf("devrouter %s\n", version)
41+
fmt.Printf(" commit: %s\n", commit)
42+
fmt.Printf(" built: %s\n", buildDate)
43+
fmt.Printf(" go: %s\n", runtime.Version())
3544
return 0
3645
case "up":
3746
return runUp(os.Args[2:])

0 commit comments

Comments
 (0)