Skip to content

Commit

Permalink
Update workflows (#63)
Browse files Browse the repository at this point in the history
* Update workflows, update icons, fix Dockerfile

Signed-off-by: Marcel Goerentz <m.goerentz@t-online.de>
  • Loading branch information
marcelGoerentz authored Jan 16, 2025
1 parent ea288df commit efcfb43
Show file tree
Hide file tree
Showing 21 changed files with 606 additions and 269 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
branches:
- beta

permissions:
contents: write
jobs:
buildBinaries:
name: Build and release binaries
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.set-build-number.outputs.new_version }}
steps:
Expand All @@ -27,6 +27,17 @@ jobs:
run: |
bash ${GITHUB_WORKSPACE}/Utility/update_build_number_variable.sh ${{ secrets.API_TOKEN }} ${{ github.repository }} ${{ env.NEW_BUILD }}
- name: Build webUI
run: |
tsc -p ${GITHUB_WORKSPACE}/web/tsconfig.json
python ${GITHUB_WORKSPACE}/Utility/create_new_webUI.py
- name: Upload webUI as artifact
uses: actions/upload-artifact@v4
with:
name: webUI-artifact
path: ./src/webUI.go

- name: Set up and Build
uses: actions/setup-go@v5
with:
Expand Down Expand Up @@ -58,6 +69,12 @@ jobs:
- name: Set NEW_VERSION
run: echo "NEW_VERSION=${{ needs.buildBinaries.outputs.new_version }}" >> $GITHUB_ENV
shell: bash

