-
Notifications
You must be signed in to change notification settings - Fork 1
213 lines (199 loc) · 6.56 KB
/
ci.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- v*
# Allows to run this via the Actions tab
workflow_dispatch:
env:
REGISTRY: quay.io
jobs:
lint:
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: Allow write access to checks to allow the action to annotate code in the PR.
checks: write
name: Linter
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54
check-license:
name: License scan
runs-on: ubuntu-latest
timeout-minutes: 5
env:
REPORT_FILE: gl-license-scanning-report.json
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.22
- name: License scanning
run: |
go install github.com/google/go-licenses@latest
go-licenses check . --disallowed_types=forbidden,restricted
- name: Generate license report
run: |
go-licenses report . > licenses.csv
- name: Save license scan report
uses: actions/upload-artifact@v3
with:
name: license_scanning
path: licenses.csv
check-go-releaser:
name: Go releaser check
runs-on: ubuntu-latest
timeout-minutes: 5
env:
QUAY_USER: ${{ secrets.QUAY_USER }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: v1.25.1
args: check
test:
name: Tests
needs:
- lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Run tests
run: go test -v ./...
publish:
name: Publish the release
if: ${{ github.ref_type == 'tag' }}
needs:
- test
runs-on: ubuntu-latest
timeout-minutes: 15
env:
TAG: ${{ github.ref_name }}
S3_BUCKET: "s3://cli-dl.stackstate.com/stackstate-cli/"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Log in to the Container registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Generate release notes
uses: ./.github/actions/quay
with:
image: quay.io/stackstate/go-rk:v0.2.4
options: >
-e RK_JIRA_PROJECT=STAC
-e RK_JIRA_URL=https://stackstate.atlassian.net
-e RK_JIRA_USER=${{ secrets.JIRA_USER }}
-e RK_JIRA_TOKEN=${{ secrets.JIRA_TOKEN }}
entrypoint: go-rk
run: >
release-notes
--fix-version cli2-${{ env.TAG }}
--output-file /workspace/release-notes.md
--title "CLI ${{ env.TAG }}"
- name: Save release notes
uses: actions/upload-artifact@v3
with:
name: release-notes
path: release-notes.md
- name: Generate JSON release notes
uses: ./.github/actions/quay
with:
image: quay.io/stackstate/go-rk:v0.2.4
options: >
-e RK_JIRA_PROJECT=STAC
-e RK_JIRA_URL=https://stackstate.atlassian.net
-e RK_JIRA_USER=${{ secrets.JIRA_USER }}
-e RK_JIRA_TOKEN=${{ secrets.JIRA_TOKEN }}
entrypoint: go-rk
run: >
release-notes
--fix-version cli2-${{ env.TAG }}
-o json
--output-file /workspace/release-notes.json
--title "CLI ${{ env.TAG }}"
- name: Save JSON release notes
uses: actions/upload-artifact@v3
with:
name: release-notes-json
path: release-notes.json
- name: Log in to the Container registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Go releaser publish
uses: goreleaser/goreleaser-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: v1.25.1
args: release --release-notes release-notes.md
- name: Write latest version to file
run: mkdir -p dist && echo "${{ env.TAG }}" > dist/LATEST_VERSION
- name: Publish latest version to S3
uses: keithweaver/aws-s3-github-action@v1.0.0
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_DEFAULT_REGION }}
command: cp
source: dist/LATEST_VERSION
destination: ${{ env.S3_BUCKET }}
- name: Publish installers to S3
uses: keithweaver/aws-s3-github-action@v1.0.0
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID}}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_DEFAULT_REGION }}
command: cp
source: scripts/publish/installers/
destination: ${{ env.S3_BUCKET }}
flags: --recursive