Skip to content

Commit 14b045a

Browse files
committed
fix: restore Docker build and add frontend build to Makefile
Restored the original GitHub Actions workflow that was accidentally simplified, which removed critical functionality: GitHub Actions Workflow (.github/workflows/release.yml): - Restored matrix build strategy for parallel platform builds - Re-added Docker image build and push to Docker Hub - Added workflow_dispatch trigger for manual runs - Added pull_request trigger for testing - Improved release notes with commit history - Added Docker installation instructions to release notes - Integrated git tag-based versioning into matrix builds Makefile Enhancements: - Added build-frontend target to build React web app - Modified build and build-release to depend on build-frontend - Added clean-all target to remove frontend artifacts - Now ensures web/dist/ exists before Go build embeds it Workflow Jobs: 1. build - Matrix build for all platforms with CGO support 2. docker - Build and push multi-arch Docker images 3. release - Create GitHub Release with binaries and notes This ensures both binaries and Docker images are published on release.
1 parent 9671e2a commit 14b045a

2 files changed

Lines changed: 229 additions & 85 deletions

File tree

.github/workflows/release.yml

Lines changed: 216 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
1-
name: Release
1+
name: Build and Release
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
47
push:
58
tags:
6-
- 'v*' # Triggers on version tags like v1.0.0, v2.1.3, etc.
9+
- "v*" # Triggers on version tags like v1.0.0
10+
workflow_dispatch:
711

812
permissions:
913
contents: write
1014

1115
jobs:
12-
release:
13-
name: Create Release
14-
runs-on: ubuntu-latest
16+
build:
17+
name: Build Binaries
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
include:
22+
- os: ubuntu-latest
23+
goos: linux
24+
goarch: amd64
25+
- os: ubuntu-latest
26+
goos: linux
27+
goarch: arm64
28+
- os: macos-latest
29+
goos: darwin
30+
goarch: amd64
31+
- os: macos-14
32+
goos: darwin
33+
goarch: arm64
34+
- os: ubuntu-latest
35+
goos: windows
36+
goarch: amd64
37+
1538
steps:
1639
- name: Checkout code
1740
uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
2041

2142
- name: Set up Go
22-
uses: actions/setup-go@v5
43+
uses: actions/setup-go@v4
2344
with:
24-
go-version: '1.21'
45+
go-version: "1.23"
2546

2647
- name: Set up Node.js
2748
uses: actions/setup-node@v4
2849
with:
29-
node-version: '18'
30-
cache: 'yarn'
50+
node-version: "18"
51+
cache: "yarn"
3152
cache-dependency-path: web/yarn.lock
3253

