Skip to content

Commit 7d3a1b7

Browse files
authored
Merge pull request #34 from zechtz/feat/git-integration
Feat/git integration
2 parents e81132c + a3a3a10 commit 7d3a1b7

16 files changed

Lines changed: 1235 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ jobs:
8484
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
8585
fi
8686
87+
- name: Get version from tag
88+
id: version
89+
run: |
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")
98+
echo "version=$VERSION" >> $GITHUB_OUTPUT
99+
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
100+
echo "date=$DATE" >> $GITHUB_OUTPUT
101+
87102
- name: Build binary
88103
env:
89104
GOOS: ${{ matrix.goos }}
@@ -94,7 +109,9 @@ jobs:
94109
if [ "${{ matrix.goos }}" = "windows" ]; then
95110
BINARY_NAME="${BINARY_NAME}.exe"
96111
fi
97-
go build -ldflags="-s -w" -o "${BINARY_NAME}"
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}"
98115
99116
if [[ "${{ matrix.os }}" == macos* ]]; then
100117
shasum -a 256 "${BINARY_NAME}" > "${BINARY_NAME}.sha256"
@@ -103,7 +120,7 @@ jobs:
103120
fi
104121
105122
- name: Upload artifacts
106-
if: github.event_name != 'pull_request' # don't upload artifacts for PRs
123+
if: github.event_name != 'pull_request'
107124
uses: actions/upload-artifact@v4
108125
with:
109126
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
@@ -174,6 +191,8 @@ jobs:
174191
steps:
175192
- name: Checkout code
176193
uses: actions/checkout@v4
194+
with:
195+
fetch-depth: 0
177196

178197
- name: Download all artifacts
179198
uses: actions/download-artifact@v4
@@ -189,14 +208,60 @@ jobs:
189208
190209
- name: Generate release notes
191210
run: |
192-
echo "# Vertex Service Manager ${GITHUB_REF#refs/tags/}" > release-notes.md
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+
217+
# Get commits since last tag
218+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
219+
if [ -n "$PREVIOUS_TAG" ]; then
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
224+
fi
225+
193226
echo "" >> release-notes.md
194227
echo "## 🚀 Features" >> release-notes.md
195228
echo "- Complete microservice management platform" >> release-notes.md
196229
echo "- Embedded React web interface" >> release-notes.md
197230
echo "- Cross-platform support" >> release-notes.md
198231
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
199246
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
200265
201266
- name: Create GitHub Release
202267
uses: softprops/action-gh-release@v2

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ RUN CGO_ENABLED=1 go build -ldflags="-s -w" -o vertex
2626
FROM alpine:latest
2727

2828
# Install runtime dependencies
29-
RUN apk --no-cache add ca-certificates sqlite
29+
# Use --no-scripts to avoid trigger issues in QEMU ARM64 builds
30+
RUN apk --no-cache --no-scripts add ca-certificates sqlite && \
31+
update-ca-certificates 2>/dev/null || true
3032

3133
WORKDIR /app
3234

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.PHONY: build build-release build-frontend version install clean clean-all help
2+
3+
# Version information
4+
# Try to get version from git tag, fallback to dev
5+
GIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null)
6+
ifneq ($(GIT_TAG),)
7+
# If we're on a tag, use it (strip 'v' prefix if present)
8+
VERSION ?= $(shell echo $(GIT_TAG) | sed 's/^v//')
9+
else
10+
# Otherwise, try to get the latest tag + commit count
11+
GIT_DESCRIBE := $(shell git describe --tags --always 2>/dev/null)
12+
ifneq ($(GIT_DESCRIBE),)
13+
VERSION ?= $(GIT_DESCRIBE)
14+
else
15+
VERSION ?= dev
16+
endif
17+
endif
18+
19+
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
20+
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
21+
22+
# Build flags
23+
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
24+
25+
help: ## Show this help message
26+
@echo 'Usage: make [target]'
27+
@echo ''
28+
@echo 'Available targets:'
29+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
30+
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)
37+
@echo "Building Vertex $(VERSION) ($(COMMIT)) ..."
38+
@go build -ldflags="$(LDFLAGS)" -o vertex .
39+
@echo "✓ Build complete: ./vertex"
40+
41+
build-release: build-frontend ## Build release version (set VERSION=x.x.x)
42+
@if [ "$(VERSION)" = "dev" ]; then \
43+
echo "Error: VERSION must be set for release builds"; \
44+
echo "Usage: make build-release VERSION=1.0.0"; \
45+
exit 1; \
46+
fi
47+
@echo "Building Vertex $(VERSION) ($(COMMIT)) ..."
48+
@go build -ldflags="$(LDFLAGS)" -o vertex .
49+
@echo "✓ Release build complete: ./vertex"
50+
51+
version: build ## Build and show version information
52+
@./vertex version
53+
54+
install: build ## Build and install vertex
55+
@./vertex install
56+
57+
clean: ## Remove Go build artifacts
58+
@rm -f vertex vertex-*
59+
@echo "✓ Build artifacts removed"
60+
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+
65+
# Quick development build (alias)
66+
dev: build ## Alias for build

