-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (112 loc) · 3.38 KB
/
ci.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
name: Continous Integration
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
permissions:
contents: read
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Task
uses: arduino/setup-task@v1
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Run tests
run: |
task install:gotestsum
task test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
runs-on: ubuntu-latest
needs:
- golangci-lint
- test
strategy:
matrix:
goos:
- linux
- darwin
goarch:
- amd64
- arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create GitHub App Token
uses: actions/create-github-app-token@v1
id: token
with:
app-id: ${{ secrets.RELEASE_PLEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PLEASE_PRIVATE_KEY }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Build
run: go build -buildvcs=true -o ./bin/${{ matrix.goarch }}/${{ matrix.goos }}/kubectl-mapr-ticket ./
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
- name: Compress
run: |
# Copy LICENSE and README.md to artifact directory
mkdir -p ./bin/${{ matrix.goarch }}/${{ matrix.goos }}
cp ./LICENSE ./bin/${{ matrix.goarch }}/${{ matrix.goos }}/
cp ./README.md ./bin/${{ matrix.goarch }}/${{ matrix.goos }}/
cp ./hack/kubectl_complete-mapr_ticket ./bin/${{ matrix.goarch }}/${{ matrix.goos }}/
# Compress artifact directory contents
tar -czvf \
./kubectl-mapr-ticket-${{ matrix.goarch }}-${{ matrix.goos }}.tar.gz \
-C ./bin/${{ matrix.goarch }}/${{ matrix.goos }}/ .
- name: Upload artifact
if: contains(github.ref, 'tags')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ steps.token.outputs.token }}
file: ./kubectl-mapr-ticket-${{ matrix.goarch }}-${{ matrix.goos }}.tar.gz
tag: ${{ github.ref }}
overwrite: true
- name: Upload artifact for PRs
if: ${{ !contains(github.ref, 'tags') }}
uses: actions/upload-artifact@v4
with:
name: kubectl-mapr-ticket-${{ matrix.goarch }}-${{ matrix.goos }}.tar.gz
path: ./kubectl-mapr-ticket-${{ matrix.goarch }}-${{ matrix.goos }}.tar.gz
krew-release:
runs-on: ubuntu-latest
needs: build
if: contains(github.ref, 'tags')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update new version in krew-index
uses: rajatjindal/[email protected]