Feat: cgo support

pull/65/head
zijiren233 2 years ago
parent 63717f52ee
commit c5d72bf2c2

@ -11,28 +11,46 @@ concurrency:
cancel-in-progress: true
jobs:
get_all_targets:
name: Get all targets
runs-on: ubuntu-latest
outputs:
TARGETS: ${{ steps.get_all_targets.outputs.TARGETS }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get all targets
id: get_all_targets
run: |
declare -a arr=()
OIFS="$IFS"
IFS=$'\n,'
for line in $(script/build.sh -t); do
arr+=("$line")
done
IFS="$OIFS"
printf -v json '"%s",' "${arr[@]}"
json="[${json%,}]"
echo "TARGETS=$json" >> $GITHUB_OUTPUT
build:
name: Build
runs-on: ubuntu-latest
needs: get_all_targets
strategy:
max-parallel: 8
matrix:
platform: [ubuntu-latest]
go-version: ["1.21"]
name: Build
runs-on: ${{ matrix.platform }}
target: ${{ fromJson(needs.get_all_targets.outputs.TARGETS) }}
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21"
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
bash script/build.sh -s -p "windows,linux,darwin"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: synctv
path: build
bash script/build.sh -sp "${{ matrix.target }}"

@ -6,18 +6,41 @@ on:
- "v*"
jobs:
get_all_targets:
name: Get all targets
runs-on: ubuntu-latest
outputs:
TARGETS: ${{ steps.get_all_targets.outputs.TARGETS }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get all targets
id: get_all_targets
run: |
declare -a arr=()
OIFS="$IFS"
IFS=$'\n,'
for line in $(script/build.sh -t); do
arr+=("$line")
done
IFS="$OIFS"
printf -v json '"%s",' "${arr[@]}"
json="[${json%,}]"
echo "TARGETS=$json" >> $GITHUB_OUTPUT
release:
name: Release
needs: get_all_targets
runs-on: ubuntu-latest
strategy:
matrix:
platform: [ubuntu-latest]
go-version: ["1.21"]
name: Release
runs-on: ${{ matrix.platform }}
target: ${{ fromJson(needs.get_all_targets.outputs.TARGETS) }}
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21"
- name: Checkout
uses: actions/checkout@v4
@ -28,13 +51,17 @@ jobs:
- name: Build
run: |
bash script/build.sh -v "v${{ steps.get_version.outputs.VERSION }}" -p "windows,linux,darwin"
bash script/build.sh -v "v${{ steps.get_version.outputs.VERSION }}" -p "${{ matrix.target }}"
- uses: "marvinpinto/action-automatic-releases@latest"
- name: Release
uses: softprops/action-gh-release@v1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ steps.get_version.outputs.VERSION }}"
title: "Version ${{ steps.get_version.outputs.VERSION }}"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: ${{ contains(steps.get_version.outputs.VERSION, 'rc') || contains(steps.get_version.outputs.VERSION, 'beta') || contains(steps.get_version.outputs.VERSION, 'alpha') }}
append_body: false
fail_on_unmatched_files: true
name: "Version ${{ steps.get_version.outputs.VERSION }}"
tag_name: "v${{ steps.get_version.outputs.VERSION }}"
files: |
build/*
build/*

@ -4,31 +4,58 @@ on:
workflow_dispatch:
jobs:
get_all_targets:
name: Get all targets
runs-on: ubuntu-latest
outputs:
TARGETS: ${{ steps.get_all_targets.outputs.TARGETS }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get all targets
id: get_all_targets
run: |
declare -a arr=()
OIFS="$IFS"
IFS=$'\n,'
for line in $(script/build.sh -t); do
arr+=("$line")
done
IFS="$OIFS"
printf -v json '"%s",' "${arr[@]}"
json="[${json%,}]"
echo "TARGETS=$json" >> $GITHUB_OUTPUT
release_dev:
name: Release dev
runs-on: ubuntu-latest
needs: get_all_targets
strategy:
matrix:
platform: [ubuntu-latest]
go-version: ["1.21"]
name: Release
runs-on: ${{ matrix.platform }}
target: ${{ fromJson(needs.get_all_targets.outputs.TARGETS) }}
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21"
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
bash script/build.sh -v dev -p "windows,linux,darwin"
bash script/build.sh -v dev -p "${{ matrix.target }}"
- uses: "marvinpinto/action-automatic-releases@latest"
- name: Release
uses: softprops/action-gh-release@v1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "dev"
title: "Dev Build"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: true
append_body: false
fail_on_unmatched_files: true
name: "Dev Build"
tag_name: dev
files: |
build/*

@ -9,6 +9,11 @@ jobs:
release_docker:
name: Release Docker
runs-on: ubuntu-latest
strategy:
matrix:
platforms:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
@ -48,4 +53,4 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
platforms: ${{ matrix.platforms }}

1
.gitignore vendored

@ -6,3 +6,4 @@
*.db
.vscode
*.local
/compiler

@ -10,7 +10,7 @@ WORKDIR /synctv
COPY ./ ./
RUN apk add --no-cache bash curl gcc git go musl-dev && \
RUN apk add --no-cache bash curl git go && \
bash script/build.sh -v ${VERSION}
From alpine:latest
@ -28,7 +28,7 @@ RUN apk add --no-cache bash ca-certificates su-exec tzdata && \
WORKDIR /root/.synctv
EXPOSE 8080/tcp 8080/udp
EXPOSE 8080/tcp
VOLUME [ "/root/.synctv" ]

@ -60,11 +60,9 @@ require (
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/go-playground/form/v4 v4.2.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
@ -97,6 +95,7 @@ require (
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.19 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@ -107,7 +106,6 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
@ -128,8 +126,8 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
modernc.org/libc v1.38.1 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/sqlite v1.28.0 // indirect
)
// 使CGO
// `go mod tidy`
replace github.com/glebarez/sqlite => gorm.io/driver/sqlite v1.5.4

@ -52,8 +52,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/envoyproxy/go-control-plane v0.11.2-0.20230627204322-7d0032219fcb h1:kxNVXsNro/lpR5WD+P1FI/yUHn2G03Glber3k8cQL2Y=
github.com/envoyproxy/go-control-plane v0.11.2-0.20230627204322-7d0032219fcb/go.mod h1:GxGqnjWzl1Gz8WfAfMJSfhvsi4EPZayRb25nLHDWXyA=
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
@ -71,10 +69,6 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
github.com/glebarez/sqlite v1.10.0 h1:u4gt8y7OND/cCei/NMHmfbLxF6xP2wgKcT/BJf2pYkc=
github.com/glebarez/sqlite v1.10.0/go.mod h1:IJ+lfSOmiekhQsFTJRx/lHtGYmCdtAiTaf5wI9u5uHA=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ=
@ -256,6 +250,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY=
@ -315,8 +311,6 @@ github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q=
github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@ -535,16 +529,10 @@ gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs=
gorm.io/driver/mysql v1.5.2/go.mod h1:pQLhh1Ut/WUAySdTHwBpBv6+JKcj+ua4ZFx1QQTBzb8=
gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo=
gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0=
gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0=
gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
modernc.org/libc v1.38.1 h1:kLZYihFEUV2+T10Bt+AhugJlkSNA4JJ36vMCSe1Bexk=
modernc.org/libc v1.38.1/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ=
modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save