330 lines
12 KiB
YAML
330 lines
12 KiB
YAML
name: CI
|
|
|
|
on: [push, pull_request, workflow_dispatch]
|
|
|
|
jobs:
|
|
native:
|
|
name: native
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-22.04, windows-2022, macos-12]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
name: Checkout onto ${{ runner.os }}
|
|
- if: runner.os == 'Linux'
|
|
name: apt install gstreamer
|
|
run: |
|
|
sudo apt update
|
|
sudo apt install -y aptitude
|
|
sudo aptitude install -y libgstrtspserver-1.0-dev libgstreamer1.0-dev libgtk2.0-dev
|
|
- if: runner.os == 'Windows'
|
|
name: Install Gstreamer
|
|
run: |
|
|
choco install -y --no-progress gstreamer --version=1.20.0
|
|
choco install -y --no-progress gstreamer-devel --version=1.20.0
|
|
$env:GSTREAMER_1_0_ROOT_MSVC_X86_64=$env:SYSTEMDRIVE + '\gstreamer\1.0\msvc_x86_64\'
|
|
echo "GSTREAMER_1_0_ROOT_MSVC_X86_64=$env:GSTREAMER_1_0_ROOT_MSVC_X86_64"
|
|
Add-Content -Path $env:GITHUB_ENV -Value "GSTREAMER_1_0_ROOT_MSVC_X86_64=$env:GSTREAMER_1_0_ROOT_MSVC_X86_64"
|
|
Add-Content -Path $env:GITHUB_PATH -Value "$env:GSTREAMER_1_0_ROOT_MSVC_X86_64\bin"
|
|
Add-Content -Path $env:GITHUB_PATH -Value "%GSTREAMER_1_0_ROOT_MSVC_X86_64%\bin"
|
|
- if: runner.os == 'macOS'
|
|
name: Install Gstreamer on macOS
|
|
run: |
|
|
curl -L 'https://gstreamer.freedesktop.org/data/pkg/osx/1.20.4/gstreamer-1.0-devel-1.20.4-universal.pkg' -o "$(pwd)/gstreamer-devel.pkg"
|
|
sudo installer -verbose -pkg "$(pwd)/gstreamer-devel.pkg" -target /
|
|
PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
|
|
PKG_CONFIG_GSTREAMER_1_0_PREFIX="/Library/Frameworks/GStreamer.framework/Versions/1.0"
|
|
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> "${GITHUB_ENV}"
|
|
echo "PKG_CONFIG_GSTREAMER_1_0_PREFIX=${PKG_CONFIG_GSTREAMER_1_0_PREFIX}" >> "${GITHUB_ENV}"
|
|
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}"
|
|
brew install pkg-config
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
- name: Cache cargo index
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
- name: Cache cargo build
|
|
if: runner.os != 'macOS' # Random missing crates on macOS, unclear why
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
- name: Build
|
|
shell: bash
|
|
run: |
|
|
echo "PATH=${PATH}"
|
|
echo "GSTREAMER_1_0_ROOT_MSVC_X86_64=${GSTREAMER_1_0_ROOT_MSVC_X86_64}"
|
|
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}"
|
|
pkg-config --variable pc_path pkg-config
|
|
cargo build --release --all-features
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: release-${{ matrix.os }}
|
|
path: "target/release/neolink*"
|
|
cross:
|
|
name: cross
|
|
runs-on: ubuntu-latest
|
|
container: "node:current-bullseye-slim"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# Everyone has a slightly different screwball naming scheme;
|
|
# Rust uses the target triple, GCC generally targets a family
|
|
# with a specific prefix, and dpkg's arch does its own thing
|
|
include:
|
|
- arch: amd64
|
|
target: x86_64-unknown-linux-gnu
|
|
gcc: x86-64-linux-gnu
|
|
pkgconfig: x86_64-linux-gnu
|
|
- arch: armhf
|
|
target: armv7-unknown-linux-gnueabihf
|
|
gcc: arm-linux-gnueabihf
|
|
pkgconfig: arm-linux-gnueabihf
|
|
- arch: arm64
|
|
target: aarch64-unknown-linux-gnu
|
|
gcc: aarch64-linux-gnu
|
|
pkgconfig: aarch64-linux-gnu
|
|
- arch: i386
|
|
target: i686-unknown-linux-gnu
|
|
gcc: i686-linux-gnu
|
|
# on i686, the pkgconfig path doesn't match the prefix!
|
|
pkgconfig: i386-linux-gnu
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install basic tools
|
|
run: |
|
|
apt-get update
|
|
apt-get install --assume-yes --no-install-recommends curl ca-certificates
|
|
- name: Install ${{ matrix.arch }} cross compiler and gstreamer
|
|
id: setup
|
|
run: |
|
|
dpkg --add-architecture ${{ matrix.arch }}
|
|
apt-get update
|
|
apt-get install --assume-yes --no-install-recommends \
|
|
build-essential \
|
|
gcc-${{ matrix.gcc }} \
|
|
g++-${{ matrix.gcc }} \
|
|
libgstrtspserver-1.0-dev:${{ matrix.arch }} \
|
|
libgstreamer1.0-dev:${{ matrix.arch }} \
|
|
libgtk2.0-dev:${{ matrix.arch }} \
|
|
libglib2.0-dev:${{ matrix.arch }}
|
|
- name: Install rustup
|
|
run: |
|
|
curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path --quiet -y
|
|
echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
|
|
- name: Install ${{ matrix.arch }} Rust toolchain
|
|
run: |
|
|
rustup target add ${TARGET}
|
|
env:
|
|
TARGET: ${{ matrix.target }}
|
|
- name: Build
|
|
run: |
|
|
cargo build --release --all-features --target=${TARGET}
|
|
env:
|
|
# Retarget pkg-config as described in https://www.freedesktop.org/wiki/Software/pkg-config/CrossCompileProposal/
|
|
PKG_CONFIG_ALLOW_CROSS: 1
|
|
PKG_CONFIG_LIBDIR: /usr/lib/${{ matrix.pkgconfig }}/pkgconfig
|
|
TARGET: ${{ matrix.target }}
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: release-${{ matrix.arch }}-buster
|
|
path: "target/${{ matrix.target }}/release/neolink*"
|
|
|
|
push_to_registry:
|
|
name: Build Docker image
|
|
if: startsWith(github.ref, 'refs/tags/') == false && github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- "cross"
|
|
- "native"
|
|
steps:
|
|
- name: Check token is set
|
|
id: vars
|
|
shell: bash
|
|
run: |
|
|
unset HAS_SECRET
|
|
if [ -n $SECRET ]; then HAS_SECRET='true' ; fi
|
|
echo "HAS_SECRET_TOKEN=${HAS_SECRET}" >> $GITHUB_OUTPUT
|
|
env:
|
|
SECRET: "${{ secrets.DOCKER_TOKEN }}"
|
|
- name: Check out the repo
|
|
uses: actions/checkout@v3
|
|
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
|
- name: Convert username to lower case for docker
|
|
id: string_user
|
|
uses: ASzc/change-string-case-action@v5
|
|
with:
|
|
string: ${{ github.repository_owner }}
|
|
- name: Convert repo to lower case for docker
|
|
id: string_repo
|
|
uses: ASzc/change-string-case-action@v5
|
|
with:
|
|
string: ${{ github.repository }}
|
|
- name: Set up QEMU
|
|
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
|
uses: docker/setup-qemu-action@v2
|
|
- name: Set up Docker Buildx
|
|
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Login to Docker Hub
|
|
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: docker.io
|
|
username: ${{ steps.string_user.outputs.lowercase }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
- name: Get tag name
|
|
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
|
id: tags
|
|
run: |
|
|
branch="$(echo "${GITHUB_REF#refs/heads/}" | sed -E 's|[/]|-|g')"
|
|
tags="${REPO_NAME}:${branch}"
|
|
if [ "${branch}" == "master" ]; then
|
|
tags="${tags},${REPO_NAME}:latest"
|
|
fi
|
|
echo "TAGS=${tags}" >> $GITHUB_OUTPUT
|
|
env:
|
|
REPO_NAME: ${{ steps.string_repo.outputs.lowercase }}
|
|
- name: Install latest rust
|
|
run: |
|
|
rustup toolchain install stable
|
|
- name: Install toml-cli
|
|
run: |
|
|
cargo install toml-cli
|
|
- name: Get project version
|
|
id: toml
|
|
run: |
|
|
NEOLINK_VERSION="$(toml get Cargo.toml package.version | sed 's|"||g')"
|
|
echo "version=${NEOLINK_VERSION}" >> $GITHUB_OUTPUT
|
|
- name: Prepare directory
|
|
run: |
|
|
mkdir linux
|
|
mkdir linux/arm
|
|
mkdir linux/arm64
|
|
- name: Download Linux x86_64
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-amd64-buster
|
|
path: linux/amd64
|
|
- name: Download Linux armv7
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-armhf-buster
|
|
path: linux/arm/v7
|
|
- name: Download Linux arm64
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-arm64-buster
|
|
path: linux/arm64
|
|
- name: Download Linux i386
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-i386-buster
|
|
path: linux/386
|
|
- name: Push to Docker Hub
|
|
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/386
|
|
context: .
|
|
push: true
|
|
file: Dockerfile
|
|
tags: ${{ steps.tags.outputs.TAGS }}
|
|
build-args: VERSION=${{ steps.toml.outputs.version }}, REPO=${{ github.repository }}, OWNER=${{ github.repository_owner }}
|
|
env:
|
|
DOCKER_BUILDKIT: 1
|
|
|
|
create_release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' # Ensure this only runs on a tag or expect issues
|
|
needs:
|
|
- "cross"
|
|
- "native"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
- name: Install latest rust
|
|
run: |
|
|
rustup toolchain install stable
|
|
- name: Install toml-cli
|
|
run: |
|
|
cargo install toml-cli
|
|
- name: Get project version
|
|
id: toml
|
|
run: |
|
|
NEOLINK_VERSION="$(toml get Cargo.toml package.version | sed 's|"||g')"
|
|
echo "version=${NEOLINK_VERSION}" >> $GITHUB_OUTPUT
|
|
- name: Download Windows
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-windows-2022
|
|
path: neolink_windows
|
|
- name: Download Macos
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-macos-12
|
|
path: neolink_macos
|
|
- name: Download Linux x86_64
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-ubuntu-22.04
|
|
path: neolink_linux_x86_64_ubuntu
|
|
- name: Download Linux x86_64
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-amd64-buster
|
|
path: neolink_linux_x86_64_buster
|
|
- name: Download Linux armhf
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-armhf-buster
|
|
path: neolink_linux_armhf
|
|
- name: Download Linux arm64
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-arm64-buster
|
|
path: neolink_linux_arm64
|
|
- name: Download Linux i386
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: release-i386-buster
|
|
path: neolink_linux_i386
|
|
- name: Prepare Releases
|
|
run: |
|
|
dirs=(
|
|
neolink_windows
|
|
neolink_macos
|
|
neolink_linux_x86_64_ubuntu
|
|
neolink_linux_x86_64_buster
|
|
neolink_linux_armhf
|
|
neolink_linux_arm64
|
|
neolink_linux_i386
|
|
)
|
|
for d in "${dirs[@]}"; do
|
|
chmod +x "${d}/neolink"*
|
|
zip -r "${d}.zip" "${d}"
|
|
done
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: Neolink ${{steps.toml.outputs.version}}
|
|
files: |
|
|
neolink_windows.zip
|
|
neolink_macos.zip
|
|
neolink_linux_x86_64_ubuntu.zip
|
|
neolink_linux_x86_64_buster.zip
|
|
neolink_linux_armhf.zip
|
|
neolink_linux_arm64.zip
|
|
neolink_linux_i386.zip
|
|
body: |
|
|
Neolink Release ${{steps.toml.outputs.version}}
|
|
draft: true
|
|
prerelease: ${{ contains(github.ref_name, 'rc') }} |