1
+ name : EC2Cryptomatic build and deployment
2
+
3
+ on :
4
+ - push
5
+ - pull_request
6
+
7
+ jobs :
8
+
9
+ code_linting :
10
+ runs-on : ubuntu-latest
11
+ container :
12
+ image : cytopia/golint:latest
13
+ volumes :
14
+ - /__w/ec2cryptomatic/ec2cryptomatic:/data
15
+
16
+ steps :
17
+ - uses : actions/checkout@v2
18
+ - name : Starting code linting
19
+ run : golint .
20
+
21
+
22
+ code_testing :
23
+ runs-on : ubuntu-latest
24
+ steps :
25
+ - uses : actions/checkout@v2
26
+ with :
27
+ # Disabling shallow clone is recommended for improving relevancy of reporting
28
+ fetch-depth : 0
29
+
30
+ - name : Setup Golang
31
+ uses : actions/setup-go@v2
32
+ with :
33
+ go-version : ' ^1.14' # The Go version to download (if necessary) and use.
34
+
35
+ - name : Run Golang test
36
+ run : go test .
37
+
38
+ - name : SonarCloud Scan
39
+ uses : sonarsource/sonarcloud-github-action@master
40
+ env :
41
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42
+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
43
+
44
+ - name : Create Docker image file
45
+ run : docker build .
46
+
47
+
48
+ code_compiling :
49
+ needs : [code_linting, code_testing]
50
+ runs-on : ubuntu-latest
51
+ strategy :
52
+ matrix :
53
+ os : [linux, windows, freebsd]
54
+ arch : [amd64, arm]
55
+ exclude :
56
+ - os : windows
57
+ arch : arm
58
+ fail-fast : true
59
+
60
+ steps :
61
+ - uses : actions/checkout@v2
62
+
63
+ - name : Setup Golang
64
+ uses : actions/setup-go@v2
65
+ with :
66
+ go-version : ' ^1.14' # The Go version to download (if necessary) and use.
67
+
68
+ - run : GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o ec2cryptomatic
69
+
70
+ - name : Package artefacts
71
+ run : zip ec2cryptomatic.${{ matrix.os }}.${{ matrix.arch }}.zip ec2cryptomatic
72
+
73
+ - uses : actions/upload-artifact@v2
74
+ with :
75
+ path : ec2cryptomatic.${{ matrix.os }}.${{ matrix.arch }}.zip
76
+
77
+
78
+ code_deploying :
79
+ needs : [code_linting, code_testing, code_compiling]
80
+ runs-on : ubuntu-latest
81
+ if : github.ref == 'refs/heads/master'
82
+ steps :
83
+ - uses : actions/checkout@v2
84
+ - name : Set VERSION variable
85
+ id : vars
86
+ run : echo ::set-output name=tag_version::"$(head -1 VERSION)"
87
+
88
+ - name : Download artefacts before uploading
89
+ uses : actions/download-artifact@v2
90
+
91
+ - name : Create a new release
92
+ id : create_release
93
+ uses : actions/create-release@v1
94
+ env :
95
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
96
+ with :
97
+ tag_name : ${{ steps.vars.outputs.tag_version }}
98
+ release_name : Release ${{ steps.vars.outputs.tag_version }}
99
+ draft : false
100
+ prerelease : false
101
+
102
+ - name : Upload Release Assets
103
+ id : upload-release-assets
104
+ uses : dwenegar/upload-release-assets@v1
105
+ env :
106
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
107
+ with :
108
+ release_id : ${{ steps.create_release.outputs.id }}
109
+ assets_path : artifact/
110
+
111
+ - name : Publish image to Docker Hub Registry
112
+
113
+ with :
114
+ name : jbrt/ec2cryptomatic
115
+ username : ${{ secrets.DOCKER_USERNAME }}
116
+ password : ${{ secrets.DOCKER_PASSWORD }}
117
+ dockerfile : Dockerfile
118
+ tags : " latest,${{ steps.vars.outputs.tag_version }}"
119
+
0 commit comments