-
-
Notifications
You must be signed in to change notification settings - Fork 12
215 lines (194 loc) · 7.94 KB
/
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
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: Build Release
on:
push:
branches: [ main ]
permissions:
contents: write
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install build dependencies
id: install_packages
run: >
sudo apt-get update && sudo apt-get -y install
desktop-file-utils gcc
libgl1-mesa-dev xserver-xorg-dev
libxcursor-dev libxrandr-dev
libxinerama-dev libxi-dev
libgl1-mesa-dev libxxf86vm-dev
> ${RUNNER_TEMP}/dpkg.log
env:
DEBIAN_FRONTEND: noninteractive
# - name: Install/Cache dependencies
# id: cache_pkg_deps
# uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: desktop-file-utils gcc libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev dbus-x11
- name: Set up Go
id: setup_go
uses: actions/setup-go@v5
with:
go-version: '^1.22'
- name: Install Go dependencies
id: install_go_deps
run: |
go install golang.org/x/tools/cmd/stringer@latest
go install golang.org/x/text/cmd/gotext@latest
go install github.com/matryer/moq@latest
- name: Run go generate
id: go_generate
run: go generate -v ./...
- name: Run go build
id: go_build
run: go build -v
- name: Run go test
id: go_test
run: go test -v -coverprofile=coverage.txt ./...
continue-on-error: true
- name: Upload Coverage
id: upload_coverage
uses: codecov/codecov-action@v4
continue-on-error: true
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./coverage.txt
fail_ci_if_error: false
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64,arm,arm64]
steps:
- name: Run release please
uses: google-github-actions/release-please-action@v4
id: release_please
with:
release-type: go
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: set app version
run: |
echo "APPVERSION=$(git describe --tags --abbrev=0)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: set app version for release
if: ${{ steps.release_please.outputs.release_created }}
run: echo "APPVERSION=${{ steps.release_please.outputs.tag_name }}" >> $GITHUB_ENV
- name: show app version
run: |
echo "::notice title=App Version::${APPVERSION}"
- name: Add ${{ matrix.arch }} package repos
if: ${{ matrix.arch != 'amd64' }}
id: enable_multiarch
run: |
source .env.${{ matrix.arch }}
sudo dpkg --add-architecture ${PKG_ARCH}
sudo sed -i 's|^deb\s|deb [arch=amd64] |g' /etc/apt/sources.list
sudo tee -a /etc/apt/sources.list << EOF
deb [arch=${PKG_ARCH}] http://ports.ubuntu.com/ubuntu-ports/ jammy main
#deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy main
deb [arch=${PKG_ARCH}] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main
#deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main
deb [arch=${PKG_ARCH}] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main
#deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main
EOF
- name: Install build dependencies
id: install_packages
run: >
source .env.${{ matrix.arch }} &&
sudo apt-get update > ${RUNNER_TEMP}/apt-update.log &&
sudo apt-get -y install desktop-file-utils gcc ${CC_PKG}
libgl1-mesa-dev:${PKG_ARCH} xserver-xorg-dev:${PKG_ARCH}
libxcursor-dev:${PKG_ARCH} libxrandr-dev:${PKG_ARCH}
libxinerama-dev:${PKG_ARCH} libxi-dev:${PKG_ARCH}
libgl1-mesa-dev:${PKG_ARCH} libxxf86vm-dev:${PKG_ARCH}
> ${RUNNER_TEMP}/apt-install.log
env:
DEBIAN_FRONTEND: noninteractive
# - name: Install/Cache build dependencies
# # if: ${{ steps.release_please.outputs.release_created }}
# id: cache_pkg_deps
# uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: >
# desktop-file-utils gcc gcc-arm-none-eabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
# libgl-dev:amd64 libx11-dev:amd64 libxrandr-dev:amd64 libxxf86vm-dev:amd64 libxi-dev:amd64 libxcursor-dev:amd64 libxinerama-dev:amd64 libxkbcommon-dev:amd64
# libgl-dev:armhf libx11-dev:armhf libxrandr-dev:armhf libxxf86vm-dev:armhf libxi-dev:armhf libxcursor-dev:armhf libxinerama-dev:armhf libxkbcommon-dev:armhf
# libgl-dev:arm64 libx11-dev:arm64 libxrandr-dev:arm64 libxxf86vm-dev:arm64 libxi-dev:arm64 libxcursor-dev:arm64 libxinerama-dev:arm64 libxkbcommon-dev:arm64
- name: Setup Go
id: setup_go
uses: actions/setup-go@v5
with:
go-version: '^1.22'
- name: Install Go dependencies
id: install_go_deps
run: |
go install golang.org/x/tools/cmd/stringer@latest
go install github.com/fyne-io/fyne-cross@latest
go install golang.org/x/text/cmd/gotext@latest
go install github.com/matryer/moq@latest
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
- name: Build ${{ matrix.arch }} binary
# if: ${{ steps.release_please.outputs.release_created }}
id: build_binary
run: |
source .env.${{ matrix.arch }}
echo ARCH: ${MATRIX_ARCH} CC: ${CC} GOARCH: ${GOARCH} PKG_CONFIG_PATH: ${PKG_CONFIG_PATH}
go generate ./...
go build -o dist/go-hass-agent-${{ matrix.arch }}
env:
CGO_ENABLED: 1
MATRIX_ARCH: ${{ matrix.arch }}
# - name: Build with fyne-cross
# id: build_fyne_cross
# run: >
# fyne-cross linux -arch=${{ matrix.arch }}
# -icon internal/agent/ui/assets/logo-pretty.png
# -release
- name: Create package
id: nfpm_package
run: |
source .env.${{ matrix.arch }}
nfpm package --config .nfpm.yaml --packager rpm --target dist
nfpm package --config .nfpm.yaml --packager deb --target dist
nfpm package --config .nfpm.yaml --packager archlinux --target dist
- name: Install cosign
# if: ${{ steps.release_please.outputs.release_created }}
id: cosign_install
uses: sigstore/[email protected]
with:
cosign-release: 'v2.2.2'
- name: Sign artifacts with cosign
id: cosign_sign
run: |
shopt -s nullglob
echo Need to sign dist/*.{rpm,deb,zst} fyne-cross/dist/linux-${{ matrix.arch }}/*.tar.xz
for artifact in dist/*.{rpm,deb,zst} fyne-cross/dist/linux-${{ matrix.arch }}/*.tar.xz; do
echo Signing ${artifact}
cosign --verbose=true sign-blob --yes --key cosign.key --output-signature=${artifact}.sig ${artifact}
done
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
- name: Upload build artifacts
id: upload_artifacts
if: ${{ ! steps.release_please.outputs.release_created }}
uses: actions/upload-artifact@v4
with:
name: ${APPVERSION}
path: dist/*.{rpm,deb,zst,sig} fyne-cross/dist/linux-${{ matrix.arch }}/*.{tar.xz,sig}
- name: Upload release artifacts
id: upload_release
if: ${{ steps.release_please.outputs.release_created }}
run: >
gh release upload ${{ steps.release_please.outputs.tag_name }}
dist/*.{rpm,deb,zst,sig} fyne-cross/dist/linux-${{ matrix.arch }}/*.{tar.xz,sig}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}