From 2a3ef3e52a6c7f04aecfa2349570af02389582f8 Mon Sep 17 00:00:00 2001 From: moecinnamo Date: Sat, 22 Nov 2025 16:04:45 +0800 Subject: [PATCH] Add configuration and other related code, and add automatic build related frameworks. Currently, the version is not available --- .github/workflows/test-and-build.yml | 34 ++++++++++++++++++++++++++++ .github/workflows/test-runners.yml | 16 ------------- config.example.json | 14 ++++++++++++ internal/service/config.go | 0 internal/service/struct.go | 17 ++++++++++++++ 5 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test-and-build.yml delete mode 100644 .github/workflows/test-runners.yml create mode 100644 config.example.json create mode 100644 internal/service/config.go create mode 100644 internal/service/struct.go diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml new file mode 100644 index 0000000..5c36d39 --- /dev/null +++ b/.github/workflows/test-and-build.yml @@ -0,0 +1,34 @@ +name: Test and Build Project +on: + workflow_dispatch: + inputs: + build_type: + description: "Build type: version or pre" + required: true + type: choice + options: + - version + - pre + version_number: + description: "Version number" + required: true + type: string +jobs: + build: + runs-on: self-hosted + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Test code + run: | + echo "Testing code" + - name: Build version + if: ${{ github.event.inputs.build_type == 'version' }} + run: | + echo "Building version ${{ github.event.inputs.version_number }}" + go mod tidy + - name: Build pre-release + if: ${{ github.event.inputs.build_type == 'pre' }} + run: | + echo "Building pre-release ${{ github.event.inputs.version_number }}" + go mod tidy diff --git a/.github/workflows/test-runners.yml b/.github/workflows/test-runners.yml deleted file mode 100644 index 9cdffb6..0000000 --- a/.github/workflows/test-runners.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Test Runners -on: - push: - branches: - - master - pull_request: - branches: - - master -jobs: - test-runners: - runs-on: self-hosted - steps: - - name: test-runners - run: | - echo "Testing runners..." - cat /etc/os-release diff --git a/config.example.json b/config.example.json new file mode 100644 index 0000000..4e735db --- /dev/null +++ b/config.example.json @@ -0,0 +1,14 @@ +{ + "server": { + "host": "0.0.0.0", + "port": 2233 + }, + "database": { + "host": "localhost", + "port": 3306, + "username": "root", + "password": "password", + "database": "meowbox", + "prefix": "box_" + } +} \ No newline at end of file diff --git a/internal/service/config.go b/internal/service/config.go new file mode 100644 index 0000000..e69de29 diff --git a/internal/service/struct.go b/internal/service/struct.go new file mode 100644 index 0000000..7d27c12 --- /dev/null +++ b/internal/service/struct.go @@ -0,0 +1,17 @@ +package service + +// Config represents the full configuration structure +type Config struct { + Server struct { + Host string `json:"host"` + Port int `json:"port"` + } `json:"server"` + Database struct { + Host string `json:"host"` + Port int `json:"port"` + Username string `json:"username"` + Password string `json:"password"` + Database string `json:"database"` + Prefix string `json:"prefix"` + } `json:"database"` +}