Skip to content

Commit 16b7018

Browse files
committed
ci: cicd and dockerfile
Signed-off-by: QuentinN42 <quentin@lieumont.fr>
1 parent 0e8aeca commit 16b7018

File tree

9 files changed

+206
-1
lines changed

9 files changed

+206
-1
lines changed

.github/workflows/build-test.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 🔨 Build Test
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**.go"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Test Builds
12+
strategy:
13+
matrix:
14+
go-version: [1.21.x]
15+
os: [ubuntu-latest]
16+
runs-on: ${{ matrix.os }}
17+
steps:
18+
- name: Set up Go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: ${{ matrix.go-version }}
22+
23+
- name: Check out code
24+
uses: actions/checkout@v3
25+
26+
- name: Go Mod hygine
27+
run: |
28+
go clean -modcache
29+
go mod tidy
30+
31+
- name: Build
32+
run: go build .
33+
working-directory: cmd/proxy/

.github/workflows/lint-report.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 💅 Lint report
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**.go"
7+
workflow_dispatch:
8+
9+
jobs:
10+
report:
11+
name: Report
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-go@v3
16+
with:
17+
go-version: "1.21.x"
18+
- name: Install report card
19+
run: |
20+
git clone https://github.com/gojp/goreportcard.git
21+
cd goreportcard
22+
make install
23+
go install ./cmd/goreportcard-cli
24+
cd ..
25+
rm -rf goreportcard
26+
- name: Report
27+
run: goreportcard-cli -v -t 100
28+
29+
golangci-lint:
30+
name: Lint (golangci-lint)
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/setup-go@v4
34+
with:
35+
go-version: "1.21.x"
36+
cache: false
37+
- uses: actions/checkout@v3
38+
- name: golangci-lint
39+
uses: golangci/golangci-lint-action@v3

.github/workflows/release-binary.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 🎉 Release Binary
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
goreleaser:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- uses: actions/setup-go@v3
19+
with:
20+
go-version: 1.21.x
21+
22+
- uses: goreleaser/goreleaser-action@v4
23+
with:
24+
args: "release --clean"
25+
version: latest
26+
env:
27+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/release-docker.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 🐳 Release Docker
2+
3+
on:
4+
workflow_run:
5+
workflows: ["🎉 Release Binary"]
6+
types:
7+
- completed
8+
workflow_dispatch:
9+
10+
jobs:
11+
release-docker:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Git Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: "Get Previous tag"
20+
id: previoustag
21+
uses: "WyriHaximus/github-action-get-previous-tag@v1"
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v2
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Login to DockerHub
30+
uses: docker/login-action@v2
31+
with:
32+
username: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_TOKEN }}
34+
35+
- name: Docker meta
36+
id: meta
37+
uses: docker/metadata-action@v4
38+
with:
39+
images: ${{ secrets.DOCKERHUB_REPO }}/proxy
40+
tags: |
41+
# set latest tag for default branch
42+
type=raw,value=latest,enable={{is_default_branch}}
43+
type=semver,pattern={{version}},value=${{ steps.previoustag.outputs.tag }}
44+
45+
- name: Build and push
46+
uses: docker/build-push-action@v4
47+
with:
48+
context: .
49+
platforms: linux/amd64,linux/arm64
50+
push: ${{ github.event_name != 'pull_request' }}
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/report-card.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# update report card on push on main
2+
name: 🧚‍♀️ Update Report Card
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
report-card:
12+
name: Update Report Card
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Request Report Update
16+
run: |
17+
curl -X POST -F "repo=github.com/$GITHUB_REPOSITORY" https://goreportcard.com/checks

.goreleaser.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
builds:
5+
- env:
6+
- CGO_ENABLED=0
7+
goos:
8+
- linux
9+
- windows
10+
- darwin
11+
goarch:
12+
- "386"
13+
- amd64
14+
- arm64
15+
binary: "escape-proxy"
16+
main: ./cmd/{{ .ProjectName }}/{{ .ProjectName }}.go
17+
18+
# will not auto-publish the release
19+
# release:
20+
# draft: true
21+
22+
checksum:
23+
algorithm: sha256

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.21.0-alpine as builder
2+
3+
WORKDIR /usr/src
4+
5+
COPY go.mod go.sum ./
6+
7+
RUN go mod download && go mod verify
8+
9+
COPY . .
10+
RUN go build -v -o /usr/local/bin/prog ./cmd/proxy/proxy.go
11+
12+
FROM alpine:3.14
13+
COPY --from=builder /usr/local/bin/prog ./prog
14+
ENTRYPOINT [ "./prog" ]
File renamed without changes.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module go-proxy
1+
module github.com/Escape-Technologies/proxy
22

33
go 1.21
44

0 commit comments

Comments
 (0)