-
Notifications
You must be signed in to change notification settings - Fork 226
234 lines (210 loc) · 7.64 KB
/
release.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: Publish Release
run-name: Publish release ${{ inputs.tag }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
tag:
type: string
required: true
jobs:
build:
strategy:
matrix:
goos: [ linux ]
goarch: [ arm64, 386, riscv64, loong64, mips64, mips64le, mipsle, mips, ppc64, ppc64le, s390x ]
include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
# BEGIN Linux AMD64 v1 v2 v3
- goos: linux
goarch: amd64
goamd64: v1
- goos: linux
goarch: amd64
goamd64: v2
- goos: linux
goarch: amd64
goamd64: v3
# END Linux AMD64 v1 v2 v3
fail-fast: false
runs-on: ubuntu-22.04
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
GOAMD64: ${{ matrix.goamd64 }}
CGO_ENABLED: 0
steps:
- name: Checkout codebase
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.tag }}
- name: Get the version
id: get_version
env:
REF: ${{ inputs.tag }}
run: |
version=${REF}
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
- name: Show workflow information
id: get_filename
run: |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOAMD64\"].friendlyName" -r < install/friendly-filenames.json)
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
cache-dependency-path: |
go.mod
go.sum
go-version: '^1.22'
- name: Install Dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y clang-15 llvm-15
- name: Get project dependencies
run: |
git submodule update --init --recursive
GOMODCACHE="${PWD}"/go-mod go mod download -modcacherw
find ./go-mod/ -maxdepth 1 ! -name "cache" ! -name "go-mod" -exec rm -rf {} \;
sed -i 's/#export GOMODCACHE=$(PWD)\/go-mod/export GOMODCACHE=$(PWD)\/go-mod/' Makefile
- name: Create directory for placing archives & packages temporarily
run: mkdir -p ./bundled/
- name: Create full source archive
if: matrix.goarch == 'arm64'
run: |
zip -9vr ./bundled/dae-full-src.zip . -x .git/\* bundled/\*
tar -I 'xz -9' -cvf ./bundled/dae-full-src.tar.xz --exclude .git --exclude bundled .
- name: Build dae
run: |
export CGO_ENABLED=0
export GOFLAGS="-trimpath -modcacherw"
export OUTPUT=build/usr/bin/dae
export VERSION=${{ env.VERSION }}
export CLANG=clang-15
export STRIP=llvm-strip-15
make
install -Dm644 ./install/dae.service -t ./build/usr/lib/systemd/system/
install -Dm640 ./install/empty.dae ./build/etc/dae/config.dae
install -Dm644 ./example.dae -t ./build/etc/dae/
install -d ./build/usr/share/dae/
curl -L -o ./build/usr/share/dae/geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
curl -L -o ./build/usr/share/dae/geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat
- name: Smoking test
if: matrix.goarch == 'amd64' && matrix.goamd64 == 'v1'
run: ./build/usr/bin/dae --version
- name: Create binary archive
run: tar -cJvf ./bundled/dae-$ASSET_NAME.tar.xz -C build .
- name: Build Linux packages
if: ${{ env.GOARM == '7' || env.GOARM == '' }}
run: |
sudo apt install -y libarchive-tools
sudo gem install fpm
case $GOARCH in
'amd64' | 'i386' | 'arm64' | 'arm' | 'riscv64' | 'loong64' | 'ppc64' | 'ppc64le') archlinux_pacman='pacman' ;;
*) echo "Skip unsupported architecture for Arch Linux" ;;
esac
for pkg_mgr in deb rpm $archlinux_pacman; do
case $GOARCH in
'amd64')
if [ $pkg_mgr == 'deb' ]; then
pkg_arch='amd64'
else
pkg_arch='x86_64'
fi ;;
'386')
case $pkg_mgr in
'deb') pkg_arch='i386' ;;
'rpm') pkg_arch='x86' ;;
'pacman') pkg_arch'i486' ;;
esac ;;
'arm64')
if [ $pkg_mgr == 'deb' ]; then
pkg_arch='arm64'
else
pkg_arch='aarch64'
fi ;;
'arm')
case $pkg_mgr in
'deb') pkg_arch='armhf' ;;
'rpm') pkg_arch='armhfp' ;;
'pacman') pkg_arch='armv7h' ;;
esac ;;
'loong64')
if [ $pkg_mgr != 'rpm' ]; then
pkg_arch='loong64'
else
pkg_arch='loongarch64'
fi ;;
'mips64le') pkg_arch='mips64el' ;;
'mipsle') pkg_arch='mipsel' ;;
'ppc64le')
if [ $pkg_mgr == 'deb' ]; then
pkg_arch='ppc64el'
else
pkg_arch='ppc64le'
fi ;;
*) pkg_arch=$GOARCH ;;
esac
fpm -s dir -t $pkg_mgr -a $pkg_arch -v ${VERSION/v/} -n dae \
--url "https://github.com/daeuniverse/dae" \
--description "eBPF-based Linux high-performance transparent proxy solution" \
--maintainer "daeuniverse <[email protected]>" \
--license 'AGPL-3.0' \
--package ./bundled/dae-$ASSET_NAME.$pkg_mgr \
--after-install ./install/package_after_install.sh \
--after-remove ./install/package_after_remove.sh \
--deb-compression xz \
--deb-compression-level 9 \
--rpm-compression xz \
--verbose \
-C build .
done
if [ $archlinux_pacman == 'pacman' ]; then
mv ./bundled/dae-$ASSET_NAME.pacman ./bundled/dae-$ASSET_NAME.pkg.tar.zst
fi
- name: Create signature
run: |
cd bundled
for FILE in *; do
echo "$(md5sum $FILE)"" md5" >> $FILE.dgst
echo "$(shasum -a 1 $FILE)"" sha1" >> $FILE.dgst
echo "$(shasum -a 256 $FILE)"" sha256" >> $FILE.dgst
echo "$(shasum -a 512 $FILE)"" sha512" >> $FILE.dgst
done
- name: Upload files to Artifacts
uses: nanoufo/action-upload-artifacts-and-release-assets@v2
with:
if-no-files-found: ignore
path: ./bundled/*
upload-release:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/[email protected]
with:
path: release/
- name: Prepare files for upload
run: |
echo "Show files are going to upload..."
cd release
ls -lh */*
- name: Upload full source and artifacts to GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
files: release/*/*