-
Notifications
You must be signed in to change notification settings - Fork 8
194 lines (163 loc) · 6.36 KB
/
go.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
name: Go
on:
push:
branches: [ '*' ]
tags: [ '*.*.*', '*.*.*-*', 'test-release-*' ]
pull_request:
branches: [ 'main', 'v*.*.*' ]
env:
CDT_VAULT_SECRET: very_secret
jobs:
build:
runs-on: ${{ matrix.os }}
outputs:
sha_short: ${{steps.vars.outputs.sha_short}}
arch: ${{steps.vars.outputs.arch}}
os: ${{steps.vars.outputs.os}}
strategy:
matrix:
arch: [amd64,arm64]
cgo: [0]
os: [windows-latest, ubuntu-latest ]
include:
- os: macos-latest
arch: arm64
cgo: 1
- os: macos-latest
arch: amd64
cgo: 1
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: gh-pages/package-lock.json
- name: generate vars
id: vars
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "::set-output name=arch::${{matrix.arch}}"
echo "::set-output name=os::$(go run test/get-os.go)"
echo "::set-output name=ext::$(go run test/get-os.go extension)"
- name: Build
env:
GOARCH: ${{matrix.arch}}
CGO_ENABLED: ${{matrix.cgo}}
run: |
go build -o build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} -ldflags='-X main.version=${{github.ref_name}} -X main.buildNum=${{github.run_number}} -X main.appName=cdt'
go build -o build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} -ldflags="-X main.version=${{github.ref_name}} -X main.buildNum=${{github.run_number}} -X main.appName=cola -X 'main.appLongName=Command Launcher'"
- name: Test & Benchmark
run: go test -v ./...
- name: Integration-test
run: |
echo "${{github.workspace}}/test"
SCRIPT_DIR='${{github.workspace}}/test' test/integration.sh
shell: bash
- name: documentation lint
run: cd gh-pages && npm install && npm run test
- name: Upload CDT
uses: actions/upload-artifact@v3
with:
name: ${{steps.vars.outputs.os}}-${{matrix.arch}}
path: build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}}
- name: Upload COLA
uses: actions/upload-artifact@v3
with:
name: ${{steps.vars.outputs.os}}-${{matrix.arch}}
path: build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}}
- name: Rename binary name for release
if: startsWith(github.ref, 'refs/tags/')
run: |
mv build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}}
mv build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}}
build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}}
packaging:
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Download linux amd64 artifact
uses: actions/download-artifact@v3
with:
name: linux-amd64
path: output/linux/amd64/
- name: Download linux arm64 artifact
uses: actions/download-artifact@v3
with:
name: linux-arm64
path: output/linux/arm64/
- name: Download windows amd64 artifact
uses: actions/download-artifact@v3
with:
name: windows-amd64
path: output/windows/amd64/
- name: Download darwin amd64 artifact
uses: actions/download-artifact@v3
with:
name: darwin-amd64
path: output/darwin/amd64/
- name: Download darwin-arm64 artifact
uses: actions/download-artifact@v3
with:
name: darwin-arm64
path: output/darwin/arm64/
- name: Rename binary name
run: |
mv output/darwin/arm64/cdt_darwin_arm64_${{needs.build.outputs.sha_short}} output/darwin/arm64/cdt
mv output/darwin/amd64/cdt_darwin_amd64_${{needs.build.outputs.sha_short}} output/darwin/amd64/cdt
mv output/linux/amd64/cdt_linux_amd64_${{needs.build.outputs.sha_short}} output/linux/amd64/cdt
mv output/linux/arm64/cdt_linux_arm64_${{needs.build.outputs.sha_short}} output/linux/arm64/cdt
mv output/windows/amd64/cdt_windows_amd64_${{needs.build.outputs.sha_short}} output/windows/amd64/cdt.exe
- name: Zip the package
uses: thedoctor0/zip-release@master
if: startsWith(github.ref, 'refs/tags/')
with:
type: 'zip'
filename: cdt_${{github.ref_name}}.zip
directory: output
- name: Upload
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/tags/')
with:
name: all-in-one.zip
path: output/cdt_${{github.ref_name}}.zip
- name: Display structure of downloaded files
run: ls -R
working-directory: output
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: output/cdt_${{github.ref_name}}.zip
update-latest-version:
needs: [ packaging ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate latest version file
run: |
mkdir output
cat release-notes.yaml | yq -r '."${{github.ref_name}}"' > output/latest.yaml
- name: Display latest version file content
run: cat output/latest.yaml
- name: Upload latest version index
uses: actions/upload-artifact@v3
with:
name: latest.yaml
path: output/latest.yaml
- name: Release & Update the version index
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: output/latest.yaml