-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (91 loc) · 2.81 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: build
on:
push:
branches: [ master ]
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request:
jobs:
tests:
name: Unit tests + coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.20
- name: Get dependencies
run: go get -v -t -d ./...
- name: Build
run: go build -v ./...
- name: Test with coverage
run: go test -v ./... -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
lint:
name: Go linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint the codebase
uses: golangci/golangci-lint-action@v3
with:
version: latest
publish:
name: Docker publish
if: contains(github.ref, 'refs/tags/')
needs: [ tests, lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
build-args: version=${{ github.ref_name }}+${{ github.sha }}
tags: '${{ github.repository }}:${{ github.ref_name }},${{ github.repository }}:latest'
push: true
- name: Update repo description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ github.repository }}
release-bin:
name: Release binaries
if: contains(github.ref, 'refs/tags/')
needs: [ tests, lint ]
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
strategy:
matrix:
target: [http2smtp, http2smtp-lambda]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: linux
goarch: ${{ matrix.goarch }}
goversion: '1.20'
project_path: cmd/${{ matrix.target }}
binary_name: ${{ matrix.target }}
extra_files: LICENSE README.md
release_tag: ${{ github.ref_name }}
ldflags: -X github.com/eexit/http2smtp/internal/api.Version=${{ github.ref_name }}+${{ github.sha }}
executable_compression: upx