-
Notifications
You must be signed in to change notification settings - Fork 37
260 lines (225 loc) · 9.37 KB
/
pipeless-build-and-release.yaml
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
251
252
253
254
255
256
257
258
259
260
name: Rust Build & Release
on:
push:
branches:
- main
paths:
- 'pipeless/Cargo.toml'
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
arch: [x64]
# Provide an output that can be used by other jobs
outputs:
new_version: ${{ steps.check_version.outputs.new_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get before and after versions
id: check_version
run: |
before_version=$(git describe --abbrev=0 --tags | grep -o '\([0-9]\+\.\)\+[0-9]\+')
after_version=$(cargo metadata --manifest-path pipeless/Cargo.toml --format-version 1 | jq -r '.packages[] | select(.name == "pipeless-ai").version')
if [ "$before_version" != "$after_version" ]; then
echo "Cargo.toml version has been updated"
echo "new_version=${after_version}" >> $GITHUB_OUTPUT
else
echo "Cargo.toml version was not updated"
exit 1
fi
- name: Set OS and Arch
id: set-os-arch
run: |
ARCH=$(uname -m)
case $ARCH in
armv5*) ARCH="armv5";;
armv6*) ARCH="armv6";;
armv7*) ARCH="arm";;
aarch64) ARCH="arm64";;
x86) ARCH="386";;
x86_64) ARCH="amd64";;
i686) ARCH="386";;
i386) ARCH="386";;
esac
echo "ARCH=$ARCH" >> $GITHUB_ENV
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]')
case "$OS" in
# Minimalist GNU for Windows
mingw*|cygwin*) OS='windows';;
esac
echo "OS=$OS" >> $GITHUB_ENV
- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: beta
default: true
override: true
- name: Set up Homebrew
if: matrix.os == 'macos-latest'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Install dependencies with Homebrew
if: matrix.os == 'macos-latest'
run: |
# Avoid to upgrade dependents like azure-cli, because we don't need them
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
# Avoid error when installing Python as gstreamer dependency
brew unlink [email protected]
rm '/usr/local/bin/2to3-3.12'
brew link --overwrite [email protected]
brew install gstreamer
brew install coreutils # For sha256sum
- name: Install system dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update \
&& sudo apt-get install -y \
libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \
gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 \
gstreamer1.0-qt5 gstreamer1.0-pulseaudio gstreamer1.0-rtsp
- name: Build
run: |
cargo build --all --release --manifest-path pipeless/Cargo.toml
mv pipeless/target/release/pipeless-ai pipeless/target/release/pipeless
strip pipeless/target/release/pipeless
mkdir pipeless-${{ steps.check_version.outputs.new_version }}
cp pipeless/target/release/{pipeless,libonnxruntime*} pipeless-${{ steps.check_version.outputs.new_version }}/
tar -czf pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz pipeless-${{ steps.check_version.outputs.new_version }}
- name: Create SHA256 file
run: sha256sum pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz > pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.check_version.outputs.new_version }}
path: |
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256
# Build for Jetson in our self hosted runner. Note it must be setup and have dependencies installed
build-jetson:
runs-on: self-hosted
# Provide an output that can be used by other jobs
outputs:
new_version: ${{ steps.check_version.outputs.new_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get before and after versions
id: check_version
run: |
before_version=$(git describe --abbrev=0 --tags | grep -o '\([0-9]\+\.\)\+[0-9]\+')
after_version=$(cargo metadata --manifest-path pipeless/Cargo.toml --format-version 1 | jq -r '.packages[] | select(.name == "pipeless-ai").version')
if [ "$before_version" != "$after_version" ]; then
echo "Cargo.toml version has been updated"
echo "new_version=${after_version}" >> $GITHUB_OUTPUT
else
echo "Cargo.toml version was not updated"
exit 1
fi
- name: Set OS and Arch
id: set-os-arch
run: |
ARCH=$(uname -m)
case $ARCH in
armv5*) ARCH="armv5";;
armv6*) ARCH="armv6";;
armv7*) ARCH="arm";;
aarch64) ARCH="arm64";;
x86) ARCH="386";;
x86_64) ARCH="amd64";;
i686) ARCH="386";;
i386) ARCH="386";;
esac
echo "ARCH=$ARCH" >> $GITHUB_ENV
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]')
case "$OS" in
# Minimalist GNU for Windows
mingw*|cygwin*) OS='windows';;
esac
echo "OS=$OS" >> $GITHUB_ENV
- name: Build
run: |
# We have already placed the onnx runtime library at ~/.pipeless so it can be linked and copied
ORT_STRATEGY=system ORT_LIB_LOCATION=/home/miguelaeh/.pipeless/ cargo build --all --release --manifest-path pipeless/Cargo.toml &&
mv pipeless/target/release/pipeless-ai pipeless/target/release/pipeless &&
strip pipeless/target/release/pipeless &&
mkdir pipeless-${{ steps.check_version.outputs.new_version }}
cp pipeless/target/release/{pipeless,libonnxruntime*} pipeless-${{ steps.check_version.outputs.new_version }}
# HACK: Copy the file that we renamed adding the version after building onnx runtime
cp /home/miguelaeh/.pipeless/libonnxruntime* pipeless-${{ steps.check_version.outputs.new_version }}/
tar -czf pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz pipeless-${{ steps.check_version.outputs.new_version }}
- name: Create SHA256 file
run: sha256sum pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz > pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.check_version.outputs.new_version }}
path: |
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256
# Create GitHub releases
release:
needs:
- build
- build-jetson
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.new_version }}
path: artifact
- name: Create and push tag
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Build Action"
git tag -a v${{ needs.build.outputs.new_version }} -m "Version ${{ needs.build.outputs.new_version }}"
git push origin v${{ needs.build.outputs.new_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
tag_name: v${{ needs.build.outputs.new_version }}
files: |
artifact/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish to crates.io
publish:
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# The publish needs to build it again
- name: Install system dependencies
run: |
sudo apt-get update \
&& sudo apt-get install -y \
libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \
gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 \
gstreamer1.0-qt5 gstreamer1.0-pulseaudio gstreamer1.0-rtsp
- name: Crates.io
run: cargo publish --manifest-path pipeless/Cargo.toml --token ${CRATES_IO_TOKEN}
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}