-
Notifications
You must be signed in to change notification settings - Fork 77
129 lines (112 loc) · 3.5 KB
/
go.yaml
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
129
name: Go
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.21
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
shell: bash
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: matrix.os == 'ubuntu-latest'
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.21
- uses: actions/checkout@v1
- run: make metalint
docker_deploy:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
name: "publish image on dockerhub"
needs: [test, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: List docker image tags
uses: docker/metadata-action@v4
id: dockermeta
with:
images: tsuru/client
tags: |
type=match,value=latest,pattern=\d.\d.\d
type=edge
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Get version from tag
id: gittag
uses: jimschubert/query-tag-action@v1
with:
commit-ish: HEAD
- name: Build and Push image to docker hub
uses: docker/build-push-action@v3
with:
file: ./Dockerfile
build-args: |
TSURU_BUILD_VERSION="${{steps.gittag.outputs.tag}}"
push: true
tags: ${{ steps.dockermeta.outputs.tags }}
labels: ${{ steps.dockermeta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8
deploy:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
needs: [test, lint]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.21
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: release
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
# The automatic GitHub token (namely secrets.GITHUB_TOKEN) doesn't have permission cross-project.
HOMEBREW_TSURU_REPOSITORY_AUTH_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUR_KEY: ${{ secrets.PRIVATE_SSH_KEY }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
- name: packagecloud
run: ./misc/build_publish_to_packagecloud.sh
env:
PACKAGE_NAME: tsuru-client
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
SKIP_GORELEASER: "true"