Skip to content

Commit 74b97aa

Browse files
committed
initial
0 parents  commit 74b97aa

File tree

23 files changed

+1417
-0
lines changed

23 files changed

+1417
-0
lines changed

.dockerignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Git and GitHub
2+
.git
3+
.github
4+
.gitignore
5+
.dockerignore
6+
7+
# Build and CI artifacts
8+
*.test
9+
*.out
10+
*.prof
11+
*.json
12+
*.txt
13+
Makefile
14+
docker-compose.yml
15+
16+
# Documentation
17+
README.md
18+
LICENSE
19+
20+
# Source code that shouldn't be in the runtime image
21+
* _test.go
22+
docs/
23+
24+
# IDE files
25+
.vscode
26+
.idea

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{yml,yaml}]
12+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
name: Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v5
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v3
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Log in to Docker registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: dhi.io
27+
username: ${{ secrets.DHI_USERNAME }}
28+
password: ${{ secrets.DHI_TOKEN }}
29+
30+
- name: Build
31+
uses: docker/build-push-action@v6
32+
with:
33+
context: .
34+
platforms: linux/amd64,linux/arm64
35+
push: false
36+
cache-from: type=gha
37+
cache-to: type=gha,mode=max

.github/workflows/check.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Check
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
check:
12+
name: ${{ matrix.task }}
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
task: [Test, Lint]
17+
18+
steps:
19+
- uses: actions/checkout@v5
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v6
23+
with:
24+
go-version: 1.25
25+
26+
- name: Test
27+
if: matrix.task == 'Test'
28+
run: go test -v ./...
29+
30+
- name: Lint
31+
if: matrix.task == 'Lint'
32+
uses: golangci/golangci-lint-action@v9
33+
with:
34+
version: v2.7

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
check:
14+
name: Check
15+
uses: ./.github/workflows/check.yml
16+
17+
build:
18+
name: Build
19+
needs: check
20+
uses: ./.github/workflows/build.yml
21+
secrets: inherit

.github/workflows/release.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Publish and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
packages: write
12+
id-token: write
13+
14+
jobs:
15+
check:
16+
name: Check
17+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
18+
uses: ./.github/workflows/check.yml
19+
20+
publish:
21+
name: Publish
22+
needs: check
23+
runs-on: ubuntu-latest
24+
env:
25+
REGISTRY: ghcr.io
26+
IMAGE_NAME: ${{ github.repository }}
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v5
31+
32+
- name: Set lower case image name
33+
run: |
34+
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
35+
36+
- name: Install Cosign
37+
uses: sigstore/cosign-installer@v3.7.0
38+
39+
- name: Set up QEMU
40+
uses: docker/setup-qemu-action@v3
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Log in to Docker registry
46+
uses: docker/login-action@v3
47+
with:
48+
registry: dhi.io
49+
username: ${{ secrets.DHI_USERNAME }}
50+
password: ${{ secrets.DHI_TOKEN }}
51+
52+
- name: Log in to GitHub registry
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Extract Docker metadata
60+
id: meta
61+
uses: docker/metadata-action@v5
62+
with:
63+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
64+
tags: |
65+
type=semver,pattern={{version}}
66+
type=semver,pattern={{major}}.{{minor}}
67+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/') }}
68+
type=ref,event=branch
69+
type=ref,event=tag
70+
71+
- name: Build and push Docker image
72+
id: build-and-push
73+
uses: docker/build-push-action@v6
74+
with:
75+
context: .
76+
platforms: linux/amd64,linux/arm64
77+
push: true
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
annotations: ${{ steps.meta.outputs.annotations }}
81+
cache-from: type=gha
82+
cache-to: type=gha,mode=max
83+
84+
- name: Sign the published Docker image
85+
env:
86+
TAGS: ${{ steps.meta.outputs.tags }}
87+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
88+
run: |
89+
images=""
90+
for tag in ${TAGS}; do
91+
images+="${tag}@${DIGEST} "
92+
done
93+
cosign sign --yes ${images}
94+
95+
release:
96+
name: Release
97+
if: startsWith(github.ref, 'refs/tags/')
98+
needs: publish
99+
runs-on: ubuntu-latest
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v5
103+
104+
- name: Prepare Release Body
105+
run: |
106+
TAG=${{ github.ref_name }}
107+
REPO_NAME=${GITHUB_REPOSITORY,,}
108+
echo "## Quick Start" > release_body.md
109+
echo "" >> release_body.md
110+
echo " \`\`\`bash" >> release_body.md
111+
echo "docker pull ghcr.io/${REPO_NAME}:${TAG}" >> release_body.md
112+
echo " \`\`\`" >> release_body.md
113+
echo "" >> release_body.md
114+
echo "---" >> release_body.md
115+
116+
- name: Create Release
117+
uses: softprops/action-gh-release@v2
118+
with:
119+
body_path: release_body.md
120+
generate_release_notes: true

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Code coverage profiles and other test artifacts
15+
*.out
16+
coverage.*
17+
*.coverprofile
18+
profile.cov
19+
20+
# Dependency directories (remove the comment below to include it)
21+
# vendor/
22+
23+
# Go workspace file
24+
go.work
25+
go.work.sum
26+
27+
# env file
28+
.env
29+
30+
# Editor/IDE
31+
# .idea/
32+
# .vscode/

0 commit comments

Comments
 (0)