-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (109 loc) · 3.18 KB
/
pipeline.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: pipeline
on: [push]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Check out code
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=30m0s
skip-cache: true
test:
needs: lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Run tests
run: make test-coverage
- name: Upload Coverage report to CodeCov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./coverage.txt
build:
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Build
run: make build
- name: Cache the build artifacts
if: contains(github.ref, 'refs/tags/')
uses: actions/cache@v3
with:
path: build
key: build-${{ hashFiles('**/*', '!build', '!.git') }}
restore-keys: |
build-
release:
if: contains(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Restore build artifacts
uses: actions/cache@v3
with:
path: build
key: build-${{ hashFiles('**/*', '!build', '!.git') }}
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: false
files: |
build/telegram-logger-linux-amd64
build/telegram-logger-windows-amd64.exe
build/telegram-logger-darwin-amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
push-to-dockerhub:
if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push (latest)
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v3
with:
# context: .
push: true
tags: psyb0t/telegram-logger:latest
- name: Get Release Version
if: contains(github.ref, 'refs/tags/')
run: |
RELEASE_VERSION=${GITHUB_REF#refs/*/}
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Build and Push New Release
if: contains(github.ref, 'refs/tags/')
uses: docker/build-push-action@v3
with:
# context: .
push: true
tags: psyb0t/telegram-logger:${{env.RELEASE_VERSION}}