Skip to content

Commit 847b2f7

Browse files
committed
Add release automation and documentation for Bering
Introduce a new .goreleaser.yaml configuration for automated releases, including support for multiple platforms and architectures. Update the Makefile to include new targets for release processes, such as goreleaser-release, contracts-pack, and chart-package. Enhance README with installation instructions and add new documentation files for releasing and versioning. Implement CI workflows for release dry runs and actual releases, ensuring proper artifact management and publishing to OCI registries. Add Helm chart files for deployment and configuration management.
1 parent f4cf37f commit 847b2f7

35 files changed

Lines changed: 3326 additions & 19 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ jobs:
1818
with:
1919
go-version-file: go.mod
2020

21-
- name: Lint
22-
run: make lint
23-
24-
- name: Test
25-
run: make test
26-
27-
- name: Build
28-
run: make build
21+
- name: Run Checks
22+
run: make run-checks
2923

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Release Dry Run
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
dry-run:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
env:
13+
VERSION: 0.0.0-dev
14+
PUBLISH_OCI: "0"
15+
GORELEASER_VERSION: v2.14.3
16+
SYFT_VERSION: v1.40.0
17+
HELM_VERSION: v3.19.1
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version-file: go.mod
28+
29+
- name: Setup Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Install GoReleaser
33+
run: go install github.com/goreleaser/goreleaser/v2@${{ env.GORELEASER_VERSION }}
34+
35+
- name: Install Syft
36+
run: go install github.com/anchore/syft/cmd/syft@${{ env.SYFT_VERSION }}
37+
38+
- name: Install Helm
39+
shell: bash
40+
run: |
41+
set -euo pipefail
42+
export DESIRED_VERSION="${HELM_VERSION}"
43+
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
44+
45+
- name: Add Go bin to PATH
46+
shell: bash
47+
run: echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
48+
49+
- name: Run Release Dry Run
50+
shell: bash
51+
env:
52+
GIT_SHA: ${{ github.sha }}
53+
IMAGE_REPOSITORY: ghcr.io/${{ github.repository }}
54+
CHART_OCI_REPOSITORY: oci://ghcr.io/${{ github.repository_owner }}/charts
55+
run: |
56+
set -euo pipefail
57+
BUILD_DATE="$(git show -s --format=%cI HEAD)"
58+
IMAGE_REPOSITORY="$(echo "${IMAGE_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
59+
CHART_OCI_REPOSITORY="$(echo "${CHART_OCI_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
60+
make release-dry-run \
61+
VERSION="${VERSION}" \
62+
BUILD_DATE="${BUILD_DATE}" \
63+
GIT_SHA="${GIT_SHA}" \
64+
IMAGE_REPOSITORY="${IMAGE_REPOSITORY}" \
65+
CHART_OCI_REPOSITORY="${CHART_OCI_REPOSITORY}"
66+
67+
- name: Upload Dist Artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: release-dry-run-dist
71+
path: dist
72+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
env:
16+
PUBLISH_OCI: "1"
17+
GORELEASER_VERSION: v2.14.3
18+
SYFT_VERSION: v1.40.0
19+
HELM_VERSION: v3.19.1
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version-file: go.mod
30+
31+
- name: Setup Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Install GoReleaser
35+
run: go install github.com/goreleaser/goreleaser/v2@${{ env.GORELEASER_VERSION }}
36+
37+
- name: Install Syft
38+
run: go install github.com/anchore/syft/cmd/syft@${{ env.SYFT_VERSION }}
39+
40+
- name: Install Helm
41+
shell: bash
42+
run: |
43+
set -euo pipefail
44+
export DESIRED_VERSION="${HELM_VERSION}"
45+
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
46+
47+
- name: Add Go bin to PATH
48+
shell: bash
49+
run: echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
50+
51+
- name: Login to GHCR
52+
shell: bash
53+
env:
54+
GHCR_TOKEN: ${{ github.token }}
55+
run: |
56+
set -euo pipefail
57+
echo "${GHCR_TOKEN}" | docker login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
58+
echo "${GHCR_TOKEN}" | helm registry login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
59+
60+
- name: Build Release Payload
61+
shell: bash
62+
env:
63+
VERSION: ${{ github.ref_name }}
64+
GIT_SHA: ${{ github.sha }}
65+
IMAGE_REPOSITORY: ghcr.io/${{ github.repository }}
66+
CHART_OCI_REPOSITORY: oci://ghcr.io/${{ github.repository_owner }}/charts
67+
run: |
68+
set -euo pipefail
69+
VERSION="${VERSION#v}"
70+
BUILD_DATE="$(git show -s --format=%cI HEAD)"
71+
IMAGE_REPOSITORY="$(echo "${IMAGE_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
72+
CHART_OCI_REPOSITORY="$(echo "${CHART_OCI_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
73+
make release-local \
74+
VERSION="${VERSION}" \
75+
BUILD_DATE="${BUILD_DATE}" \
76+
GIT_SHA="${GIT_SHA}" \
77+
GIT_TAG="v${VERSION}" \
78+
PUBLISH_OCI="${PUBLISH_OCI}" \
79+
IMAGE_REPOSITORY="${IMAGE_REPOSITORY}" \
80+
CHART_OCI_REPOSITORY="${CHART_OCI_REPOSITORY}"
81+
82+
- name: Publish GitHub Release Assets
83+
shell: bash
84+
env:
85+
GH_TOKEN: ${{ github.token }}
86+
run: |
87+
set -euo pipefail
88+
mapfile -t assets < dist/release-assets.txt
89+
args=()
90+
for asset in "${assets[@]}"; do
91+
args+=("dist/${asset}")
92+
done
93+
if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
94+
gh release upload "${GITHUB_REF_NAME}" "${args[@]}" --clobber
95+
gh release edit "${GITHUB_REF_NAME}" --title "${GITHUB_REF_NAME}" --notes-file dist/release-notes.md
96+
else
97+
gh release create "${GITHUB_REF_NAME}" \
98+
"${args[@]}" \
99+
--title "${GITHUB_REF_NAME}" \
100+
--notes-file dist/release-notes.md
101+
fi

.goreleaser.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
version: 2
2+
3+
project_name: bering
4+
dist: dist
5+
6+
before:
7+
hooks:
8+
- go mod download
9+
10+
builds:
11+
- id: bering
12+
main: ./cmd/bering
13+
binary: bering
14+
env:
15+
- CGO_ENABLED=0
16+
goos:
17+
- linux
18+
- darwin
19+
- windows
20+
goarch:
21+
- amd64
22+
- arm64
23+
ignore:
24+
- goos: windows
25+
goarch: arm64
26+
flags:
27+
- -trimpath
28+
ldflags:
29+
- -s -w -buildid=
30+
mod_timestamp: "{{ .CommitTimestamp }}"
31+
32+
archives:
33+
- id: release
34+
ids:
35+
- bering
36+
formats:
37+
- tar.gz
38+
format_overrides:
39+
- goos: windows
40+
formats:
41+
- zip
42+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
43+
files:
44+
- LICENSE
45+
- README.md
46+
47+
checksum:
48+
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
49+
algorithm: sha256
50+
51+
sboms:
52+
- id: archives
53+
artifacts: archive
54+
ids:
55+
- release
56+
documents:
57+
- "{{ .ArtifactName }}.sbom.json"
58+
59+
snapshot:
60+
version_template: "{{ if .Env.RELEASE_VERSION }}{{ .Env.RELEASE_VERSION }}{{ else }}0.0.0-dev{{ end }}"

Makefile

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
SHELL := /bin/sh
22

33
GO ?= go
4+
GORELEASER ?= goreleaser
45
IMAGE ?= bering:dev
6+
DIST_DIR ?= dist
7+
VERSION ?= 0.0.0-dev
8+
CHART_VERSION ?= $(VERSION)
9+
BUILD_DATE ?= $(shell git show -s --format=%cI HEAD 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ")
10+
GIT_SHA ?= $(shell git rev-parse --verify HEAD 2>/dev/null || echo unknown)
11+
GIT_TAG ?= v$(VERSION)
12+
IMAGE_REPOSITORY ?= ghcr.io/mb3r-lab/bering
13+
CHART_OCI_REPOSITORY ?= oci://ghcr.io/mb3r-lab/charts
14+
PUBLISH_OCI ?= 0
15+
ALLOW_CHART_VERSION_MISMATCH ?= 0
516

6-
.PHONY: help lint test build run-checks docker-build clean
17+
BOOL_TRUE := 1 true TRUE yes YES
18+
19+
.PHONY: help lint test build run-checks docker-build goreleaser-release contracts-pack chart-package oci-image release-manifest validate-release release-dry-run release-local clean
720

821
help:
922
@echo "Targets:"
10-
@echo " lint Run gofmt and go vet"
11-
@echo " test Run unit and integration tests"
12-
@echo " build Build bering binary"
13-
@echo " run-checks Run lint + test + build"
14-
@echo " docker-build Build CLI image"
15-
@echo " clean Remove generated binaries"
23+
@echo " lint Run gofmt and go vet"
24+
@echo " test Run unit and integration tests"
25+
@echo " build Build the local bering binary"
26+
@echo " run-checks Run lint + test + build"
27+
@echo " release-dry-run Build the release payload locally without publishing"
28+
@echo " release-local Build the canonical release payload and optionally publish OCI artifacts"
29+
@echo " chart-package Package the Helm chart and optionally publish it to an OCI registry"
30+
@echo " release-manifest Generate release-manifest.json and supporting metadata"
31+
@echo " validate-release Validate generated release metadata"
32+
@echo " docker-build Build the local CLI image"
33+
@echo " clean Remove generated binaries and release artifacts"
1634

1735
lint:
1836
@fmt_out="$$(gofmt -l .)"; \
@@ -28,13 +46,35 @@ test:
2846

2947
build:
3048
mkdir -p bin
31-
$(GO) build -o bin/bering ./cmd/bering
49+
$(GO) build -trimpath -o bin/bering ./cmd/bering
3250

3351
run-checks: lint test build
3452

3553
docker-build:
3654
docker build -f build/Dockerfile -t $(IMAGE) .
3755

56+
goreleaser-release:
57+
rm -rf $(DIST_DIR)
58+
RELEASE_VERSION=$(VERSION) $(GORELEASER) release --snapshot --clean --skip=publish
59+
60+
contracts-pack:
61+
$(GO) run ./cmd/releasectl contracts-pack --repo-root . --dist-dir $(DIST_DIR) --app-version $(VERSION) --build-date $(BUILD_DATE)
62+
63+
chart-package:
64+
$(GO) run ./cmd/releasectl chart-package --repo-root . --dist-dir $(DIST_DIR) --chart-dir charts/bering --app-version $(VERSION) --chart-version $(CHART_VERSION) --oci-repository $(CHART_OCI_REPOSITORY) $(if $(filter $(BOOL_TRUE),$(PUBLISH_OCI)),--publish,) $(if $(filter $(BOOL_TRUE),$(ALLOW_CHART_VERSION_MISMATCH)),--allow-chart-version-mismatch,)
65+
66+
oci-image:
67+
$(GO) run ./cmd/releasectl oci-image --repo-root . --dist-dir $(DIST_DIR) --dockerfile build/Dockerfile --image-repository $(IMAGE_REPOSITORY) --app-version $(VERSION) --git-commit $(GIT_SHA) --build-date $(BUILD_DATE) $(if $(filter $(BOOL_TRUE),$(PUBLISH_OCI)),--publish,)
68+
69+
release-manifest:
70+
$(GO) run ./cmd/releasectl release-manifest --repo-root . --dist-dir $(DIST_DIR) --app-version $(VERSION) --git-commit $(GIT_SHA) --git-tag $(GIT_TAG) --build-date $(BUILD_DATE)
71+
72+
validate-release:
73+
$(GO) run ./cmd/releasectl validate --repo-root . --dist-dir $(DIST_DIR) --app-version $(VERSION) --build-date $(BUILD_DATE) $(if $(filter $(BOOL_TRUE),$(PUBLISH_OCI)),--require-published-oci,) $(if $(filter $(BOOL_TRUE),$(ALLOW_CHART_VERSION_MISMATCH)),--allow-chart-version-mismatch,)
74+
75+
release-dry-run: lint test goreleaser-release contracts-pack chart-package oci-image release-manifest validate-release
76+
77+
release-local: test goreleaser-release contracts-pack chart-package oci-image release-manifest validate-release
78+
3879
clean:
3980
rm -rf bin out dist
40-

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,24 @@ The runtime service exports Prometheus/OpenMetrics metrics including:
184184
## Additional docs
185185

186186
- [docs/architecture.md](docs/architecture.md)
187+
- [docs/install.md](docs/install.md)
188+
- [docs/release-assets.md](docs/release-assets.md)
187189
- [docs/runtime-config.md](docs/runtime-config.md)
188190
- [docs/trace-input-format.md](docs/trace-input-format.md)
189191
- [docs/topology-input-format.md](docs/topology-input-format.md)
190192
- [docs/schema-publishing.md](docs/schema-publishing.md)
191193
- [docs/migration-notes.md](docs/migration-notes.md)
192194
- [docs/mvp-scope-and-limits.md](docs/mvp-scope-and-limits.md)
195+
- [RELEASING.md](RELEASING.md)
196+
- [VERSIONING.md](VERSIONING.md)
193197

194198
## CI and local checks
195199

196200
```bash
197201
make lint
198202
make test
199203
make build
204+
make release-dry-run
200205
```
201206

202207
## License

0 commit comments

Comments
 (0)