Compare commits
5 Commits
fff1a783c9
...
main
Author | SHA1 | Date | |
---|---|---|---|
b0f0c587c9 | |||
fb62aaa7b8 | |||
097ff306a9 | |||
774288768e | |||
f69f4d6029 |
124
.gitea/workflows/release.yml
Normal file
124
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
# Git(tea) Actions workflow: Build and publish standalone binaries **plus** bundled `static/` assets
|
||||||
|
# ────────────────────────────────────────────────────────────────────
|
||||||
|
# ✧ Builds the Go‑based WoL server for four targets **and** packt das Verzeichnis
|
||||||
|
# `static` zusammen mit der Binary, sodass es relativ zur ausführbaren Datei
|
||||||
|
# liegt (wichtig für die eingebauten Bootstrap‑Assets & favicon).
|
||||||
|
#
|
||||||
|
# • linux/amd64 → wol-server-linux-amd64.tar.gz
|
||||||
|
# • linux/arm64 → wol-server-linux-arm64.tar.gz
|
||||||
|
# • linux/arm/v7 → wol-server-linux-armv7.tar.gz
|
||||||
|
# • windows/amd64 → wol-server-windows-amd64.zip
|
||||||
|
#
|
||||||
|
# ✧ Artefakte landen im Workflow und – bei Tag‑Push (vX.Y.Z) – als Release‑Assets.
|
||||||
|
#
|
||||||
|
# Secrets/variables:
|
||||||
|
# GITEA_TOKEN – optional, falls default token keine Release‑Rechte hat.
|
||||||
|
# ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
name: build-binaries
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
tags: [ "v*" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-fast
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
ext: ""
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
ext: ""
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
ext: ""
|
||||||
|
- goos: windows
|
||||||
|
goarch: amd64
|
||||||
|
ext: ".exe"
|
||||||
|
|
||||||
|
env:
|
||||||
|
GO_VERSION: "1.24"
|
||||||
|
BINARY_NAME: vocalforge
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Go ${{ env.GO_VERSION }}
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Build ${{ matrix.goos }}/${{ matrix.goarch }}${{ matrix.goarm && format('/v{0}', matrix.goarm) || '' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
mkdir -p dist/package
|
||||||
|
if [ -n "${{ matrix.goarm }}" ]; then export GOARM=${{ matrix.goarm }}; fi
|
||||||
|
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -trimpath -ldflags "-s -w" \
|
||||||
|
-o "dist/package/${BINARY_NAME}${{ matrix.ext }}" .
|
||||||
|
# Assets: statisches Verzeichnis beilegen
|
||||||
|
cp -r static dist/package/
|
||||||
|
|
||||||
|
- name: Package archive with static assets
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
cd dist
|
||||||
|
if [ "${{ matrix.goos }}" == "windows" ]; then
|
||||||
|
ZIP_NAME="${BINARY_NAME}-windows-amd64.zip"
|
||||||
|
(cd package && zip -r "../$ZIP_NAME" .)
|
||||||
|
else
|
||||||
|
ARCH_SUFFIX="${{ matrix.goarch }}"
|
||||||
|
if [ "${{ matrix.goarch }}" == "arm" ]; then ARCH_SUFFIX="armv${{ matrix.goarm }}"; fi
|
||||||
|
TAR_NAME="${BINARY_NAME}-${{ matrix.goos }}-${ARCH_SUFFIX}.tar.gz"
|
||||||
|
tar -czf "$TAR_NAME" -C package .
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload workflow artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && format('v{0}', matrix.goarm) || '' }}
|
||||||
|
path: dist/*.tar.gz
|
||||||
|
if-no-files-found: ignore
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: windows-amd64
|
||||||
|
path: dist/*.zip
|
||||||
|
if-no-files-found: ignore
|
||||||
|
|
||||||
|
# Release Schritt für Tag‑Pushes
|
||||||
|
release:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-fast
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ./dist
|
||||||
|
|
||||||
|
- name: Create / Update release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||||
|
with:
|
||||||
|
name: "Release ${{ github.ref_name }}"
|
||||||
|
tag_name: ${{ github.ref_name }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
files: |
|
||||||
|
dist/**/vocalforge-*.tar.gz
|
||||||
|
dist/**/vocalforge-*.zip
|
19
Dockerfile
19
Dockerfile
@@ -6,7 +6,7 @@ WORKDIR /app
|
|||||||
COPY go.* ./
|
COPY go.* ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /bin/autovoice
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /bin/vocalforge
|
||||||
|
|
||||||
# 2. Runtime-Stage
|
# 2. Runtime-Stage
|
||||||
FROM alpine:3.22
|
FROM alpine:3.22
|
||||||
@@ -16,7 +16,7 @@ RUN apk add --no-cache ca-certificates
|
|||||||
#RUN mkdir /data
|
#RUN mkdir /data
|
||||||
#RUN mkdir /dynamicsrc
|
#RUN mkdir /dynamicsrc
|
||||||
RUN mkdir /tempsrc
|
RUN mkdir /tempsrc
|
||||||
COPY --from=builder /bin/autovoice /bin/autovoice
|
COPY --from=builder /bin/vocalforge /bin/vocalforge
|
||||||
#COPY ./static /data/static
|
#COPY ./static /data/static
|
||||||
COPY ./language.json /tempsrc/language.json
|
COPY ./language.json /tempsrc/language.json
|
||||||
#COPY ./dynamicsrc /dynamicsrc
|
#COPY ./dynamicsrc /dynamicsrc
|
||||||
@@ -25,13 +25,12 @@ COPY ./language.json /tempsrc/language.json
|
|||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
# Environment defaults; können per compose überschrieben werden
|
# Environment defaults; können per compose überschrieben werden
|
||||||
ENV LOBBY_CHANNEL_ID=0 \
|
ENV PRESENCE_GUILD_ID=0 \
|
||||||
DISCORD_TOKEN=0 \
|
DB_PATH=/data/guild_config.db \
|
||||||
GUILD_ID=0 \
|
|
||||||
CATEGORY_ID=0 \
|
|
||||||
TIMEOUT_MIN=1 \
|
TIMEOUT_MIN=1 \
|
||||||
CONFIG_PATH=/data/guild_config.json
|
DISCORD_TOKEN=0 \
|
||||||
|
TRANSLATIONS_FILE=/tempsrc/language.json
|
||||||
|
|
||||||
|
VOLUME /data
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/vocalforge"]
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/autovoice"]
|
|
36
main.go
36
main.go
@@ -174,6 +174,19 @@ func initDB() {
|
|||||||
addLanguageColumnIfNotExists()
|
addLanguageColumnIfNotExists()
|
||||||
ensureLobbyRuleTable()
|
ensureLobbyRuleTable()
|
||||||
|
|
||||||
|
_, _ = db.Exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS eventlog(
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
guild_id TEXT NOT NULL,
|
||||||
|
type TEXT NOT NULL, -- z.B. 'vc_created' | 'vc_deleted' | 'member_moved'
|
||||||
|
channel_id TEXT,
|
||||||
|
user_id TEXT,
|
||||||
|
ts INTEGER NOT NULL, -- unix seconds
|
||||||
|
extra TEXT
|
||||||
|
);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_eventlog_guild_ts ON eventlog(guild_id, ts DESC);
|
||||||
|
`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close DB connection
|
// Close DB connection
|
||||||
@@ -183,6 +196,21 @@ func closeDB() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func logEvent(gid, typ, chID, userID string, extra any) {
|
||||||
|
if db == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var extraJSON string
|
||||||
|
if extra != nil {
|
||||||
|
if b, err := json.Marshal(extra); err == nil {
|
||||||
|
extraJSON = string(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, _ = db.Exec(`INSERT INTO eventlog(guild_id, type, channel_id, user_id, ts, extra)
|
||||||
|
VALUES(?,?,?,?,?,?)`,
|
||||||
|
gid, typ, chID, userID, time.Now().Unix(), extraJSON)
|
||||||
|
}
|
||||||
|
|
||||||
// Laden der Guild-Konfiguration mit Sprache
|
// Laden der Guild-Konfiguration mit Sprache
|
||||||
func loadGuildCfgs() error {
|
func loadGuildCfgs() error {
|
||||||
rows, err := db.Query("SELECT guild_id, lobby_name, category_name, timeout_min, language FROM guild_config")
|
rows, err := db.Query("SELECT guild_id, lobby_name, category_name, timeout_min, language FROM guild_config")
|
||||||
@@ -500,6 +528,10 @@ func createPrivateVCAndMove(
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("VC-Anlage fehlgeschlagen: %w", err)
|
return nil, fmt.Errorf("VC-Anlage fehlgeschlagen: %w", err)
|
||||||
|
} else {
|
||||||
|
logEvent(guildID, "vc_created", newChan.ID, requesterID, map[string]any{
|
||||||
|
"name": newChan.Name, "timeout_min": timeoutMin,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// optionaler Move
|
// optionaler Move
|
||||||
@@ -532,6 +564,9 @@ func createPrivateVCAndMove(
|
|||||||
if moveErr != nil {
|
if moveErr != nil {
|
||||||
log.Printf("Move endgültig fehlgeschlagen: %v", moveErr)
|
log.Printf("Move endgültig fehlgeschlagen: %v", moveErr)
|
||||||
}
|
}
|
||||||
|
if moveErr == nil {
|
||||||
|
logEvent(guildID, "member_moved", newChan.ID, requesterID, nil)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,6 +602,7 @@ func watchAndCleanup(s *discordgo.Session, guildID, channelID string, timeout ti
|
|||||||
if time.Since(lastActive) >= timeout {
|
if time.Since(lastActive) >= timeout {
|
||||||
_, _ = s.ChannelDelete(channelID)
|
_, _ = s.ChannelDelete(channelID)
|
||||||
log.Println("➖ Deleted channel for guildID: " + guildID + " with ID: " + channelID)
|
log.Println("➖ Deleted channel for guildID: " + guildID + " with ID: " + channelID)
|
||||||
|
logEvent(guildID, "vc_deleted", channelID, "", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user