-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (141 loc) · 4.77 KB
/
all.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Lint, Test, Build, Publish
on:
push:
branches:
- master
tags:
- v*
pull_request:
env:
GOLANG_CI_VERSION: "1.27.0"
APP_NAME: "k6cloudlogs"
DOCKER_IMAGE_ID: "loadimpact/k6cloudlogs"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.14.x
- name: Checkout code
uses: actions/checkout@v2
- name: Populate dependencies
run: go mod vendor -v
- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$GOLANG_CI_VERSION
- name: Lint
run: ./bin/golangci-lint run --out-format=tab ./...
test:
strategy:
matrix:
go-version: [1.14.x]
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix['go-version'] }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: GOMAXPROCS=2 go test -p 2 -race -timeout 120s -coverprofile=/tmp/code-coverage.out ./...
- name: Generate coverage report
run: go tool cover -html=/tmp/code-coverage.out -o /tmp/code-coverage.html
- uses: actions/upload-artifact@v1
with:
name: test coverage report
path: /tmp/code-coverage.html
- name: Build
run: go build .
docker:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Populate dependencies #TODO: delete after vendoring
run: go mod vendor -v
- name: Build
run: docker build --tag image .
- name: Publish
if: github.event_name != 'pull_request'
run: |
echo "REF=${{ github.ref }}"
echo "DOCKER_IMAGE_ID=$DOCKER_IMAGE_ID"
#
# Log into registry
echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo "$VERSION" | sed -e 's/^v//')
echo "VERSION=$VERSION"
docker tag image "$DOCKER_IMAGE_ID:$VERSION"
docker push "$DOCKER_IMAGE_ID:$VERSION"
# We also want to tag the latest stable version as latest
if [[ "$VERSION" != "master" ]] && [[ ! "$VERSION" =~ (RC|rc) ]]; then
docker tag image "$DOCKER_IMAGE_ID:latest"
docker push "$DOCKER_IMAGE_ID:latest"
fi
release:
runs-on: ubuntu-latest
needs: [lint, test]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.14.x
- name: Checkout code
uses: actions/checkout@v2
- name: Print used Go version
run: go version
- name: Build
run: |
./build-release.sh
- name: Upload Build
uses: actions/upload-artifact@v1
with:
name: k6cloudlogs-build
path: "dist/"
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Linux 64bit
id: upload-release-asset-linux64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "dist/${{ env.APP_NAME }}-linux64.tar.gz"
asset_name: "${{ env.APP_NAME }}-linux64.tar.gz"
asset_content_type: application/gzip
- name: Upload Windows 64bit
id: upload-release-asset-windows-64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "dist/${{ env.APP_NAME }}-win64.zip"
asset_name: "${{ env.APP_NAME }}-win64.zip"
asset_content_type: application/zip
- name: Upload MacOS
id: upload-release-asset-macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "dist/${{ env.APP_NAME }}-mac.zip"
asset_name: "${{ env.APP_NAME }}-mac.zip"
asset_content_type: application/zip