Skip to content
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: 118 additions & 0 deletions .github/workflows/chart-lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: chart-lint-test

on:
pull_request:
paths:
- "deploy/helm/**"
- ".github/workflows/chart-lint-test.yaml"
push:
branches:
- main
paths:
- "deploy/helm/**"
- ".github/workflows/chart-lint-test.yaml"

jobs:
lint-test:
name: Lint and template
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.15.0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.6.1

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch=main --chart-dirs deploy/helm)
if [ -n "$changed" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Run chart-testing (lint)
run: ct lint --target-branch=main --chart-dirs deploy/helm --validate-maintainers=false

- name: Helm template (single)
run: |
helm template ci deploy/helm/comqtt \
-f deploy/helm/comqtt/ci/single-values.yaml \
> /tmp/single.yaml
echo "Generated $(wc -l < /tmp/single.yaml) lines for single mode"

- name: Helm template (cluster)
run: |
helm template ci deploy/helm/comqtt \
-f deploy/helm/comqtt/ci/cluster-values.yaml \
> /tmp/cluster.yaml
echo "Generated $(wc -l < /tmp/cluster.yaml) lines for cluster mode"

install-test:
name: Install on kind
runs-on: ubuntu-latest
needs: lint-test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.15.0

- name: Create kind cluster
uses: helm/kind-action@v1.10.0
with:
cluster_name: comqtt-ci
wait: 120s

- name: Build comqtt image
run: |
docker build -t ghcr.io/wind-c/comqtt:ci .
kind load docker-image ghcr.io/wind-c/comqtt:ci --name comqtt-ci

- name: Install single-mode chart
run: |
helm install single deploy/helm/comqtt \
-f deploy/helm/comqtt/ci/single-values.yaml \
--set image.tag=ci \
--wait --timeout 5m

- name: Run helm tests (single)
run: helm test single --logs

- name: Deploy Valkey for cluster mode
run: kubectl apply -f deploy/helm/comqtt/ci/valkey.yaml

- name: Install cluster-mode chart
run: |
helm install cluster deploy/helm/comqtt \
-f deploy/helm/comqtt/ci/cluster-values.yaml \
--set image.tag=ci \
--wait --timeout 8m

- name: Show cluster pod status
if: always()
run: |
kubectl get pods -o wide
kubectl describe statefulset cluster-comqtt || true

- name: Wait for Raft formation
run: |
for i in 0 1 2; do
echo "==== cluster-comqtt-${i} logs ===="
kubectl logs cluster-comqtt-${i} --tail=200 || true
done
40 changes: 40 additions & 0 deletions .github/workflows/chart-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: chart-release

on:
push:
branches:
- main
paths:
- "deploy/helm/**"

permissions:
contents: write
pages: write
id-token: write

jobs:
release:
name: Release Helm chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.15.0

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: deploy/helm
env:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75 changes: 75 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: release

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v2.7.0). Required for manual runs."
required: true
type: string

permissions:
contents: write
packages: write

jobs:
goreleaser:
name: GoReleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push tag (manual dispatch only)
if: github.event_name == 'workflow_dispatch'
env:
TAG: ${{ inputs.tag }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"

# GHCR image names must be lowercase. github.repository_owner is
# already lowercase for users/orgs, but we lowercase defensively.
- name: Compute lowercase image owner
id: owner
run: echo "value=${OWNER,,}" >> "$GITHUB_OUTPUT"
env:
OWNER: ${{ github.repository_owner }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_OWNER: ${{ steps.owner.outputs.value }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bolt.db
raft.db
.idea
.vscode
.claude/
158 changes: 158 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
version: 2

project_name: comqtt

before:
hooks:
- go mod tidy

builds:
- id: comqtt
main: ./cmd/single
binary: comqtt
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
ignore:
- goos: windows
goarch: arm64

- id: comqtt-cluster
main: ./cmd/cluster
binary: comqtt-cluster
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}

archives:
- id: default
ids:
- comqtt
- comqtt-cluster
# Windows skips cmd/cluster, so its archive has 1 binary while
# linux/darwin archives have 2. Allow that intentional asymmetry.
allow_different_binary_count: true
name_template: >-
{{ .ProjectName }}_{{ .Version }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
format_overrides:
- goos: windows
formats: [zip]
files:
- LICENSE.md
- README.md
- cmd/config/*.yml

checksum:
name_template: "checksums.txt"

snapshot:
version_template: "{{ incpatch .Version }}-snapshot-{{ .ShortCommit }}"

changelog:
sort: asc
use: github
filters:
exclude:
- "^docs:"
- "^test:"
- "^chore:"
- "^ci:"
- "Merge pull request"
- "Merge branch"
groups:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: Bug fixes
regexp: "^.*fix[(\\w)]*:+.*$"
order: 1
- title: Performance
regexp: "^.*perf[(\\w)]*:+.*$"
order: 2
- title: Other
order: 999

dockers:
- id: comqtt-amd64
use: buildx
goos: linux
goarch: amd64
ids:
- comqtt
- comqtt-cluster
image_templates:
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:{{ .Version }}-amd64"
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:v{{ .Major }}.{{ .Minor }}-amd64"
dockerfile: Dockerfile.goreleaser
extra_files:
- cmd/config
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description=A lightweight high-performance MQTT broker (v3.0/v3.1.1/v5.0) supporting clustering"
- "--label=org.opencontainers.image.url=https://github.com/wind-c/comqtt"
- "--label=org.opencontainers.image.source=https://github.com/wind-c/comqtt"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.licenses=MIT"

- id: comqtt-arm64
use: buildx
goos: linux
goarch: arm64
ids:
- comqtt
- comqtt-cluster
image_templates:
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:{{ .Version }}-arm64"
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:v{{ .Major }}.{{ .Minor }}-arm64"
dockerfile: Dockerfile.goreleaser
extra_files:
- cmd/config
build_flag_templates:
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description=A lightweight high-performance MQTT broker (v3.0/v3.1.1/v5.0) supporting clustering"
- "--label=org.opencontainers.image.url=https://github.com/wind-c/comqtt"
- "--label=org.opencontainers.image.source=https://github.com/wind-c/comqtt"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.licenses=MIT"

docker_manifests:
- name_template: "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:{{ .Version }}"
image_templates:
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:{{ .Version }}-amd64"
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:{{ .Version }}-arm64"
- name_template: "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:v{{ .Major }}.{{ .Minor }}"
image_templates:
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:v{{ .Major }}.{{ .Minor }}-amd64"
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:v{{ .Major }}.{{ .Minor }}-arm64"
- name_template: "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:latest"
image_templates:
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:{{ .Version }}-amd64"
- "ghcr.io/{{ .Env.IMAGE_OWNER }}/comqtt:{{ .Version }}-arm64"

release:
prerelease: auto
draft: false
name_template: "v{{ .Version }}"
Loading