- name: Download webUI artifact
uses: actions/download-artifact@v4
with:
name: webUI-artifact
path: ./src

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -73,7 +90,7 @@ jobs:
with:
context: .
build-args: |
BRANCH=beta
BUILD_FLAG=beta
VERSION=${{ env.NEW_VERSION }}
push: true
no-cache: true
Expand Down
27 changes: 16 additions & 11 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ jobs:
buildBinaries:
name: Build and release binaries
runs-on: ubuntu-latest
outputs:
permissions:
contents: write
new_version: ${{ steps.set-build-number.outputs.new_version }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: beta
ref: intermediat

- name: Set build number
id: set-build-number
Expand All @@ -42,8 +43,8 @@ jobs:
- name: Build webUI
run: |
tsc -p ./web/tsconfig.json
python ./Utility/create_webUI.py
tsc -p ${GITHUB_WORKSPACE}/web/tsconfig.json
python ${GITHUB_WORKSPACE}/Utility/create_new_webUI.py
- name: Upload webUI as artifact
uses: actions/upload-artifact@v4
Expand All @@ -67,8 +68,8 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
name: v${{ env.NEW_VERSION }} (Beta)
tag_name: v${{ env.NEW_VERSION }}-beta
name: v${{ env.NEW_VERSION }} (Workflow Test)
tag_name: v${{ env.NEW_VERSION }}-test
files: dist/*

buildDockerImages:
Expand All @@ -82,6 +83,12 @@ jobs:
- name: Set NEW_VERSION
run: echo "NEW_VERSION=${{ needs.buildBinaries.outputs.new_version }}" >> $GITHUB_ENV
shell: bash

- name: Download webUI artifact
uses: actions/download-artifact@v4
with:
name: webUI-artifact
path: ./src

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -97,10 +104,8 @@ jobs:
with:
context: .
build-args: |
BRANCH=beta
push: true
BUILD_FLAG=beta
VERSION=${{ env.NEW_VERSION }}
push: false
no-cache: true
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8
tags: |
mgoerentz/threadfin:latest-beta
mgoerentz/threadfin:v${{ env.NEW_VERSION }}-beta
35 changes: 25 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
branches:
- master

permissions:
contents: write
jobs:
buildBinaries:
name: Build and release binaries
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.set-build-number.outputs.new_version }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: main
ref: maser

- name: Set build number
id: set-build-number
Expand All @@ -27,17 +27,28 @@ jobs:
run: |
bash ${GITHUB_WORKSPACE}/Utility/update_build_number_variable.sh ${{ secrets.API_TOKEN }} ${{ github.repository }} ${{ env.NEW_BUILD }}
- name: Build webUI
run: |
tsc -p ${GITHUB_WORKSPACE}/web/tsconfig.json
python ${GITHUB_WORKSPACE}/Utility/create_new_webUI.py
- name: Upload webUI as artifact
uses: actions/upload-artifact@v4
with:
name: webUI-artifact
path: ./src/webUI.go

- name: Set up and Build
uses: actions/setup-go@v5
with:
go-version: 1.23
id: go
- name: Build Binaries

- name: Build binaries
run: |
go mod tidy && go mod vendor
bash ${GITHUB_WORKSPACE}/Utility/create_binaries.sh
- name: Create a Release
uses: softprops/action-gh-release@v2
with:
Expand All @@ -48,7 +59,7 @@ jobs:
make_latest: true

buildDockerImages:
name: Build and push Docker Images
name: Build and push Docker images
runs-on: ubuntu-latest
needs: buildBinaries
steps:
Expand All @@ -59,6 +70,12 @@ jobs:
run: echo "NEW_VERSION=${{ needs.buildBinaries.outputs.new_version }}" >> $GITHUB_ENV
shell: bash

- name: Download webUI artifact
uses: actions/download-artifact@v4
with:
name: webUI-artifact
path: ./src

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -69,13 +86,11 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Build and Push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
push: true
no-cache: true
build-args: |
VERSION=${{ env.NEW_VERSION }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8
tags: |
mgoerentz/threadfin:latest
Expand Down
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# First stage. Building a binary
# -----------------------------------------------------------------------------
ARG BRANCH=master
ARG BUILD_FLAG=master
FROM golang:1.23-alpine AS base

# Download the source code
RUN apk --no-cache add git
RUN git clone https://github.com/marcelGoerentz/Threadfin.git /src

# Copy source code
COPY . /src
WORKDIR /src

ARG VERSION
RUN git checkout ${BRANCH} && git pull \
&& sed -i "s/const Version = \".*\"/const Version = \"${VERSION}\"/" threadfin.go \
RUN sed -i "s/const Version = \".*\"/const Version = \"${VERSION}\"/" threadfin.go \
&& go mod tidy \
&& go mod vendor

Expand All @@ -21,7 +18,7 @@ RUN go build .
FROM base AS beta
RUN go build -tags beta .

FROM ${BRANCH} AS builder
FROM ${BUILD_FLAG} AS builder
ARG BRANCH
RUN echo "Build ${BRANCH} version"

Expand Down
48 changes: 48 additions & 0 deletions Utility/create_new_webUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
import base64

# Variablen
html_folder = "./web/public"
go_file = "./src/webUI.go"
package_name = "src"
map_name = "webUI"

# Funktion zum Überprüfen der HTML-Dateien
def check_html_folder():
if not os.path.isdir(html_folder):
print("HTML folder does not exist.")
return False
return True

# Funktion zum Erstellen der Go-Datei
def build_go_file():
if not check_html_folder():
return

content = f"package {package_name}\n\n"
content += f"var {map_name} = make(map[string]interface{{}})\n\n"
content += "func loadHTMLMap() {\n\n"

# Hier wird die Map aus den Dateien im HTML-Ordner erstellt
content += create_map_from_files(html_folder) + "\n"

content += "}\n\n"

with open(go_file, "w") as f:
f.write(content)

# Funktion zum Erstellen der Map aus den Dateien im HTML-Ordner
def create_map_from_files(folder):
map_content = ""
for root, _, files in os.walk(folder):
for file in files:
file_path = os.path.join(root, file)
with open(file_path, "rb") as f:
base64_str = base64.b64encode(f.read()).decode('utf-8')
key = os.path.relpath(file_path, folder).replace("\\", "/")
map_content += f'\t{map_name}["web/public/{key}"] = "{base64_str}"\n'
return map_content

# Aufruf der Funktion buildGoFile
build_go_file()
print("Created new webUI.go")
3 changes: 2 additions & 1 deletion src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func Init() (err error) {

System.URLBase = fmt.Sprintf("%s://%s:%s", System.ServerProtocol, System.IPAddress, Settings.Port)

/*
// HTML Dateien erstellen, mit dev == true werden die lokalen HTML Dateien verwendet
if System.Dev {
Expand All @@ -201,7 +202,7 @@ func Init() (err error) {
return
}
}
}*/

// DLNA Server starten
if Settings.SSDP {
Expand Down
24 changes: 20 additions & 4 deletions src/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ import (
// Einstellungen ändern (WebUI)
func updateServerSettings(request RequestStruct) (settings SettingsStruct, err error) {

var oldSettings = jsonToMap(mapToJSON(Settings))
var newSettings = jsonToMap(mapToJSON(request.Settings))
oldSettings, err := jsonToMap(mapToJSON(Settings))
if err != nil {
ShowError(err, 0 ) //TODO: Define error code
return
}
newSettings, err := jsonToMap(mapToJSON(request.Settings))
if err != nil {
ShowError(err, 0 ) //TODO: Define error code
return
}
var reloadData = false
var cacheImages = false
var createXEPGFiles = false
Expand Down Expand Up @@ -470,7 +478,11 @@ func saveFilter(request RequestStruct) (settings SettingsStruct, err error) {
// Neuer Filter
newFilter = true
dataID = createNewID()
filterMap[dataID] = jsonToMap(mapToJSON(defaultFilter))
filterMap[dataID], err = jsonToMap(mapToJSON(defaultFilter))
if err != nil {
ShowError(err, 0 ) //TODO: Define error code
return
}

}

Expand Down Expand Up @@ -658,7 +670,11 @@ func saveNewUser(request RequestStruct) (err error) {
// Wizard (WebUI)
func saveWizard(request RequestStruct) (nextStep int, err error) {

var wizard = jsonToMap(mapToJSON(request.Wizard))
wizard, err := jsonToMap(mapToJSON(request.Wizard))
if err != nil {
ShowError(err, 0 ) //TODO: Define error code
return
}

for key, value := range wizard {

Expand Down
Loading

0 comments on commit efcfb43

Please sign in to comment.