init · DockRouter/DockRouter@daea51e · GitHub
Skip to content

Commit daea51e

Browse files
committed
init
0 parents  commit daea51e

105 files changed

Lines changed: 25327 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yml‎

Lines changed: 56 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.22'
21+
cache: true
22+
23+
- name: Download dependencies
24+
run: go mod download
25+
26+
- name: Run tests
27+
run: go test -v -race -coverprofile=coverage.out ./...
28+
29+
- name: Upload coverage
30+
uses: codecov/codecov-action@v4
31+
with:
32+
file: ./coverage.out
33+
fail_ci_if_error: false
34+
35+
lint:
36+
name: Lint
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Setup Go
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.22'
46+
cache: true
47+
48+
- name: Run golangci-lint
49+
uses: golangci/golangci-lint-action@v4
50+
with:
51+
version: latest
52+
args: --timeout=5m
53+
54+
build:
55+
name: Build
56+
runs-on: ubuntu-latest
57+
needs: [test, lint]
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
62+
- name: Setup Go
63+
uses: actions/setup-go@v5
64+
with:
65+
go-version: '1.22'
66+
cache: true
67+
68+
- name: Build binary
69+
run: |
70+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dockrouter ./cmd/dockrouter
71+
72+
- name: Upload artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: dockrouter-linux-amd64
76+
path: dockrouter
77+
78+
docker:
79+
name: Docker Build
80+
runs-on: ubuntu-latest
81+
needs: build
82+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v4
86+
87+
- name: Set up Docker Buildx
88+
uses: docker/setup-buildx-action@v3
89+
90+
- name: Login to Docker Hub
91+
if: github.event_name != 'pull_request'
92+
uses: docker/login-action@v3
93+
with:
94+
username: ${{ secrets.DOCKERHUB_USERNAME }}
95+
password: ${{ secrets.DOCKERHUB_TOKEN }}
96+
97+
- name: Extract metadata
98+
id: meta
99+
uses: docker/metadata-action@v5
100+
with:
101+
images: ${{ secrets.DOCKERHUB_USERNAME }}/dockrouter
102+
tags: |
103+
type=ref,event=branch
104+
type=sha,prefix=
105+
type=raw,value=latest,enable={{is_default_branch}}
106+
107+
- name: Build and push
108+
uses: docker/build-push-action@v5
109+
with:
110+
context: .
111+
push: ${{ github.event_name != 'pull_request' }}
112+
tags: ${{ steps.meta.outputs.tags }}
113+
labels: ${{ steps.meta.outputs.labels }}
114+
cache-from: type=gha
115+
cache-to: type=gha,mode=max

‎.github/workflows/release.yml‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
name: GoReleaser
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: '1.22'
25+
cache: true
26+
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v5
29+
with:
30+
version: latest
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
35+
docker:
36+
name: Docker Release
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Login to Docker Hub
46+
uses: docker/login-action@v3
47+
with:
48+
username: ${{ secrets.DOCKERHUB_USERNAME }}
49+
password: ${{ secrets.DOCKERHUB_TOKEN }}
50+
51+
- name: Extract tag
52+
id: tag
53+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
54+
55+
- name: Build and push
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
push: true
60+
tags: |
61+
${{ secrets.DOCKERHUB_USERNAME }}/dockrouter:${{ steps.tag.outputs.VERSION }}
62+
${{ secrets.DOCKERHUB_USERNAME }}/dockrouter:latest
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max

‎.goreleaser.yml‎

Lines changed: 54 additions & 0 deletions

0 commit comments

Comments
 (0)