@@ -0,0 +1,103 @@
|
|||||||
|
name: Test Build and Run
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
pull_request:
|
||||||
|
merge_group:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||||
|
arch: [amd64, arm64]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
GOARCH: ${{ matrix.arch }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '1.19'
|
||||||
|
|
||||||
|
- name: Build Go binary
|
||||||
|
run: go build -ldflags "-s -w" -trimpath -o ./go2rtc
|
||||||
|
|
||||||
|
- name: Test Go binary on linux
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.arch }}" = "amd64" ]; then
|
||||||
|
./go2rtc -version
|
||||||
|
else
|
||||||
|
sudo apt-get update && sudo apt-get install -y qemu-user-static
|
||||||
|
sudo cp /usr/bin/qemu-aarch64-static .
|
||||||
|
sudo chown $USER:$USER ./qemu-aarch64-static
|
||||||
|
qemu-aarch64-static ./go2rtc -version
|
||||||
|
fi
|
||||||
|
- name: Test Go binary on macos
|
||||||
|
if: matrix.os == 'macos-latest'
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.arch }}" = "amd64" ]; then
|
||||||
|
./go2rtc -version
|
||||||
|
else
|
||||||
|
echo "ARM64 architecture is not yet supported on macOS"
|
||||||
|
fi
|
||||||
|
- name: Test Go binary on windows
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: |
|
||||||
|
if ("${{ matrix.arch }}" -eq "amd64") {
|
||||||
|
.\go2rtc* -version
|
||||||
|
} else {
|
||||||
|
Write-Host "ARM64 architecture is not yet supported on Windows"
|
||||||
|
}
|
||||||
|
docker-test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- amd64
|
||||||
|
- "386"
|
||||||
|
- arm/v7
|
||||||
|
- arm64/v8
|
||||||
|
continue-on-error: true
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/${{ matrix.platform }}
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: go2rtc-${{ matrix.platform }}
|
||||||
|
- name: test run
|
||||||
|
run: |
|
||||||
|
docker run --platform=linux/${{ matrix.platform }} --rm go2rtc-${{ matrix.platform }} go2rtc -version
|
||||||
|
|
||||||
|
- name: Build and push Hardware
|
||||||
|
if: matrix.platform == 'amd64'
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: hardware.Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: go2rtc-${{ matrix.platform }}-hardware
|
||||||
|
- name: test run
|
||||||
|
if: matrix.platform == 'amd64'
|
||||||
|
run: |
|
||||||
|
docker run --platform=linux/${{ matrix.platform }} --rm go2rtc-${{ matrix.platform }}-hardware go2rtc -version
|
||||||
+13
-4
@@ -2,16 +2,18 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/shell"
|
"fmt"
|
||||||
"github.com/rs/zerolog"
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/shell"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "1.3.0"
|
var Version = "1.3.0"
|
||||||
@@ -24,10 +26,17 @@ var Info = map[string]any{
|
|||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
var confs Config
|
var confs Config
|
||||||
|
var version bool
|
||||||
|
|
||||||
flag.Var(&confs, "config", "go2rtc config (path to file or raw text), support multiple")
|
flag.Var(&confs, "config", "go2rtc config (path to file or raw text), support multiple")
|
||||||
|
flag.BoolVar(&version, "version", false, "Print the version of the application and exit")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if version {
|
||||||
|
fmt.Println("Current version: ", Version)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if confs == nil {
|
if confs == nil {
|
||||||
confs = []string{"go2rtc.yaml"}
|
confs = []string{"go2rtc.yaml"}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user