This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
130 lines (114 loc) · 4.46 KB
/
release-weekly-build.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
name: Release Build
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch'
required: true
default: 'main'
tag:
description: 'Release Tag'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
check-latest: true
cache: true
id: go
- name: Check license headers
run: make validate
- name: Run golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b . v1.51.1
./golangci-lint run
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
defaults:
run:
shell: bash
env:
GO111MODULE: "on"
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Install Docker CLI
if: ${{ matrix.os == 'macos-latest' }}
# Only the CLI is needed to run docker-scan e2e
run: brew install docker
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
check-latest: true
cache: true
id: go
- name: Build binary
env:
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
E2E_HUB_URL: ${{ secrets.E2E_HUB_URL }}
E2E_HUB_USERNAME: ${{ secrets.E2E_HUB_USERNAME }}
E2E_HUB_TOKEN: ${{ secrets.E2E_HUB_TOKEN }}
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build
- name: Build Mac arm64 binary
if: ${{ matrix.os == 'macos-latest' }}
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build-mac-arm64
- name: Build Linux arm64 binary
if: ${{ matrix.os == 'ubuntu-latest' }}
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build-linux-arm64
- name: Upload binary artifact
if: ${{ github.event.inputs.tag != '' }} # don't push artifacts if no tag is specified
uses: actions/upload-artifact@v2
with:
name: docker-scan-${{ matrix.os}}
path: ./bin/
- name: ON SUCCESS - Slack notification
if: ${{ success() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":heavy_check_mark: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin Weekly Build SUCCESS> on ${{ matrix.os}}"}' ${{ secrets.SLACK_WEBHOOK }}
- name: ON FAILURE - Slack notification
if: ${{ failure() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":no_entry_sign: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin Weekly Build FAILED> on ${{ matrix.os}}"}' ${{ secrets.SLACK_WEBHOOK }}
- name: ON CANCELLED - Slack notification
if: ${{ cancelled() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":bangbang: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin Weekly Build CANCELED> on ${{ matrix.os}}"}' ${{ secrets.SLACK_WEBHOOK }}
release:
runs-on: ubuntu-latest
needs: [lint, build]
if: ${{ github.event.inputs.tag != '' }} # don't release if no tag is specified
env:
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist
- name: Ship it
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*/*"
prerelease: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.tag }}
- name: ON SUCCESS - Slack notification
if: ${{ success() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":heavy_check_mark: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin has been released> ${{ github.event.inputs.tag }}"}' ${{ secrets.SLACK_WEBHOOK }}