-
Notifications
You must be signed in to change notification settings - Fork 16
96 lines (84 loc) · 2.81 KB
/
go.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
name: Go
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
jobs:
test:
name: Test
strategy:
matrix:
golang: ["1.14"]
os: ["ubuntu-latest", "macos-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go ${{ matrix.golang }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.golang }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Download golangci-lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.8
- name: Make sure it builds
run: go build
- name: Lint
run: $(go env GOPATH)/bin/golangci-lint run --timeout=10m
- name: Test
run: go test -v ./...
release:
name: Release
runs-on: ubuntu-latest
needs: [test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download gox
run: go get github.com/mitchellh/gox
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get Git tag
id: tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Build release assets
run: |
$(go env GOPATH)/bin/gox \
-output='build/gocat-${{ steps.tag.outputs.TAG }}-{{ .OS }}-{{ .Arch }}' \
-arch='amd64' \
-os='linux darwin' \
-verbose \
-ldflags "-s -w"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
body: Changelog at https://github.com/sumup-oss/gocat/blob/master/CHANGELOG.md
# TODO: Replace with glob pattern once `actions/upload-release-asset` supports it
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/gocat-${{ steps.tag.outputs.TAG }}-darwin-amd64
asset_name: gocat-${{ steps.tag.outputs.TAG }}-darwin-amd64
asset_content_type: application/octet-stream
# TODO: Replace with glob pattern once `actions/upload-release-asset` supports it
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/gocat-${{ steps.tag.outputs.TAG }}-linux-amd64
asset_name: gocat-${{ steps.tag.outputs.TAG }}-linux-amd64
asset_content_type: application/octet-stream