mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-12-27 17:05:40 -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:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Install libopus-dev
|
||||
|
||||
- name: 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
|
||||
with:
|
||||
go-version: 1.17
|
||||
-
|
||||
name: go-license install
|
||||
|
||||
- name: go-license install
|
||||
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"
|
||||
-
|
||||
name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||
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:
|
||||
version: latest
|
||||
args: build --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Run GoReleaser
|
||||
|
||||
- name: Run GoReleaser Release
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
@ -48,8 +53,8 @@ jobs:
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Upload assets
|
||||
|
||||
- name: Upload assets
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: mdb
|
||||
|
@ -19,6 +19,26 @@ builds:
|
||||
# - darwin
|
||||
goarch:
|
||||
- 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:
|
||||
checksum:
|
||||
|
6
Makefile
6
Makefile
@ -1,17 +1,17 @@
|
||||
GOFILES=$(shell find ./ -type f -name '*.go')
|
||||
|
||||
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"
|
||||
|
||||
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
|
||||
go run -race ./cmd/mumble-discord-bridge
|
||||
|
||||
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:
|
||||
|
@ -120,10 +120,11 @@ func (dd *DiscordDuplex) discordSendPCM(ctx context.Context, cancel context.Canc
|
||||
dd.Bridge.DiscordVoice.RWMutex.RUnlock()
|
||||
}
|
||||
|
||||
defer log.Println("Stopping Discord send PCM")
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Println("Stopping Discord send PCM")
|
||||
return
|
||||
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 !streaming {
|
||||
speakingStart = time.Now()
|
||||
dd.Bridge.DiscordVoice.Speaking(true)
|
||||
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)
|
||||
done <- true
|
||||
}()
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(5 * time.Second):
|
||||
fmt.Println("Discord speaking timeout :(")
|
||||
cancel()
|
||||
return
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
streaming = true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user