mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-11-22 21:35:44 -05:00
fix: allow discordSendPCM to exit when discord disconnects
chore: update action and docker build
This commit is contained in:
parent
c0ed696543
commit
f520fc67c7
39
.github/workflows/build-release.yml
vendored
39
.github/workflows/build-release.yml
vendored
@ -11,36 +11,41 @@ jobs:
|
|||||||
goreleaser:
|
goreleaser:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Checkout
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
|
||||||
name: Install libopus-dev
|
- name: Install libopus-dev
|
||||||
run: sudo apt update && sudo apt-get -y install libopus-dev
|
run: sudo apt update && sudo apt-get -y install libopus-dev
|
||||||
-
|
|
||||||
name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.17
|
go-version: 1.17
|
||||||
-
|
|
||||||
name: go-license install
|
- name: go-license install
|
||||||
run: go install github.com/google/go-licenses@latest
|
run: go install github.com/google/go-licenses@latest
|
||||||
-
|
|
||||||
name: go-license save
|
- name: go-license save
|
||||||
run: go-licenses save ./cmd/mumble-discord-bridge --force --save_path="./dist/LICENSES"
|
run: go-licenses save ./cmd/mumble-discord-bridge --force --save_path="./dist/LICENSES"
|
||||||
-
|
|
||||||
name: Run GoReleaser
|
- name: Log in to Docker Hub
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Run GoReleaser Build
|
||||||
|
uses: goreleaser/goreleaser-action@v2
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: build --rm-dist
|
args: build --rm-dist
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-
|
|
||||||
name: Run GoReleaser
|
- name: Run GoReleaser Release
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v2
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
@ -48,8 +53,8 @@ jobs:
|
|||||||
args: release --rm-dist
|
args: release --rm-dist
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-
|
|
||||||
name: Upload assets
|
- name: Upload assets
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: mdb
|
name: mdb
|
||||||
|
@ -19,6 +19,26 @@ builds:
|
|||||||
# - darwin
|
# - darwin
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
|
dockers:
|
||||||
|
- image_templates:
|
||||||
|
- "ghcr.io/stieneee/mumble-discord-bridge:latest"
|
||||||
|
- "ghcr.io/stieneee/mumble-discord-bridge:{{ .Tag }}"
|
||||||
|
- "stieneee/mumble-discord-bridge:latest"
|
||||||
|
- "stieneee/mumble-discord-bridge:{{ .Tag }}"
|
||||||
|
skip_push: "false"
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
use: docker
|
||||||
|
build_flag_templates:
|
||||||
|
- "--pull"
|
||||||
|
- "--label=org.opencontainers.image.created={{.Date}}"
|
||||||
|
- "--label=org.opencontainers.image.title={{.ProjectName}}"
|
||||||
|
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||||
|
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||||
|
- "--platform=linux/arm64"
|
||||||
|
# push_flags:
|
||||||
|
# - --tls-verify=false
|
||||||
|
# extra_files:
|
||||||
|
# - config.yml
|
||||||
|
|
||||||
# archives:
|
# archives:
|
||||||
checksum:
|
checksum:
|
||||||
|
6
Makefile
6
Makefile
@ -1,17 +1,17 @@
|
|||||||
GOFILES=$(shell find ./ -type f -name '*.go')
|
GOFILES=$(shell find ./ -type f -name '*.go')
|
||||||
|
|
||||||
mumble-discord-bridge: $(GOFILES) .goreleaser.yml
|
mumble-discord-bridge: $(GOFILES) .goreleaser.yml
|
||||||
goreleaser build --skip-validate --rm-dist
|
goreleaser build --skip-validate --rm-dist --single-target --snapshot
|
||||||
go-licenses save ./cmd/mumble-discord-bridge --force --save_path="./dist/LICENSES"
|
go-licenses save ./cmd/mumble-discord-bridge --force --save_path="./dist/LICENSES"
|
||||||
|
|
||||||
dev: $(GOFILES) .goreleaser.yml
|
dev: $(GOFILES) .goreleaser.yml
|
||||||
goreleaser build --skip-validate --rm-dist && sudo ./dist/mumble-discord-bridge_linux_amd64/mumble-discord-bridge
|
goreleaser build --skip-validate --rm-dist --single-target --snapshot && sudo ./dist/mumble-discord-bridge_linux_amd64/mumble-discord-bridge
|
||||||
|
|
||||||
dev-race: $(GOFILES) .goreleaser.yml
|
dev-race: $(GOFILES) .goreleaser.yml
|
||||||
go run -race ./cmd/mumble-discord-bridge
|
go run -race ./cmd/mumble-discord-bridge
|
||||||
|
|
||||||
dev-profile: $(GOFILES) .goreleaser.yml
|
dev-profile: $(GOFILES) .goreleaser.yml
|
||||||
goreleaser build --skip-validate --rm-dist && sudo ./dist/mumble-discord-bridge_linux_amd64/mumble-discord-bridge -cpuprofile cpu.prof
|
goreleaser build --skip-validate --rm-dist --single-target --snapshot && sudo ./dist/mumble-discord-bridge_linux_amd64/mumble-discord-bridge -cpuprofile cpu.prof
|
||||||
|
|
||||||
test-chart: SHELL:=/bin/bash
|
test-chart: SHELL:=/bin/bash
|
||||||
test-chart:
|
test-chart:
|
||||||
|
@ -120,10 +120,11 @@ func (dd *DiscordDuplex) discordSendPCM(ctx context.Context, cancel context.Canc
|
|||||||
dd.Bridge.DiscordVoice.RWMutex.RUnlock()
|
dd.Bridge.DiscordVoice.RWMutex.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer log.Println("Stopping Discord send PCM")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
log.Println("Stopping Discord send PCM")
|
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@ -135,7 +136,21 @@ func (dd *DiscordDuplex) discordSendPCM(ctx context.Context, cancel context.Canc
|
|||||||
if (len(pcm) > 1 && streaming) || (len(pcm) > dd.Bridge.BridgeConfig.DiscordStartStreamingCount && !streaming) {
|
if (len(pcm) > 1 && streaming) || (len(pcm) > dd.Bridge.BridgeConfig.DiscordStartStreamingCount && !streaming) {
|
||||||
if !streaming {
|
if !streaming {
|
||||||
speakingStart = time.Now()
|
speakingStart = time.Now()
|
||||||
|
done := make(chan bool, 1)
|
||||||
|
go func() {
|
||||||
|
// This call will prevent discordSendPCM from exiting if the discord connection is lost
|
||||||
dd.Bridge.DiscordVoice.Speaking(true)
|
dd.Bridge.DiscordVoice.Speaking(true)
|
||||||
|
done <- true
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
fmt.Println("Discord speaking timeout :(")
|
||||||
|
cancel()
|
||||||
|
return
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
streaming = true
|
streaming = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user