Skip to content
This repository was archived by the owner on Aug 24, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 0 additions & 118 deletions .github/workflows/build-release.yml

This file was deleted.

101 changes: 101 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Release

on:
push:
branches: [main]

permissions:
contents: write
packages: write

jobs:
# ===========================================================================
# Step 1: Calculate version and create draft release
# ===========================================================================
create-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
release_created: ${{ steps.create_release.outputs.release_created }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Calculate Version
id: version
run: |
NEW_VERSION=$(make -s version)
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"

- name: Create Draft Release
id: create_release
run: |
gh release create "${{ steps.version.outputs.version }}" \
--title "Release ${{ steps.version.outputs.version }}" \
--draft \
--notes "ai-context ${{ steps.version.outputs.version }}" \
--target ${{ github.sha }}
echo "release_created=true" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}

# ===========================================================================
# Step 2: Build binaries (matrix)
# ===========================================================================
binaries:
needs: create-release
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, darwin]
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.25'

- name: Build Binary
run: make build-for GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} VERSION=${{ needs.create-release.outputs.version }}

- name: Upload Release Asset
run: |
BINARY=$(ls *-${{ matrix.os }}-${{ matrix.arch }} 2>/dev/null | head -1)
gh release upload "${{ needs.create-release.outputs.version }}" \
"$BINARY" \
--clobber
env:
GH_TOKEN: ${{ github.token }}

# ===========================================================================
# Step 3: Publish release
# ===========================================================================
publish:
needs: [create-release, binaries]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Publish Release
run: gh release edit "${{ needs.create-release.outputs.version }}" --draft=false
env:
GH_TOKEN: ${{ github.token }}

# ===========================================================================
# Cleanup on failure
# ===========================================================================
cleanup-on-failure:
needs: [create-release, binaries, publish]
if: always() && (needs.binaries.result == 'failure' || needs.publish.result == 'failure') && needs.create-release.outputs.release_created == 'true'
runs-on: ubuntu-latest
steps:
- name: Delete Draft Release
run: |
echo "Cleaning up draft release due to workflow failure"
gh release delete "${{ needs.create-release.outputs.version }}" --yes
env:
GH_TOKEN: ${{ github.token }}
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.PHONY: help clean build build-for build-all version

# =============================================================================
# Variables
# =============================================================================
APP_NAME := ai-context

# Build variables (set by CI or use defaults)
VERSION ?= dev-build
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)

# Console colors
CYAN := \033[0;36m
GREEN := \033[0;32m
NC := \033[0m

# =============================================================================
# Help
# =============================================================================
help: ## Show this help
@echo "$(CYAN)Available targets:$(NC)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'

.DEFAULT_GOAL := help

clean: ## Remove built binaries
@rm -f $(APP_NAME) $(APP_NAME)-*
@echo "$(GREEN)Cleaned$(NC)"

# =============================================================================
# Build
# =============================================================================
build: ## Build binary for current platform
@go build -ldflags="-s -w -X 'github.com/tanq16/ai-context/cmd.AppVersion=$(VERSION)'" -o $(APP_NAME) .
@echo "$(GREEN)Built: ./$(APP_NAME)$(NC)"

build-for: ## Build binary for specified GOOS/GOARCH
@CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags="-s -w -X 'github.com/tanq16/ai-context/cmd.AppVersion=$(VERSION)'" -o $(APP_NAME)-$(GOOS)-$(GOARCH) .
@echo "$(GREEN)Built: ./$(APP_NAME)-$(GOOS)-$(GOARCH)$(NC)"

build-all: ## Build all platform binaries
@$(MAKE) build-for GOOS=linux GOARCH=amd64
@$(MAKE) build-for GOOS=linux GOARCH=arm64
@$(MAKE) build-for GOOS=darwin GOARCH=amd64
@$(MAKE) build-for GOOS=darwin GOARCH=arm64

# =============================================================================
# Version
# =============================================================================
version: ## Calculate next version from commit message
@LATEST_TAG=$$(git tag --sort=-v:refname | head -n1 || echo "0.0.0"); \
LATEST_TAG=$${LATEST_TAG#v}; \
MAJOR=$$(echo "$$LATEST_TAG" | cut -d. -f1); \
MINOR=$$(echo "$$LATEST_TAG" | cut -d. -f2); \
PATCH=$$(echo "$$LATEST_TAG" | cut -d. -f3); \
MAJOR=$${MAJOR:-0}; MINOR=$${MINOR:-0}; PATCH=$${PATCH:-0}; \
COMMIT_MSG="$$(git log -1 --pretty=%B)"; \
if echo "$$COMMIT_MSG" | grep -q "\[major-release\]"; then \
MAJOR=$$((MAJOR + 1)); MINOR=0; PATCH=0; \
elif echo "$$COMMIT_MSG" | grep -q "\[minor-release\]"; then \
MINOR=$$((MINOR + 1)); PATCH=0; \
else \
PATCH=$$((PATCH + 1)); \
fi; \
echo "v$${MAJOR}.$${MINOR}.$${PATCH}"
Loading