-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (93 loc) · 3.7 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
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
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:
srchash: ${{ steps.gstsrc.outputs.hash }}
steps:
- name: Checkout gst-plugins-rs
run: git clone --depth 1 -b ${{ env.GST_GIT_BRANCH }} ${{ env.GST_GIT_REPO }}
- name: Hash cargo lockfile
id: gstsrc
run: echo "hash=${{ hashFiles('**/Cargo.lock') }}" >> $GITHUB_OUTPUT
main:
strategy:
fail-fast: false
matrix:
include:
- rust_target: arm-unknown-linux-gnueabihf
linker_target: arm-linux-gnueabihf
rust_flags: -C linker=$RPI_LINKER -L$RPI_SYSROOT/lib -L$RPI_SYSROOT/usr/lib
runs-on: ubuntu-20.04
container: ghcr.io/mopidy/gst-plugin-spotify-build:latest
needs: bust-cache
env:
GST_PLUGIN: gst-plugin-spotify
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.rust_target }}
- name: Checkout gst-plugins-rs
run: |
git clone --depth 1 -b ${{ env.GST_GIT_BRANCH }} ${{ env.GST_GIT_REPO }}
cp gst-plugins-rs/audio/spotify/Cargo.toml Cargo.toml.orig
- name: Cache cargo stuff
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-${{ matrix.rust_target }}-cargo-${{ needs.bust-cache.outputs.srchash }}
- name: Install cargo deb
run: cargo install cargo-deb
- name: Configure cross environment
if: matrix.linker_target != ''
run: |
PKG_CONFIG_ALLOW_CROSS=1
PKG_CONFIG_PATH="/usr/lib/${{ matrix.linker_target }}/pkgconfig"
echo "PKG_CONFIG_ALLOW_CROSS=$PKG_CONFIG_ALLOW_CROSS" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
- name: Configure cross environment (RPi)
if: matrix.linker_target == 'arm-linux-gnueabihf'
run: |
RPI_DIR="/rpi-tools/arm-bcm2708/arm-linux-gnueabihf"
RPI_SYSROOT="$RPI_DIR/arm-linux-gnueabihf/sysroot"
RPI_LINKER="$RPI_DIR/bin/arm-linux-gnueabihf-gcc"
RUSTFLAGS="-C linker=$RPI_LINKER -L$RPI_SYSROOT/lib -L$RPI_SYSROOT/usr/lib"
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV
echo "RUSTFLAGS is ${{ matrix.rust_flags }}"
- name: Build gst-plugins-rs
run: |
env
cd gst-plugins-rs
cargo build --target=${{ matrix.rust_target }} --package ${{ env.GST_PLUGIN }} --release --config 'profile.release.strip = true'
- name: Fixup target-specific install path
run: |
GST_PLUGINS_DIR=$(pkg-config --variable=pluginsdir gstreamer-1.0)
cat Cargo.toml.orig Cargo.toml.deb | sed "s@%GST_PLUGINS_DIR%@$GST_PLUGINS_DIR@" > gst-plugins-rs/audio/spotify/Cargo.toml
- name: Build deb
run: |
cd gst-plugins-rs
cargo deb --target=${{ matrix.rust_target }} --package ${{ env.GST_PLUGIN }} --no-build
DEB_PATH=$(readlink -m $(find target/${{ matrix.rust_target }}/debian/${{ env.GST_PLUGIN }}_*.deb))
DEB_NAME=$(basename $DEB_PATH .deb)
echo "DEB_PATH=$DEB_PATH" >> $GITHUB_ENV
echo "DEB_NAME=$DEB_NAME" >> $GITHUB_ENV
- name: Check deb
run: dpkg-deb --field ${{ env.DEB_PATH }} Package Architecture Version Installed-Size
- name: Upload deb
uses: actions/upload-artifact@v3
with:
name: ${{ env.DEB_NAME }}
path: ${{ env.DEB_PATH }}