Skip to content

Commit b422df2

Browse files
authored
Initial commit
0 parents  commit b422df2

21 files changed

Lines changed: 2211 additions & 0 deletions

File tree

.editorconfig

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
charset = utf-8
12+
13+
# Go files
14+
[*.go]
15+
indent_style = tab
16+
indent_size = 4
17+
18+
# YAML files
19+
[*.{yml,yaml}]
20+
indent_style = space
21+
indent_size = 2
22+
23+
# JSON files
24+
[*.json]
25+
indent_style = space
26+
indent_size = 2
27+
28+
# Markdown files
29+
[*.md]
30+
indent_style = space
31+
indent_size = 2
32+
trim_trailing_whitespace = false
33+
34+
# Makefile
35+
[Makefile]
36+
indent_style = tab
37+
38+
# justfile
39+
[justfile]
40+
indent_style = space
41+
indent_size = 4
42+
43+
# Shell scripts
44+
[*.sh]
45+
indent_style = space
46+
indent_size = 4
47+
48+
# Protobuf
49+
[*.proto]
50+
indent_style = space
51+
indent_size = 2
52+
53+
# Web files
54+
[*.{html,css,js,ts,tsx,jsx}]
55+
indent_style = space
56+
indent_size = 2
57+
58+
# Configuration files
59+
[*.{toml,ini,cfg}]
60+
indent_style = space
61+
indent_size = 2
62+
63+
# Dockerfile
64+
[Dockerfile*]
65+
indent_style = space
66+
indent_size = 4
67+
68+
# Git files
69+
[.git*]
70+
indent_style = space
71+
indent_size = 2