RELEASE.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Release Guide
2+
3+
## Quick Release Process
4+
5+
1. **Commit all changes**
6+
```bash
7+
git add .
8+
git commit -m "feat: your changes"
9+
```
10+
11+
2. **Create and push version tag**
12+
```bash
13+
git tag -a v1.0.0 -m "Release version 1.0.0"
14+
git push origin v1.0.0
15+
```
16+
17+
3. **Wait for GitHub Actions**
18+
- Workflow automatically builds binaries for all platforms
19+
- Creates GitHub Release with binaries and release notes
20+
- Check: https://github.com/zechtz/vertex/actions
21+
22+
4. **Done!**
23+
- Users can download from: https://github.com/zechtz/vertex/releases
24+
25+
## What Happens Automatically
26+
27+
When you push a tag (e.g., `v1.0.0`):
28+
29+
1. **GitHub Actions triggers** (`.github/workflows/release.yml`)
30+
2. **Builds binaries** for:
31+
- Linux (amd64, arm64)
32+
- macOS (Intel, Apple Silicon)
33+
- Windows (amd64)
34+
3. **Generates SHA256 checksums**
35+
4. **Creates release notes** from git commits
36+
5. **Publishes GitHub Release** with all artifacts
37+
38+
## Local Testing
39+
40+
Test the build before tagging:
41+
42+
```bash
43+
# Build locally with current git tag
44+
make build
45+
./vertex version
46+
47+
# Build with specific version (override)
48+
make build VERSION=1.0.0-test
49+
./vertex version
50+
```
51+
52+
## Version Numbering
53+
54+
Follow [Semantic Versioning](https://semver.org/):
55+
56+
- `v1.0.0` - Major release (breaking changes)
57+
- `v1.1.0` - Minor release (new features, backward compatible)
58+
- `v1.1.1` - Patch release (bug fixes)
59+
- `v1.0.0-beta.1` - Pre-release
60+
61+
## Example Workflow
62+
63+
```bash
64+
# 1. Make changes
65+
vim internal/services/manager.go
66+
67+
# 2. Test locally
68+
make build
69+
./vertex version
70+
71+
# 3. Commit
72+
git add .
73+
git commit -m "feat: add new service management feature"
74+
75+
# 4. Tag and push
76+
git tag -a v1.2.0 -m "Release version 1.2.0 - Add service management"
77+
git push origin main
78+
git push origin v1.2.0
79+
80+
# 5. Monitor GitHub Actions
81+
# Visit: https://github.com/zechtz/vertex/actions
82+
83+
# 6. Release is ready!
84+
# Visit: https://github.com/zechtz/vertex/releases/latest
85+
```
86+
87+
## Troubleshooting
88+
89+
### Build fails in GitHub Actions
90+
91+
- Check the Actions tab for detailed logs
92+
- Common issues:
93+
- Tests failing
94+
- Dependencies not available
95+
- Go version mismatch
96+
97+
### Version not detected
98+
99+
```bash
100+
# Check git tags
101+
git tag -l
102+
103+
# Check current version
104+
git describe --tags
105+
106+
# If no tags exist, create one
107+
git tag -a v0.1.0 -m "Initial release"
108+
```
109+
110+
### Need to re-release
111+
112+
If you need to fix a release:
113+
114+
```bash
115+
# Delete the tag locally and remotely
116+
git tag -d v1.0.0
117+
git push origin :refs/tags/v1.0.0
118+
119+
# Delete the GitHub Release (via web UI)
120+
# Make your fixes, commit, and re-tag
121+
git tag -a v1.0.0 -m "Release version 1.0.0"
122+
git push origin v1.0.0
123+
```
124+
125+
## Manual Release (Without CI/CD)
126+
127+
If you need to create a release manually:
128+
129+
```bash
130+
# Build all platforms
131+
./build.sh
132+
133+
# This creates:
134+
# - vertex-linux-amd64
135+
# - vertex-linux-arm64
136+
# - vertex-darwin-amd64
137+
# - vertex-darwin-arm64
138+
# - vertex-windows-amd64.exe
139+
140+
# Create checksums
141+
sha256sum vertex-* > checksums.txt
142+
143+
# Manually create GitHub Release and upload files
144+
```

0 commit comments

Comments
 (0)