-
Notifications
You must be signed in to change notification settings - Fork 2
140 lines (119 loc) · 4.4 KB
/
ci.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
name: CI
on: [push, pull_request]
defaults:
run:
shell: bash
env:
GST_GIT_REPO: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
GST_GIT_BRANCH: main
GST_SRC_DIR: gst-plugins-rs/audio/spotify
# $RPI_BIN and $RPI_SYSROOT are defined in the docker images
jobs:
# This job must run on the runner because hashFiles() operates on the runner
# by design, not inside the defined container (actions/runner#837).
bust-cache:
runs-on: ubuntu-latest
outputs:
container_version: ${{ steps.container.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Find latest container version
id: container
run: |
echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
main:
strategy:
fail-fast: false
matrix:
include:
- target: arm-unknown-linux-gnueabihf
linker: arm-linux-gnueabihf
linker_path: $RPI_BIN/
extra_rust_flags: -L$RPI_SYSROOT/lib -L$RPI_SYSROOT/usr/lib
- target: aarch64-unknown-linux-gnu
linker: aarch64-linux-gnu
- target: x86_64-unknown-linux-gnu
linker: x86_64-linux-gnu
runs-on: ubuntu-20.04
container: ghcr.io/mopidy/gst-plugin-spotify-build:latest
needs: bust-cache
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Checkout gst-plugins-rs
run: |
git clone --depth 1 -b ${{ env.GST_GIT_BRANCH }} ${{ env.GST_GIT_REPO }}
- name: Backup original plugin Cargo.toml file
run: |
cp ${GST_SRC_DIR}/Cargo.toml Cargo.toml.orig
- name: Cache cargo stuff
env:
CONTAINER_VERSION: gst-plugin-spotify-build:${{ needs.bust-cache.outputs.container_version }}
uses: actions/cache@v3
with:
path: |
~/.cargo
gst-plugins-rs/target/${{ matrix.target }}/release
key: ${{ env.CONTAINER_VERSION }}-${{ matrix.target }}
restore-keys: |
${{ env.CONTAINER_VERSION }}-
- name: Install cargo deb
run: cargo install cargo-deb
- name: Configure environment
run: |
TARGET=${{ matrix.target }}
LINKER=${{ matrix.linker }}
LINKER_PATH=$(eval "echo ${{ matrix.linker_path }}")
EXTRA_RUSTFLAGS=$(eval "echo ${{ matrix.extra_rust_flags }}")
[ $(gcc -dumpmachine) != "{$LINKER}" ] && PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_PATH=/usr/lib/${LINKER}/pkgconfig
export LINKER_TOOLS=${LINKER_PATH}${LINKER}
export RUSTFLAGS="-C linker=${LINKER_TOOLS}-gcc $EXTRA_RUSTFLAGS"
echo "PKG_CONFIG_ALLOW_CROSS=$PKG_CONFIG_ALLOW_CROSS" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV
echo "LINKER_TOOLS=$LINKER_TOOLS" >> $GITHUB_ENV
echo "TARGET=$TARGET" >> $GITHUB_ENV
- name: Build gst-plugins-rs
run: |
env | sort
pushd ${GST_SRC_DIR}
cargo build --target=${TARGET} --release
- name: Strip binary
run: |
SO_FILE=$(find gst-plugins-rs/target/${TARGET}/release/*.so)
ls -l $SO_FILE
${LINKER_TOOLS}-strip $SO_FILE
ls -l $SO_FILE
- name: Upload lib
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }} lib
path: gst-plugins-rs/target/${{ matrix.target }}/release/*.so
- name: Prepare deb package
run: |
echo "Append package metadata to Cargo.toml"
cat Cargo.toml.orig Cargo.toml.deb > ${GST_SRC_DIR}/Cargo.toml
echo "Fixup target-specific library install path"
TARGET_PLUGINS_DIR=$(pkg-config --variable=pluginsdir gstreamer-1.0)
sed -i "s@%GST_PLUGINS_DIR%@$TARGET_PLUGINS_DIR@" ${GST_SRC_DIR}/Cargo.toml
- name: Create deb package
run: |
pushd ${GST_SRC_DIR}
cargo deb -v --target=${TARGET} --no-build
- name: Check deb
run: |
DEB_FILE=$(find gst-plugins-rs/target/${TARGET}/debian/*.deb)
dpkg-deb --field $DEB_FILE Package Architecture Version Installed-Size
echo "DEB_FILE=$DEB_FILE" >> $GITHUB_ENV
- name: Upload deb
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }} Debian Package
path: ${{ env.DEB_FILE }}