-
-
Notifications
You must be signed in to change notification settings - Fork 90
207 lines (183 loc) · 6.56 KB
/
ghcr.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
name: Multi-Arch CI + CD
on:
release:
types: [published]
workflow_dispatch:
env:
REGISTRY: ghcr.io
CROSS_SYSROOT: /mnt/alpine
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]
outputs:
HEPLIFY_VERSION: ${{ steps.version.outputs.HEPLIFY_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set up Alpine Linux for x86_64 (build arch)
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.arch }}
id: alpine-root
packages: >
build-base
pkgconf
linux-headers
musl-dev
gcc
libpcap-dev
ca-certificates
git
go
sudo
- name: Install LuaJit 2.1 ${{ matrix.arch }}
run: |
git clone https://luajit.org/git/luajit-2.0.git \
&& cd luajit-2.0 \
&& git checkout v2.1 \
&& make CCOPT="-static -fPIC" BUILDMODE="static" && sudo make install
shell: alpine.sh {0}
- name: Build ${{ matrix.arch }}
run: CGO_ENABLED=1 GOOS=linux go build -a --ldflags '-linkmode external -extldflags "-static -s -w"' -o heplify-server${{ matrix.arch == 'aarch64' && '-arm64' || '' }} ./cmd/heplify-server
shell: alpine.sh {0}
- name: Retrieve version
run: |
echo "HEPLIFY_VERSION=$(cat config/config.go | sed -n 's/^.*heplify-server \([0-9.]*\).*/\1/p')" >> $GITHUB_OUTPUT
id: version
- name: Package for ${{ matrix.arch }}
if: ${{ matrix.arch != 'aarch64' }}
run: ./scripts/build_package.sh
env:
ARCH: ${{ matrix.arch == 'aarch64' && 'arm64' || 'amd64' }}
RELEASE: ${{ steps.version.outputs.HEPLIFY_VERSION }}
- name: Upload Artifacts for ${{ matrix.arch }}
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'heplify-server*'
- name: Check PACKAGECLOUD secret presence
id: checkpackagecloud
shell: bash
run: |
if [ "$SECRET" == "" ] || [ "$USERNAME" == "" ]; then
echo "secretspresent=false" >> $GITHUB_OUTPUT
else
echo "secretspresent=true" >> $GITHUB_OUTPUT
fi
env:
SECRET: ${{ secrets.PACKAGECLOUD_TOKEN }}
USERNAME: ${{ secrets.PACKAGECLOUD_USERNAME }}
- name: upload deb packagecloud
if: ${{ matrix.arch != 'aarch64' && steps.checkpackagecloud.outputs.secretspresent == 'true' }}
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: heplify-server-*-amd64.deb
PACKAGECLOUD-REPO: sipcapture
PACKAGECLOUD-DISTRIB: any/any
PACKAGECLOUD-USERNAME: ${{ secrets.PACKAGECLOUD_USERNAME }}
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
continue-on-error: true
- name: upload rpm packagecloud
if: ${{ matrix.arch != 'aarch64' && steps.checkpackagecloud.outputs.secretspresent == 'true' }}
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: heplify-server-*-amd64.rpm
PACKAGECLOUD-REPO: sipcapture
PACKAGECLOUD-DISTRIB: rpm_any/rpm_any
PACKAGECLOUD-USERNAME: ${{ secrets.PACKAGECLOUD_USERNAME }}
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
continue-on-error: true
docker-ghcr-push:
if: ${{ github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Version Check
run: |
echo "${{ needs.build.outputs.HEPLIFY_VERSION }}"
- name: Set up Docker QEMU
uses: docker/[email protected]
with:
platforms: amd64, arm64
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to GHCR
uses: docker/[email protected]
with:
platforms: linux/amd64, linux/arm64
file: ./docker/Dockerfile
push: true
tags: |
ghcr.io/sipcapture/heplify-server:latest
ghcr.io/sipcapture/heplify-server:${{ needs.build.outputs.HEPLIFY_VERSION || github.event.release.tag_name }}
labels: |
dev.heplify-server.image.title=heplify-server
dev.heplify-server.image.version=${{needs.build.outputs.HEPLIFY_VERSION || github.event.release.tag_name }}
docker-hub-push:
if: ${{ github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
contents: read
steps:
- name: Check Docker secret presence
id: checkdocker
shell: bash
run: |
if [ "$SECRET" == "" ] || [ "$USERNAME" == "" ]; then
echo "secretspresent=false" >> $GITHUB_OUTPUT
else
echo "secretspresent=true" >> $GITHUB_OUTPUT
fi
env:
SECRET: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
- uses: actions/checkout@v3
- name: Version Check
run: |
echo "${{ needs.build.outputs.HEPLIFY_VERSION }}"
- name: Set up Docker QEMU
uses: docker/[email protected]
with:
platforms: amd64, arm64
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
id: logintodocker
if: ${{ steps.checkdocker.outputs.secretspresent == 'true' }}
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Exit if credentials doesn't exist
if: ${{ steps.checkdocker.outputs.secretspresent == 'false' }}
run: |
echo "can not proceed"
exit 1
- name: Build and push to DockerHub
uses: docker/[email protected]
with:
platforms: linux/amd64, linux/arm64
file: ./docker/Dockerfile
push: true
tags: |
qxip/heplify-server:latest
qxip/heplify-server:${{ needs.build.outputs.HEPLIFY_VERSION || github.event.release.tag_name }}
labels: |
dev.heplify-server.image.title=heplify-server
dev.heplify-server.image.version=${{needs.build.outputs.HEPLIFY_VERSION || github.event.release.tag_name }}