|
1 | 1 | name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - "v*" # Trigger on version tags like v0.1.0, v1.2.3 |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" # Trigger on version tags like v0.1.0, v1.2.3 |
7 | 7 |
|
8 | 8 | permissions: |
9 | | - contents: write # Required for creating releases |
| 9 | + contents: write # Required for creating releases |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - test: |
13 | | - name: Run Tests |
14 | | - runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - name: Checkout code |
17 | | - uses: actions/checkout@v5 |
18 | | - |
19 | | - - name: Set up Go |
20 | | - uses: actions/setup-go@v5 |
21 | | - with: |
22 | | - go-version: "1.24" |
23 | | - |
24 | | - - name: Run tests |
25 | | - run: go test -v ./... |
26 | | - |
27 | | - release: |
28 | | - name: Build and Release |
29 | | - needs: test # Only run if tests pass |
30 | | - runs-on: ubuntu-latest |
31 | | - steps: |
32 | | - - name: Checkout code |
33 | | - uses: actions/checkout@v5 |
34 | | - |
35 | | - - name: Set up Go |
36 | | - uses: actions/setup-go@v5 |
37 | | - with: |
38 | | - go-version: "1.24" |
39 | | - |
40 | | - - name: Build binaries for all platforms |
41 | | - run: | |
42 | | - # Get version from tag (GitHub sets GITHUB_REF to refs/tags/v0.1.0) |
43 | | - VERSION=${GITHUB_REF#refs/tags/} |
44 | | - COMMIT=$(git rev-parse --short HEAD) |
45 | | - BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
46 | | - GO_VERSION=$(go version | awk '{print $3}') |
47 | | -
|
48 | | - echo "Building version: ${VERSION}" |
49 | | -
|
50 | | - # Build flags |
51 | | - LDFLAGS="-X main.version=${VERSION} -X main.gitCommit=${COMMIT} -X main.buildTime=${BUILD_TIME} -X main.goVersion=${GO_VERSION} -w -s" |
52 | | -
|
53 | | - # Create output directory |
54 | | - mkdir -p dist |
55 | | -
|
56 | | - # Linux amd64 |
57 | | - echo "Building Linux amd64..." |
58 | | - GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-linux-amd64 ./cmd/devenv |
59 | | -
|
60 | | - # macOS amd64 (Intel) |
61 | | - echo "Building macOS amd64..." |
62 | | - GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-darwin-amd64 ./cmd/devenv |
63 | | -
|
64 | | - # macOS arm64 (Apple Silicon) |
65 | | - echo "Building macOS arm64..." |
66 | | - GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o dist/devenv-darwin-arm64 ./cmd/devenv |
67 | | -
|
68 | | - # Windows amd64 |
69 | | - echo "Building Windows amd64..." |
70 | | - GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-windows-amd64.exe ./cmd/devenv |
71 | | -
|
72 | | - echo "✅ All binaries built successfully" |
73 | | - ls -lh dist/ |
74 | | -
|
75 | | - - name: Create Release |
76 | | - uses: softprops/action-gh-release@v2 |
77 | | - with: |
78 | | - files: | |
79 | | - dist/devenv-linux-amd64 |
80 | | - dist/devenv-darwin-amd64 |
81 | | - dist/devenv-darwin-arm64 |
82 | | - dist/devenv-windows-amd64.exe |
83 | | - generate_release_notes: true |
84 | | - draft: false |
85 | | - prerelease: false |
| 12 | + test: |
| 13 | + name: Run Tests |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v5 |
| 18 | + |
| 19 | + - name: Set up Go |
| 20 | + uses: actions/setup-go@v5 |
| 21 | + with: |
| 22 | + go-version: "1.24" |
| 23 | + |
| 24 | + - name: Run tests |
| 25 | + run: go test -v ./... |
| 26 | + |
| 27 | + release: |
| 28 | + name: Build and Release |
| 29 | + needs: test # Only run if tests pass |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout code |
| 33 | + uses: actions/checkout@v5 |
| 34 | + |
| 35 | + - name: Set up Go |
| 36 | + uses: actions/setup-go@v5 |
| 37 | + with: |
| 38 | + go-version: "1.24" |
| 39 | + |
| 40 | + - name: Build binaries for all platforms |
| 41 | + run: | |
| 42 | + # Get version from tag (GitHub sets GITHUB_REF to refs/tags/v0.1.0) |
| 43 | + VERSION=${GITHUB_REF#refs/tags/} |
| 44 | + COMMIT=$(git rev-parse --short HEAD) |
| 45 | + BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 46 | + GO_VERSION=$(go version | awk '{print $3}') |
| 47 | +
|
| 48 | + echo "Building version: ${VERSION}" |
| 49 | +
|
| 50 | + # Build flags |
| 51 | + LDFLAGS="-X main.version=${VERSION} -X main.gitCommit=${COMMIT} -X main.buildTime=${BUILD_TIME} -X main.goVersion=${GO_VERSION} -w -s" |
| 52 | +
|
| 53 | + # Create output directory |
| 54 | + mkdir -p dist |
| 55 | +
|
| 56 | + # Linux amd64 |
| 57 | + echo "Building Linux amd64..." |
| 58 | + GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-linux-amd64 ./cmd/devenv |
| 59 | +
|
| 60 | + # macOS amd64 (Intel) |
| 61 | + echo "Building macOS amd64..." |
| 62 | + GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-darwin-amd64 ./cmd/devenv |
| 63 | +
|
| 64 | + # macOS arm64 (Apple Silicon) |
| 65 | + echo "Building macOS arm64..." |
| 66 | + GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o dist/devenv-darwin-arm64 ./cmd/devenv |
| 67 | +
|
| 68 | + # Windows amd64 |
| 69 | + echo "Building Windows amd64..." |
| 70 | + GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/devenv-windows-amd64.exe ./cmd/devenv |
| 71 | +
|
| 72 | + echo "✅ All binaries built successfully" |
| 73 | + ls -lh dist/ |
| 74 | +
|
| 75 | + - name: Create Release |
| 76 | + uses: softprops/action-gh-release@v2 |
| 77 | + with: |
| 78 | + files: | |
| 79 | + dist/devenv-linux-amd64 |
| 80 | + dist/devenv-darwin-amd64 |
| 81 | + dist/devenv-darwin-arm64 |
| 82 | + dist/devenv-windows-amd64.exe |
| 83 | + generate_release_notes: true |
| 84 | + draft: false |
| 85 | + prerelease: false |
0 commit comments