Added enable config option #847
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
pre_job: | |
# continue-on-error: true # Uncomment once integration is finished | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} && ! (startsWith(github.ref, 'refs/tags/') && github.event_name == 'push') | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@v5 | |
with: | |
# All of these options are optional, so you can remove them if you are happy with the defaults | |
concurrent_skipping: 'same_content_newer' | |
skip_after_successful_duplicate: 'false' | |
native: | |
needs: pre_job | |
if: needs.pre_job.outputs.should_skip != 'true' | |
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: | |
needs: pre_job | |
if: needs.pre_job.outputs.should_skip != 'true' | |
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 --verbose --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 }}-bullseye | |
path: "target/${{ matrix.target }}/release/neolink*" | |
push_to_registry: | |
name: Build Docker image | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
needs: | |
- "cross" | |
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: ${{ vars.DOCKER_USERNAME || steps.string_user.outputs.lowercase }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Set Docker name with owner (package name) depending on if DOCKER_USERNAME is set | |
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }} | |
id: docker_repo | |
shell: bash | |
run: | | |
if [ -z $DOCKER_USERNAME ]; then | |
echo "DOCKER_NWO=${GITHUB_NWO}" >> $GITHUB_OUTPUT | |
else | |
IFS='/' read -ra NWO_SPLIT <<< "$GITHUB_NWO" | |
REPO_NAME=${NWO_SPLIT[1]} | |
echo "DOCKER_NWO=${DOCKER_USERNAME}/${REPO_NAME}" >> $GITHUB_OUTPUT | |
fi | |
env: | |
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} | |
GITHUB_NWO: ${{ steps.string_repo.outputs.lowercase }} | |
- name: Get tag name | |
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }} | |
id: tags | |
shell: bash | |
run: | | |
tags=( ) | |
gittag="$(git tag --points-at HEAD)" | |
branch="$(git rev-parse --abbrev-ref HEAD)" | |
if [[ -n "${gittag}" ]]; then | |
tags=( "${tags[@]}" "${REPO_NAME}:${gittag}" ) | |
fi | |
if [[ -n "${branch}" ]]; then | |
branch="$(echo "${branch}" | sed -E 's|[/]|-|g')" | |
tags=( "${tags[@]}" "${REPO_NAME}:${branch}" ) | |
if [ "${branch}" == "master" ]; then | |
tags=( "${tags[@]}" "${tags},${REPO_NAME}:latest" ) | |
fi | |
fi | |
function join_by { | |
local d=${1-} f=${2-} | |
if shift 2; then | |
printf %s "$f" "${@/#/$d}" | |
fi | |
} | |
tagstr="$(join_by "," "${tags[@]}")" | |
echo "TAGS=${tagstr}" | |
echo "TAGS=${tagstr}" >> "${GITHUB_OUTPUT}" | |
env: | |
REPO_NAME: ${{ steps.docker_repo.outputs.DOCKER_NWO }} | |
- 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-bullseye | |
path: linux/amd64 | |
- name: Download Linux armv7 | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-armhf-bullseye | |
path: linux/arm/v7 | |
- name: Download Linux arm64 | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-arm64-bullseye | |
path: linux/arm64 | |
- name: Download Linux i386 | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-i386-bullseye | |
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=${{ vars.DOCKER_USERNAME || 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-bullseye | |
path: neolink_linux_x86_64_bullseye | |
- name: Download Linux armhf | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-armhf-bullseye | |
path: neolink_linux_armhf | |
- name: Download Linux arm64 | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-arm64-bullseye | |
path: neolink_linux_arm64 | |
- name: Download Linux i386 | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-i386-bullseye | |
path: neolink_linux_i386 | |
- name: Prepare Releases | |
run: | | |
dirs=( | |
neolink_windows | |
neolink_macos | |
neolink_linux_x86_64_ubuntu | |
neolink_linux_x86_64_bullseye | |
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_bullseye.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') }} |