-
Notifications
You must be signed in to change notification settings - Fork 77
151 lines (143 loc) · 4.41 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Copyright © 2023 tsuru-client authors
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
name: Go
on: [push, pull_request]
env:
GO_VERSION: "1.20.2"
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: make test-ci
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: make lint
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pre-commit/[email protected]
coverage:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta-v2'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
- run: make test-coverage
- name: Generate coverage badge
run: ./scripts/coverage_badge.sh
- name: Save static files for gh-pages
run: |
mkdir -p public
cp -r coverage/ public/coverage/
- name: Publish to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
force_orphan: true
docker_deploy:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
name: "publish image on dockerhub"
needs: [test, lint, pre-commit]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
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: Build and Push image to docker hub
uses: docker/build-push-action@v3
with:
file: ./Dockerfile
build-args: |
DOCKER_BUILD_TSURU_VERSION="v${{steps.dockermeta.outputs.version}}"
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
release:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
needs: [test, lint, pre-commit]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: "~> v1.18" # v1.18.2
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: Publish to Packagecloud
run: ./scripts/build_publish_to_packagecloud.sh
env:
PACKAGE_NAME: tsuru-client
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
SKIP_GORELEASER: "true"