-
Notifications
You must be signed in to change notification settings - Fork 24
251 lines (217 loc) · 9.67 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: Release
on:
push:
branches:
- test
release:
types:
- 'published'
jobs:
build:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
# https://doc.rust-lang.org/nightly/rustc/platform-support.html
- { target: aarch64-apple-darwin , os: macos-14 }
- { target: aarch64-pc-windows-msvc , os: windows-2022 }
- { target: aarch64-linux-android , os: ubuntu-24.04, use-cross: true }
- { target: aarch64-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true }
- { target: aarch64-unknown-linux-musl , os: ubuntu-24.04, use-cross: true, nfpm: arm64 }
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-24.04, use-cross: true }
- { target: arm-unknown-linux-musleabihf, os: ubuntu-24.04, use-cross: true }
- { target: i686-pc-windows-msvc , os: windows-2022 }
- { target: i686-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true }
- { target: i686-unknown-linux-musl , os: ubuntu-24.04, use-cross: true }
- { target: x86_64-apple-darwin , os: macos-14 }
- { target: x86_64-pc-windows-gnu , os: windows-2022 }
- { target: x86_64-pc-windows-msvc , os: windows-2022 }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true }
- { target: x86_64-unknown-linux-musl , os: ubuntu-24.04, use-cross: true, nfpm: amd64 }
env:
BUILD_CMD: cargo
EXE_SUFFIX: ""
PKG_LIVE777_NAME: ""
PKG_LIVEMAN_NAME: ""
PKG_WHEPFROM_NAME: ""
PKG_WHIPINTO_NAME: ""
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: latest
- name: Install npm dependencies
run: npm ci
- name: Build WebUI
run: npm run build
- name: Get the release version from the tag
shell: bash
run: |
VERSION=${GITHUB_REF_NAME}
if expr "${VERSION}" : '[^0-9]*$' > /dev/null; then
VERSION=`git describe --tags`
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "version is: ${VERSION}"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- name: Install cross
if: matrix.job.use-cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Overwrite build command env variable
if: matrix.job.use-cross
shell: bash
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
- name: Overwrite suffix env variable
if: runner.os == 'Windows'
shell: bash
run: echo "EXE_SUFFIX=.exe" >> $GITHUB_ENV
- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
cross --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
echo "BUILD_CMD: ${BUILD_CMD}"
- name: Build
shell: bash
run: |
$BUILD_CMD $BUILD_NDK build --locked --all-targets --all-features --release --target=${{ matrix.job.target }}
- name: Archive
shell: bash
run: |
PKG_BUILDNAME=${{ env.VERSION }}-${{ matrix.job.target }}${{ env.EXE_SUFFIX }}
echo "BUILD_PATH=target/${{ matrix.job.target }}/release" >> $GITHUB_ENV
echo "PKG_LIVE777_NAME=live777-${PKG_BUILDNAME}" >> $GITHUB_ENV
echo "PKG_LIVEMAN_NAME=liveman-${PKG_BUILDNAME}" >> $GITHUB_ENV
echo "PKG_WHEPFROM_NAME=whepfrom-${PKG_BUILDNAME}" >> $GITHUB_ENV
echo "PKG_WHIPINTO_NAME=whipinto-${PKG_BUILDNAME}" >> $GITHUB_ENV
echo "PKG_NET4MQTT_NAME=net4mqtt-${PKG_BUILDNAME}" >> $GITHUB_ENV
- name: Create Live777 tarball
shell: bash
run: |
TAR_SUFFIX=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) TAR_SUFFIX=".zip" ;; esac;
TAR_BASENAME=live777-${{ env.VERSION }}-${{ matrix.job.target }}
TAR_NAME=${TAR_BASENAME}${TAR_SUFFIX}
ARCHIVE_DIR="${TAR_BASENAME}/"
mkdir -p "${ARCHIVE_DIR}"
cp "${{ env.BUILD_PATH }}/live777${{ env.EXE_SUFFIX }}" "$ARCHIVE_DIR"
cp "README.md" "LICENSE" "conf/live777.toml" "conf/live777.service" "$ARCHIVE_DIR"
# base compressed package
case ${{ matrix.job.target }} in
*-pc-windows-*) 7z -y a "${TAR_NAME}" "${TAR_BASENAME}"/* | tail -2 ;;
*) tar czf "${TAR_NAME}" "${TAR_BASENAME}"/* ;;
esac;
# Let subsequent steps know where to find the compressed package
echo "TAR_LIVE777_NAME=${TAR_NAME}" >> $GITHUB_ENV
- name: Create LiveMan tarball
shell: bash
run: |
TAR_SUFFIX=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) TAR_SUFFIX=".zip" ;; esac;
TAR_BASENAME=liveman-${{ env.VERSION }}-${{ matrix.job.target }}
TAR_NAME=${TAR_BASENAME}${TAR_SUFFIX}
ARCHIVE_DIR="${TAR_BASENAME}/"
mkdir -p "${ARCHIVE_DIR}"
cp "${{ env.BUILD_PATH }}/liveman${{ env.EXE_SUFFIX }}" "$ARCHIVE_DIR"
cp "README.md" "LICENSE" "conf/liveman.toml" "conf/liveman.service" "$ARCHIVE_DIR"
# base compressed package
case ${{ matrix.job.target }} in
*-pc-windows-*) 7z -y a "${TAR_NAME}" "${TAR_BASENAME}"/* | tail -2 ;;
*) tar czf "${TAR_NAME}" "${TAR_BASENAME}"/* ;;
esac;
# Let subsequent steps know where to find the compressed package
echo "TAR_LIVEMAN_NAME=${TAR_NAME}" >> $GITHUB_ENV
- name: Rename binary
shell: bash
run: |
cp ${{ env.BUILD_PATH }}/whepfrom${{ env.EXE_SUFFIX }} ${{ env.PKG_WHEPFROM_NAME }}
cp ${{ env.BUILD_PATH }}/whipinto${{ env.EXE_SUFFIX }} ${{ env.PKG_WHIPINTO_NAME }}
cp ${{ env.BUILD_PATH }}/net4mqtt${{ env.EXE_SUFFIX }} ${{ env.PKG_NET4MQTT_NAME }}
- name: Artifact Upload Binary
uses: actions/upload-artifact@v4
with:
name: ${{ env.VERSION }}_${{ matrix.job.target }}_bin
path: |
${{ env.TAR_LIVE777_NAME }}
${{ env.TAR_LIVEMAN_NAME }}
${{ env.PKG_WHEPFROM_NAME }}
${{ env.PKG_WHIPINTO_NAME }}
${{ env.PKG_NET4MQTT_NAME }}
- name: Install nFPM
if: ${{ matrix.job.nfpm }}
run: |
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt update
sudo apt install nfpm
- name: Set nFPM environment
if: ${{ matrix.job.nfpm }}
run: |
echo "NFPM_ARCH=${{ matrix.job.nfpm }}" >> $GITHUB_ENV
echo "NFPM_TARGET=${{ matrix.job.target }}" >> $GITHUB_ENV
echo "NFPM_VERSION=`git describe --tags | cut -d - -f 1`" >> $GITHUB_ENV
echo "NFPM_RELEASE=`git describe --tags | cut -d - -f 2`" >> $GITHUB_ENV
echo "NFPM_PRERELEASE=`git describe --tags | cut -d - -f 3`" >> $GITHUB_ENV
- name: Build nFPM config
if: ${{ matrix.job.nfpm }}
run: |
envsubst < nfpm/live777.yaml > live777.yaml
envsubst < nfpm/liveman.yaml > liveman.yaml
envsubst < nfpm/net4mqtt.yaml > net4mqtt.yaml
envsubst < nfpm/whipinto.yaml > whipinto.yaml
envsubst < nfpm/whepfrom.yaml > whepfrom.yaml
- name: Use nFPM
if: ${{ matrix.job.nfpm }}
run: |
nfpm pkg --packager deb --config live777.yaml
nfpm pkg --packager deb --config liveman.yaml
nfpm pkg --packager deb --config net4mqtt.yaml
nfpm pkg --packager deb --config whipinto.yaml
nfpm pkg --packager deb --config whepfrom.yaml
nfpm pkg --packager rpm --config live777.yaml
nfpm pkg --packager rpm --config liveman.yaml
nfpm pkg --packager rpm --config net4mqtt.yaml
nfpm pkg --packager rpm --config whipinto.yaml
nfpm pkg --packager rpm --config whepfrom.yaml
nfpm pkg --packager archlinux --config live777.yaml
nfpm pkg --packager archlinux --config liveman.yaml
nfpm pkg --packager archlinux --config net4mqtt.yaml
nfpm pkg --packager archlinux --config whipinto.yaml
nfpm pkg --packager archlinux --config whepfrom.yaml
- name: Artifact Upload deb package
uses: actions/upload-artifact@v4
if: ${{ matrix.job.nfpm }}
with:
name: ${{ env.VERSION }}_${{ matrix.job.target }}_deb
path: |
*.deb
- name: Artifact Upload rpm package
uses: actions/upload-artifact@v4
if: ${{ matrix.job.nfpm }}
with:
name: ${{ env.VERSION }}_${{ matrix.job.target }}_rpm
path: |
*.rpm
- name: Artifact Upload archlinux package
uses: actions/upload-artifact@v4
if: ${{ matrix.job.nfpm }}
with:
name: ${{ env.VERSION }}_${{ matrix.job.target }}_archlinux
path: |
*.pkg.tar.zst
- name: Upload release archive
shell: bash
if: github.ref_type == 'tag'
run: gh release upload ${{ env.VERSION }} ${{ env.TAR_LIVE777_NAME }} ${{ env.TAR_LIVEMAN_NAME }} ${{ env.PKG_WHEPFROM_NAME }} ${{ env.PKG_WHIPINTO_NAME }} ${{ env.PKG_NET4MQTT_NAME }} *.deb *.rpm *.pkg.tar.zst
env:
GH_TOKEN: ${{ github.token }}