.github/workflows/ci.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
GO_VERSION: '1.23.4'
11+
12+
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: ${{ env.GO_VERSION }}
22+
23+
- name: Install golangci-lint
24+
run: |
25+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
26+
27+
- name: Run golangci-lint
28+
run: golangci-lint run ./...
29+
30+
test:
31+
name: Test
32+
strategy:
33+
matrix:
34+
os: [ubuntu-latest, macos-latest]
35+
go: ['1.22', '1.23.4']
36+
runs-on: ${{ matrix.os }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: actions/setup-go@v5
41+
with:
42+
go-version: ${{ matrix.go }}
43+
44+
- name: Run tests
45+
run: |
46+
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
47+
48+
- name: Upload coverage
49+
if: matrix.os == 'ubuntu-latest' && matrix.go == env.GO_VERSION
50+
uses: codecov/codecov-action@v4
51+
with:
52+
file: ./coverage.out
53+
fail_ci_if_error: false
54+
55+
build-sharedlib:
56+
name: Build Shared Libraries
57+
strategy:
58+
matrix:
59+
include:
60+
- os: ubuntu-latest
61+
target: linux-amd64
62+
output: signer-amd64.so
63+
- os: macos-latest
64+
target: darwin-arm64
65+
output: signer-arm64.dylib
66+
runs-on: ${{ matrix.os }}
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- uses: actions/setup-go@v5
71+
with:
72+
go-version: ${{ env.GO_VERSION }}
73+
74+
- name: Vendor dependencies
75+
run: |
76+
go mod download
77+
go mod vendor
78+
79+
- name: Build shared library
80+
run: |
81+
mkdir -p build
82+
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
83+
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o build/${{ matrix.output }} ./sharedlib/sharedlib.go
84+
else
85+
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o build/${{ matrix.output }} ./sharedlib/sharedlib.go
86+
fi
87+
88+
- name: Verify shared library
89+
run: |
90+
ls -la build/
91+
file build/${{ matrix.output }}
92+
93+
- name: Upload artifact
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: sharedlib-${{ matrix.target }}
97+
path: build/${{ matrix.output }}
98+
99+
e2e-test:
100+
name: End-to-End Test
101+
needs: build-sharedlib
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- uses: actions/setup-go@v5
107+
with:
108+
go-version: ${{ env.GO_VERSION }}
109+
110+
- name: Download Linux shared library
111+
uses: actions/download-artifact@v4
112+
with:
113+
name: sharedlib-linux-amd64
114+
path: build/
115+
116+
- name: Run E2E tests
117+
run: |
118+
chmod +x scripts/e2e-test.sh
119+
./scripts/e2e-test.sh
120+
121+
security-scan:
122+
name: Security Scan
123+
runs-on: ubuntu-latest
124+
steps:
125+
- uses: actions/checkout@v4
126+
127+
- uses: actions/setup-go@v5
128+
with:
129+
go-version: ${{ env.GO_VERSION }}
130+
131+
- name: Run gosec
132+
run: |
133+
go install github.com/securego/gosec/v2/cmd/gosec@latest
134+
gosec -fmt=json -out=security-report.json ./... || true
135+
136+
- name: Upload security report
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: security-report
140+
path: security-report.json
141+
142+
build-cross-platform:
143+
name: Cross-Platform Build
144+
runs-on: ubuntu-latest
145+
steps:
146+
- uses: actions/checkout@v4
147+
148+
- uses: actions/setup-go@v5
149+
with:
150+
go-version: ${{ env.GO_VERSION }}
151+
152+
- name: Build for multiple platforms
153+
run: |
154+
make build-cross || echo "No main binary to build"
155+
156+
docker-build:
157+
name: Docker Build Test
158+
runs-on: ubuntu-latest
159+
steps:
160+
- uses: actions/checkout@v4
161+
162+
- name: Test Docker build
163+
run: |
164+
if [ -f Dockerfile ]; then
165+
docker build -t tmpl:test .
166+
else
167+
echo "No Dockerfile found, skipping Docker build"
168+
fi

.github/workflows/release.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: '1.23.4'
23+
24+
- name: Validate tag
25+
run: |
26+
if ! [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
27+
echo "Invalid tag format. Expected format: vX.Y.Z or vX.Y.Z-suffix"
28+
exit 1
29+
fi
30+
31+
- name: Build release artifacts
32+
run: |
33+
make clean
34+
make vendor
35+
36+
# Build shared libraries
37+
just build-all
38+
39+
# Create checksums
40+
cd build
41+
sha256sum * > checksums.txt
42+
cd ..
43+
44+
- name: Create release archive
45+
run: |
46+
VERSION=${{ github.ref_name }}
47+
mkdir -p release
48+
49+
# Archive each platform separately
50+
tar -czf release/tmpl-${VERSION}-darwin-arm64.tar.gz -C build signer-arm64.dylib
51+
tar -czf release/tmpl-${VERSION}-linux-amd64.tar.gz -C build signer-amd64.so
52+
53+
# Create source archive
54+
git archive --format=tar.gz --prefix=tmpl-${VERSION}/ -o release/tmpl-${VERSION}-source.tar.gz HEAD
55+
56+
# Copy checksums
57+
cp build/checksums.txt release/
58+
59+
- name: Generate changelog
60+
id: changelog
61+
run: |
62+
echo "## What's Changed" > changelog.md
63+
echo "" >> changelog.md
64+
65+
# Get commits since last tag
66+
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
67+
if [ -z "$LAST_TAG" ]; then
68+
git log --pretty=format:"* %s (%h)" >> changelog.md
69+
else
70+
git log ${LAST_TAG}..HEAD --pretty=format:"* %s (%h)" >> changelog.md
71+
fi
72+
73+
echo "" >> changelog.md
74+
echo "" >> changelog.md
75+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LAST_TAG}...${{ github.ref_name }}" >> changelog.md
76+
77+
- name: Create GitHub Release
78+
uses: softprops/action-gh-release@v2
79+
with:
80+
body_path: changelog.md
81+
files: |
82+
release/*.tar.gz
83+
release/checksums.txt
84+
draft: false
85+
prerelease: ${{ contains(github.ref_name, '-') }}
86+
87+
build-binaries:
88+
name: Build Cross-Platform Binaries
89+
runs-on: ubuntu-latest
90+
strategy:
91+
matrix:
92+
include:
93+
- goos: linux
94+
goarch: amd64
95+
- goos: linux
96+
goarch: arm64
97+
- goos: darwin
98+
goarch: amd64
99+
- goos: darwin
100+
goarch: arm64
101+
- goos: windows
102+
goarch: amd64
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- uses: actions/setup-go@v5
107+
with:
108+
go-version: '1.23.4'
109+
110+
- name: Build shared library
111+
env:
112+
CGO_ENABLED: 1
113+
GOOS: ${{ matrix.goos }}
114+
GOARCH: ${{ matrix.goarch }}
115+
run: |
116+
# Skip Windows shared library builds (not supported)
117+
if [ "${{ matrix.goos }}" != "windows" ]; then
118+
make vendor
119+
120+
OUTPUT_EXT="so"
121+
if [ "${{ matrix.goos }}" = "darwin" ]; then
122+
OUTPUT_EXT="dylib"
123+
fi
124+
125+
mkdir -p build
126+
go build -buildmode=c-shared -trimpath -ldflags="-s -w" \
127+
-o build/signer-${{ matrix.goarch }}.${OUTPUT_EXT} \
128+
./sharedlib/sharedlib.go || echo "Build failed for ${{ matrix.goos }}/${{ matrix.goarch }}"
129+
fi
130+
131+
- name: Upload artifacts
132+
if: matrix.goos != 'windows'
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: sharedlib-${{ matrix.goos }}-${{ matrix.goarch }}
136+
path: build/*

0 commit comments

Comments
 (0)