-
Notifications
You must be signed in to change notification settings - Fork 1
281 lines (247 loc) · 8.77 KB
/
release.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
setup:
env:
BASE_PROJECT: armory-cli
GRGIT_USER: GitHub
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
outputs:
version: ${{ github.ref_name }}
changelog: ${{ steps.changelog.outputs.CHANGELOG }}
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
token: ${{ secrets.ARMORY_PLATFORM_GITHUB_PAT_TOKEN }}
submodules: recursive
- name: Fetch full history
run: git fetch --prune --tags --unshallow
- name: Generate Changelog
id: changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export NEW_TAG="${{ github.ref_name }}"
echo "NEW_TAG=$NEW_TAG"
export PREVIOUS_TAG=$(git describe --abbrev=0 --tags "${NEW_TAG}"^ --match 'v[0-9]*')
echo "PREVIOUS_TAG=$PREVIOUS_TAG"
export CHANGELOG=`git log $NEW_TAG...$PREVIOUS_TAG --oneline`
echo "CHANGELOG=$CHANGELOG"
#Format the changelog so it's markdown compatible
CHANGELOG="${CHANGELOG//$'%'/%25}"
CHANGELOG="${CHANGELOG//$'\n'/%0A}"
CHANGELOG="${CHANGELOG//$'\r'/%0D}"
echo ::set-output name=CHANGELOG::$(echo -e "${CHANGELOG}")
run-quality-suite:
name: Run Quality Suite
needs:
- setup
runs-on: ubuntu-latest
steps:
- name: Get GitHub App Installation Token for Private Go Repos
id: get_token
uses: machine-learning-apps/[email protected]
with:
APP_PEM: ${{ secrets.GO_PRIVATE_REPO_APP_KEY }}
APP_ID: ${{ secrets.GO_PRIVATE_REPO_APP_ID }}
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
token: ${{ secrets.ARMORY_PLATFORM_GITHUB_PAT_TOKEN }}
submodules: recursive
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version-file: 'go.mod'
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-
- name: Configure git for private modules
env:
TOKEN: ${{ steps.get_token.outputs.app_token }}
run: git config --global url."https://x-access-token:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Run build
run: |
make all
- name: SonarQube Analysis
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
create-release:
name: Create Release
needs:
- setup
- run-quality-suite
runs-on: ubuntu-latest
outputs:
release-url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ needs.setup.outputs.version }}"
release_name: ${{ github.event.repository.name }} ${{ needs.setup.outputs.version }}
body: |
${{ needs.setup.outputs.changelog }}
draft: false
prerelease: false
compile:
name: Compile Binaries and Upload to Release
needs:
- setup
- create-release
runs-on: ubuntu-latest
strategy:
matrix:
os: [ darwin, windows, linux ]
arch: [ amd64, arm64 ]
include:
- os: windows
arch: amd64
ext: .exe
exclude:
- os: windows
arch: arm64
env:
ASSET_NAME: armory-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}
steps:
- name: Get GitHub App Installation Token for Private Go Repos
id: get_token
uses: machine-learning-apps/[email protected]
with:
APP_PEM: ${{ secrets.GO_PRIVATE_REPO_APP_KEY }}
APP_ID: ${{ secrets.GO_PRIVATE_REPO_APP_ID }}
- name: Checkout Code
uses: actions/checkout@v2
with:
token: ${{ secrets.ARMORY_PLATFORM_GITHUB_PAT_TOKEN }}
submodules: recursive
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version-file: 'go.mod'
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-
- name: Configure git for private modules
env:
TOKEN: ${{ steps.get_token.outputs.app_token }}
run: git config --global url."https://x-access-token:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Build CLI
env:
VERSION: ${{ needs.setup.outputs.version }}
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CLI_EXT: ${{ matrix.ext }}
run: make build
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release-url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./build/dist/${{ matrix.os }}_${{ matrix.arch }}/armory${{ matrix.ext }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: binary/octet-stream
build-push:
name: Build and Push Docker Image
needs:
- setup
- create-release
- compile
runs-on: ubuntu-latest
outputs:
docker-version: ${{ steps.vars.outputs.version }}
steps:
- name: Get GitHub App Installation Token for Private Go Repos
id: get_token
uses: machine-learning-apps/[email protected]
with:
APP_PEM: ${{ secrets.GO_PRIVATE_REPO_APP_KEY }}
APP_ID: ${{ secrets.GO_PRIVATE_REPO_APP_ID }}
- name: Checkout Code
uses: actions/checkout@v2
with:
token: ${{ secrets.ARMORY_PLATFORM_GITHUB_PAT_TOKEN }}
submodules: recursive
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version-file: 'go.mod'
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-
- name: Configure git for private modules
env:
TOKEN: ${{ steps.get_token.outputs.app_token }}
run: git config --global url."https://x-access-token:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Login to Artifactory
uses: docker/login-action@v3
with:
username: ${{ secrets.ARTIFACTORY_USER }}
password: ${{ secrets.ARTIFACTORY_TOKEN }}
registry: armory-docker-local.jfrog.io
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASS }}
- name: Set variables
id: vars
run: |
# Trim 'v' prefix from version
echo "version=$(cut -c2- <<< ${{ needs.setup.outputs.version }})" >> $GITHUB_OUTPUT
- name: Build and push Docker image
env:
REGISTRY: docker.io
VERSION: ${{ needs.setup.outputs.version }}
IMAGE_TAG_VERSION: ${{ steps.vars.outputs.version }}
IMAGE_TAG: latest
PUSH: true
run: make release
scan-image:
name: CVE Image Scan
needs:
- build-push
- setup
runs-on: ubuntu-latest
steps:
- name: Run Security Scan
uses: armory-io/[email protected]
with:
url: https://aquasec.armory.io
registry: Docker Hub
username: ${{ secrets.AQUA_USER }}
password: ${{ secrets.AQUA_PASSWORD }}
image: armory/armory-cli:${{needs.build-push.outputs.docker-version}}
run-s3-releaser:
name: Update Releaser Repository
needs:
- setup
- create-release
- compile
runs-on: ubuntu-latest
steps:
- name: Dispatch update event to releaser repository
run: |
curl -X POST -H "Authorization: token ${{ secrets.ARMORY_PLATFORM_GITHUB_PAT_TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/armory-io/armory-cli-releaser/dispatches --data "{\"event_type\": \"ReleaseCli\", \"client_payload\": {\"release_tag\": \"${{ github.ref_name }}\"}}"