3354
- name: Install frontend dependencies
@@ -40,99 +61,213 @@ jobs:
4061
cd web
4162
yarn build
4263
64+
- name: Install cross-compilation tools
65+
run: |
66+
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
67+
sudo apt-get update
68+
if [ "${{ matrix.goos }}" = "windows" ]; then
69+
sudo apt-get install -y gcc-mingw-w64
70+
elif [ "${{ matrix.goos }}" = "linux" ] && [ "${{ matrix.goarch }}" = "arm64" ]; then
71+
sudo apt-get install -y gcc-aarch64-linux-gnu
72+
else
73+
sudo apt-get install -y gcc-multilib
74+
fi
75+
elif [[ "${{ matrix.os }}" == macos* ]]; then
76+
echo "Using native macOS compilation"
77+
fi
78+
79+
- name: Set up cross-compilation environment
80+
run: |
81+
if [ "${{ matrix.goos }}" = "windows" ]; then
82+
echo "CC=x86_64-w64-mingw32-gcc" >> $GITHUB_ENV
83+
elif [ "${{ matrix.goos }}" = "linux" ] && [ "${{ matrix.goarch }}" = "arm64" ]; then
84+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
85+
fi
86+
4387
- name: Get version from tag
4488
id: version
4589
run: |
46-
# Remove 'v' prefix from tag
47-
VERSION=${GITHUB_REF#refs/tags/v}
90+
# Get version from tag or use git describe
91+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
92+
VERSION=${GITHUB_REF#refs/tags/v}
93+
else
94+
VERSION=$(git describe --tags --always 2>/dev/null || echo "dev")
95+
fi
96+
COMMIT=$(git rev-parse --short HEAD)
97+
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
4898
echo "version=$VERSION" >> $GITHUB_OUTPUT
49-
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
99+
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
100+
echo "date=$DATE" >> $GITHUB_OUTPUT
50101
51-
- name: Build binaries
102+
- name: Build binary
103+
env:
104+
GOOS: ${{ matrix.goos }}
105+
GOARCH: ${{ matrix.goarch }}
106+
CGO_ENABLED: 1
52107
run: |
53-
# Build for multiple platforms
54-
VERSION=${{ steps.version.outputs.version }}
55-
COMMIT=$(git rev-parse --short HEAD)
56-
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
57-
LDFLAGS="-X main.version=$VERSION -X main.commit=$COMMIT -X main.date=$DATE"
108+
BINARY_NAME="vertex-${{ matrix.goos }}-${{ matrix.goarch }}"
109+
if [ "${{ matrix.goos }}" = "windows" ]; then
110+
BINARY_NAME="${BINARY_NAME}.exe"
111+
fi
112+
113+
LDFLAGS="-s -w -X main.version=${{ steps.version.outputs.version }} -X main.commit=${{ steps.version.outputs.commit }} -X main.date=${{ steps.version.outputs.date }}"
114+
go build -ldflags="$LDFLAGS" -o "${BINARY_NAME}"
115+
116+
if [[ "${{ matrix.os }}" == macos* ]]; then
117+
shasum -a 256 "${BINARY_NAME}" > "${BINARY_NAME}.sha256"
118+
else
119+
sha256sum "${BINARY_NAME}" > "${BINARY_NAME}.sha256"
120+
fi
121+
122+
- name: Upload artifacts
123+
if: github.event_name != 'pull_request'
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
127+
path: |
128+
vertex-${{ matrix.goos }}-${{ matrix.goarch }}*
129+
130+
docker:
131+
name: Build and Push Docker Images
132+
runs-on: ubuntu-latest
133+
if: startsWith(github.ref, 'refs/tags/')
134+
needs: build
135+
136+
steps:
137+
- name: Checkout code
138+
uses: actions/checkout@v4
58139

59-
# Linux amd64
60-
echo "Building for Linux amd64..."
61-
GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o vertex-linux-amd64 .
140+
- name: Set up Node.js
141+
uses: actions/setup-node@v4
142+
with:
143+
node-version: "18"
144+
cache: "yarn"
145+
cache-dependency-path: web/yarn.lock
146+
147+
- name: Build frontend
148+
run: |
149+
cd web
150+
yarn install --frozen-lockfile
151+
yarn build
152+
153+
- name: Set up Docker Buildx
154+
uses: docker/setup-buildx-action@v3
155+
156+
- name: Login to Docker Hub
157+
uses: docker/login-action@v3
158+
with:
159+
username: ${{ secrets.DOCKERHUB_USERNAME }}
160+
password: ${{ secrets.DOCKERHUB_TOKEN }}
161+
162+
- name: Extract metadata
163+
id: meta
164+
uses: docker/metadata-action@v5
165+
with:
166+
images: ${{ secrets.DOCKERHUB_USERNAME }}/vertex
167+
tags: |
168+
type=ref,event=tag
169+
type=raw,value=latest
170+
type=raw,value={{version}}
62171
63-
# Linux arm64
64-
echo "Building for Linux arm64..."
65-
GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS" -o vertex-linux-arm64 .
172+
- name: Build and push Docker image
173+
uses: docker/build-push-action@v5
174+
with:
175+
context: .
176+
platforms: linux/amd64,linux/arm64
177+
push: true
178+
tags: ${{ steps.meta.outputs.tags }}
179+
labels: ${{ steps.meta.outputs.labels }}
180+
cache-from: type=gha
181+
cache-to: type=gha,mode=max
182+
build-args: |
183+
BUILDKIT_INLINE_CACHE=1
66184
67-
# macOS amd64
68-
echo "Building for macOS amd64..."
69-
GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -o vertex-darwin-amd64 .
185+
release:
186+
name: Create Release
187+
needs: [build, docker]
188+
runs-on: ubuntu-latest
189+
if: startsWith(github.ref, 'refs/tags/')
70190

71-
# macOS arm64
72-
echo "Building for macOS arm64..."
73-
GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -o vertex-darwin-arm64 .
191+
steps:
192+
- name: Checkout code
193+
uses: actions/checkout@v4
194+
with:
195+
fetch-depth: 0
74196

75-
# Windows amd64
76-
echo "Building for Windows amd64..."
77-
GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o vertex-windows-amd64.exe .
197+
- name: Download all artifacts
198+
uses: actions/download-artifact@v4
199+
with:
200+
pattern: binaries-*
201+
merge-multiple: true
78202

79-
- name: Create checksums
203+
- name: List downloaded files
80204
run: |
81-
sha256sum vertex-* > checksums.txt
82-
cat checksums.txt
205+
echo "Downloaded files:"
206+
find . -name "vertex-*" -type f
207+
find . -name "*.sha256" -type f
83208
84209
- name: Generate release notes
85-
id: release_notes
86210
run: |
211+
# Get version from tag
212+
VERSION=${GITHUB_REF#refs/tags/}
213+
214+
echo "# Vertex Service Manager $VERSION" > release-notes.md
215+
echo "" >> release-notes.md
216+
87217
# Get commits since last tag
88218
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
89219
if [ -n "$PREVIOUS_TAG" ]; then
90-
echo "## Changes since $PREVIOUS_TAG" > release_notes.md
91-
echo "" >> release_notes.md
92-
git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" >> release_notes.md
93-
else
94-
echo "## Initial Release" > release_notes.md
95-
echo "" >> release_notes.md
96-
echo "First release of Vertex Service Manager" >> release_notes.md
220+
echo "## Changes since $PREVIOUS_TAG" >> release-notes.md
221+
echo "" >> release-notes.md
222+
git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" >> release-notes.md
223+
echo "" >> release-notes.md
97224
fi
98225
99-
echo "" >> release_notes.md
100-
echo "## Installation" >> release_notes.md
101-
echo "" >> release_notes.md
102-
echo "Download the appropriate binary for your platform:" >> release_notes.md
103-
echo "" >> release_notes.md
104-
echo "- **Linux (amd64)**: \`vertex-linux-amd64\`" >> release_notes.md
105-
echo "- **Linux (arm64)**: \`vertex-linux-arm64\`" >> release_notes.md
106-
echo "- **macOS (Intel)**: \`vertex-darwin-amd64\`" >> release_notes.md
107-
echo "- **macOS (Apple Silicon)**: \`vertex-darwin-arm64\`" >> release_notes.md
108-
echo "- **Windows (amd64)**: \`vertex-windows-amd64.exe\`" >> release_notes.md
109-
echo "" >> release_notes.md
110-
echo "Make the binary executable and move it to your PATH:" >> release_notes.md
111-
echo "\`\`\`bash" >> release_notes.md
112-
echo "chmod +x vertex-*" >> release_notes.md
113-
echo "sudo mv vertex-* /usr/local/bin/vertex" >> release_notes.md
114-
echo "\`\`\`" >> release_notes.md
115-
echo "" >> release_notes.md
116-
echo "Verify the installation:" >> release_notes.md
117-
echo "\`\`\`bash" >> release_notes.md
118-
echo "vertex version" >> release_notes.md
119-
echo "\`\`\`" >> release_notes.md
120-
121-
cat release_notes.md
226+
echo "" >> release-notes.md
227+
echo "## 🚀 Features" >> release-notes.md
228+
echo "- Complete microservice management platform" >> release-notes.md
229+
echo "- Embedded React web interface" >> release-notes.md
230+
echo "- Cross-platform support" >> release-notes.md
231+
echo "- Real-time monitoring and logs" >> release-notes.md
232+
echo "- Profile-based service management" >> release-notes.md
233+
echo "- Environment variable management" >> release-notes.md
234+
echo "" >> release-notes.md
235+
echo "## 📦 Installation" >> release-notes.md
236+
echo "" >> release-notes.md
237+
echo "### Download Binary" >> release-notes.md
238+
echo "" >> release-notes.md
239+
echo "Download the appropriate binary for your platform:" >> release-notes.md
240+
echo "" >> release-notes.md
241+
echo "- **Linux (amd64)**: \`vertex-linux-amd64\`" >> release-notes.md
242+
echo "- **Linux (arm64)**: \`vertex-linux-arm64\`" >> release-notes.md
243+
echo "- **macOS (Intel)**: \`vertex-darwin-amd64\`" >> release-notes.md
244+
echo "- **macOS (Apple Silicon)**: \`vertex-darwin-arm64\`" >> release-notes.md
245+
echo "- **Windows (amd64)**: \`vertex-windows-amd64.exe\`" >> release-notes.md
246+
echo "" >> release-notes.md
247+
echo "\`\`\`bash" >> release-notes.md
248+
echo "# Make executable and install" >> release-notes.md
249+
echo "chmod +x vertex-*" >> release-notes.md
250+
echo "sudo mv vertex-* /usr/local/bin/vertex" >> release-notes.md
251+
echo "" >> release-notes.md
252+
echo "# Verify installation" >> release-notes.md
253+
echo "vertex version" >> release-notes.md
254+
echo "\`\`\`" >> release-notes.md
255+
echo "" >> release-notes.md
256+
echo "### Docker" >> release-notes.md
257+
echo "" >> release-notes.md
258+
echo "\`\`\`bash" >> release-notes.md
259+
echo "docker pull \${{ secrets.DOCKERHUB_USERNAME }}/vertex:$VERSION" >> release-notes.md
260+
echo "# or" >> release-notes.md
261+
echo "docker pull \${{ secrets.DOCKERHUB_USERNAME }}/vertex:latest" >> release-notes.md
262+
echo "\`\`\`" >> release-notes.md
263+
264+
cat release-notes.md
122265
123266
- name: Create GitHub Release
124-
uses: softprops/action-gh-release@v1
267+
uses: softprops/action-gh-release@v2
125268
with:
126-
name: Release ${{ steps.version.outputs.tag }}
127-
body_path: release_notes.md
269+
files: |
270+
vertex-*
271+
body_path: release-notes.md
128272
draft: false
129273
prerelease: false
130-
files: |
131-
vertex-linux-amd64
132-
vertex-linux-arm64
133-
vertex-darwin-amd64
134-
vertex-darwin-arm64
135-
vertex-windows-amd64.exe
136-
checksums.txt
137-
env:
138-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build build-release version install clean help
1+
.PHONY: build build-release build-frontend version install clean clean-all help
22

33
# Version information
44
# Try to get version from git tag, fallback to dev
@@ -28,12 +28,17 @@ help: ## Show this help message
2828
@echo 'Available targets:'
2929
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
3030

31-
build: ## Build vertex with version information
31+
build-frontend: ## Build the frontend web application
32+
@echo "Building frontend..."
33+
@cd web && yarn install --frozen-lockfile && yarn build
34+
@echo "✓ Frontend built: web/dist/"
35+
36+
build: build-frontend ## Build vertex with version information (includes frontend)
3237
@echo "Building Vertex $(VERSION) ($(COMMIT)) ..."
3338
@go build -ldflags="$(LDFLAGS)" -o vertex .
3439
@echo "✓ Build complete: ./vertex"
3540

36-
build-release: ## Build release version (set VERSION=x.x.x)
41+
build-release: build-frontend ## Build release version (set VERSION=x.x.x)
3742
@if [ "$(VERSION)" = "dev" ]; then \
3843
echo "Error: VERSION must be set for release builds"; \
3944
echo "Usage: make build-release VERSION=1.0.0"; \
@@ -49,9 +54,13 @@ version: build ## Build and show version information
4954
install: build ## Build and install vertex
5055
@./vertex install
5156

52-
clean: ## Remove build artifacts
57+
clean: ## Remove Go build artifacts
5358
@rm -f vertex vertex-*
5459
@echo "✓ Build artifacts removed"
5560

61+
clean-all: clean ## Remove all build artifacts (including frontend)
62+
@rm -rf web/dist web/node_modules
63+
@echo "✓ All build artifacts removed"
64+
5665
# Quick development build (alias)
5766
dev: build ## Alias for build

0 commit comments

Comments
 (0)