-
Notifications
You must be signed in to change notification settings - Fork 9
215 lines (213 loc) · 7.19 KB
/
ci-main.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
name: CI
on:
push:
branches:
- main
- dev-*
tags:
- v*
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { platform: macos-14, arch: arm64, os: macos }
- { platform: macos-13, arch: x64, os: macos }
- { platform: ubuntu-20.04, arch: x64, os: linux }
- { platform: ubuntu-20.04, arch: arm32, os: linux }
- { platform: windows-2019, arch: x64, os: windows }
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup MinGW64
if: matrix.os == 'windows'
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
install: >-
mingw-w64-x86_64-gcc
- name: Setup go compiler
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: false
- name: Setup zig
if: matrix.os == 'linux' && matrix.arch == 'arm32'
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- name: Install Neo Web
run: go run mage.go InstallNeoWeb
- name: Install Neo Launcher
if: matrix.os == 'macos' || matrix.os == 'windows'
run: go run mage.go InstallNeoLauncher
- name: Build
if: matrix.arch != 'arm32'
run: go run mage.go test machbase-neo
- name: Build arm32
if: matrix.arch == 'arm32'
run: go run mage.go buildx machbase-neo linux arm packagex linux arm
- name: Codecov
if: matrix.os == 'linux' && matrix.arch == 'x64'
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Codesign and notarize macos app
if: matrix.os == 'macos'
uses: toitlang/[email protected]
with:
certificate: ${{ secrets.CODESIGN_DARWIN_CERTIFICATE }}
certificate-password: ${{ secrets.CODESIGN_DARWIN_PASS }}
username: ${{ secrets.CODESIGN_DARWIN_APPLE_ID_USERNAME }}
password: ${{ secrets.CODESIGN_DARWIN_APPLE_ID_PASS }}
apple-team-id: ${{ secrets.CODESIGN_DARWIN_APPLE_TEAM_ID }}
app-path: |-
./tmp/machbase-neo
- name: Codesign windows app
if: matrix.os == 'windows'
uses: dlemstra/code-sign-action@v1
with:
certificate: ${{ secrets.CODESIGN_WIN_CERTIFICATE }}
password: ${{ secrets.CODESIGN_WIN_PASS }}
folder: './tmp'
recursive: false
files: |
machbase-neo.exe
- name: Package
if: matrix.arch != 'arm32'
run: go run mage.go package
- name: Upload Artifact
if: startsWith(github.ref, 'refs/tags/v') != true
uses: actions/upload-artifact@v4
with:
name: machbase-neo-snapshot-${{ matrix.os }}-${{ matrix.arch }}
retention-days: 5
path: packages/machbase-neo-v*.zip
- name: Release files
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GIT_PASS }}
file: packages/machbase-neo-v*.zip
repo_name: machbase/neo-server
prerelease: true
tag: ${{ github.ref }}
overwrite: true
file_glob: true
linux-arm64:
runs-on: [ self-hosted, linux, arm64, ubuntu20 ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup go compiler
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: false
cache: false # !!! do not cache for self-hosted runner
- name: Install Neo Web
run: go run mage.go InstallNeoWeb
- name: Build
run: go run mage.go test machbase-neo
- name: Package
run: go run mage.go package
- name: Upload Artifact
if: startsWith(github.ref, 'refs/tags/v') != true
uses: actions/upload-artifact@v4
with:
name: machbase-neo-snapshot-linux-arm64
retention-days: 5
path: packages/machbase-neo-v*.zip
- name: Release files
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GIT_PASS }}
file: packages/machbase-neo-v*.zip
repo_name: machbase/neo-server
prerelease: true
tag: ${{ github.ref }}
overwrite: true
file_glob: true
docker-arm64:
runs-on: [ self-hosted, linux, ARM64, ubuntu20 ]
if: startsWith(github.ref, 'refs/tags/v')
needs: [ build ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up go compiler
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: false
cache: false # do not cache for self-hosted runner
- name: Install Neo Web
run: go run mage.go InstallNeoWeb
- name: Package for arm64
run: |
go run mage.go machbase-neo && \
scp tmp/machbase-neo ${{ secrets.DOCKER_HOST }}:/home/ubuntu/docker-build/arm64/
docker-amd64:
runs-on: [ self-hosted, linux, X64, ubuntu20 ]
if: startsWith(github.ref, 'refs/tags/v')
needs: [ docker-arm64 ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up go compiler
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: false
cache: false # do not cache for self-hosted runner
- name: Install Neo Web
run: go run mage.go InstallNeoWeb
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker version
run: docker -v
- name: Get Next Version
id: get_version
run: echo "ver=$(go run mage.go buildversion)" >> $GITHUB_OUTPUT
shell: bash
- name: Package for amd64
run: |
go run mage.go machbase-neo && \
mv tmp/machbase-neo /home/ubuntu/docker-build/amd64/
- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build and Push (Latest)
uses: docker/build-push-action@v4
if: (!contains(github.ref, 'snapshot') && !contains(github.ref, 'rc'))
with:
context: /home/ubuntu/docker-build
file: ./scripts/Dockerfile
platforms: linux/arm64,linux/amd64
push: true
tags: |
machbase/machbase-neo:${{ steps.get_version.outputs.ver }}
machbase/machbase-neo:latest
- name: Docker Build and Push (Snapshot)
uses: docker/build-push-action@v4
if: (contains(github.ref, 'snapshot') || contains(github.ref, 'rc'))
with:
context: /home/ubuntu/docker-build
file: ./scripts/Dockerfile
platforms: linux/arm64,linux/amd64
push: true
tags: |
machbase/machbase-neo:${{ steps.get_version.outputs.ver }}