Compare commits

..
14 Commits
Author SHA1 Message Date
bvbej 22624d22c4 Merge pull request '更新版本' (#40) from dev into main
Reviewed-on: #40
2026-08-11 11:05:28 +08:00
bvbej 456f4a9cdc Merge pull request '[🚀] mapstructure' (#39) from dev into main
Reviewed-on: #39
2026-02-25 17:44:51 +08:00
bvbej 8c3f374dbd Merge pull request '[🚀] mapstructure' (#38) from dev into main
Reviewed-on: #38
2026-02-25 17:31:58 +08:00
bvbej 34b7a8a5df Merge pull request 'dev' (#37) from dev into main
Reviewed-on: #37
2026-02-25 15:08:43 +08:00
bvbej 33a6aca4ff Merge pull request '[🚀] storage' (#36) from dev into main
Reviewed-on: #36
2026-02-07 16:27:33 +08:00
bvbej 8d2de46efa Merge pull request 'dev' (#35) from dev into main
Reviewed-on: #35
2026-02-07 16:04:39 +08:00
bvbej 8c8c98b756 Merge pull request '[🚀] EncryptedRequest' (#34) from dev into main
Reviewed-on: #34
2026-02-07 15:54:50 +08:00
bvbej d36d66bbf7 Merge pull request 'dev' (#33) from dev into main
Reviewed-on: #33
2026-02-07 15:45:06 +08:00
bvbej 3b4b9952dc Merge pull request '[🚀] mysql' (#32) from dev into main
Reviewed-on: #32
2026-02-07 15:36:57 +08:00
bvbej b3e319a21f Merge pull request 'dev' (#31) from dev into main
Reviewed-on: #31
2026-01-21 16:41:13 +08:00
bvbej 5213f7002f Merge pull request '[🚀] v0.13.1' (#30) from dev into main
Reviewed-on: #30
2025-12-20 10:45:41 +08:00
bvbej 20f500ebcf Merge pull request '[🚀] v0.13.0' (#29) from dev into main
Reviewed-on: #29
2025-12-19 15:52:59 +08:00
bvbej fd13fafd86 Merge pull request 'dev' (#28) from dev into main
Reviewed-on: #28
2025-12-09 15:39:26 +08:00
bvbej 8926ec889b Merge pull request '[🚀] v0.12.27' (#27) from dev into main
Reviewed-on: #27
2025-09-25 13:46:51 +08:00
3 changed files with 5 additions and 151 deletions
-116
View File
@@ -1,116 +0,0 @@
name: Update dependencies and release
on:
schedule:
# Every Sunday at 03:17 UTC (11:17 Asia/Shanghai).
- cron: '17 3 * * 0'
workflow_dispatch:
permissions:
contents: write
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITEA_SERVER_URL: ${{ github.server_url }}
GITEA_REPOSITORY: ${{ github.repository }}
jobs:
update-and-release:
# The act_runner on the Raspberry Pi must expose the self-hosted label.
runs-on: self-hosted
timeout-minutes: 60
steps:
- name: Check out the default branch
uses: actions/checkout@v4
with:
token: ${{ secrets.GITEA_TOKEN }}
ref: ${{ env.DEFAULT_BRANCH }}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Update modules
shell: bash
run: |
set -euo pipefail
go get -u ./...
go mod tidy
- name: Run tests
shell: bash
run: go test -timeout=20m ./...
- name: Detect dependency changes
id: changes
shell: bash
run: |
if git diff --quiet -- go.mod go.sum; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push dependency update
if: steps.changes.outputs.changed == 'true'
shell: bash
run: |
set -euo pipefail
git config user.name "gitea-actions[bot]"
git config user.email "gitea-actions[bot]@users.noreply.gitea.local"
git add go.mod go.sum
git commit -m "chore: update Go dependencies"
git push origin "HEAD:$DEFAULT_BRANCH"
- name: Calculate next patch version
if: steps.changes.outputs.changed == 'true'
id: version
shell: bash
run: |
set -euo pipefail
latest="$(git tag --list 'v[0-9]*' --sort=-version:refname | head -n 1)"
if [[ -z "$latest" ]]; then
next="v0.1.0"
elif [[ "$latest" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
next="v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.$((${BASH_REMATCH[3]} + 1))"
else
echo "Latest tag '$latest' is not a vMAJOR.MINOR.PATCH tag" >&2
exit 1
fi
echo "tag=$next" >> "$GITHUB_OUTPUT"
echo "Releasing $next"
- name: Tag the release
if: steps.changes.outputs.changed == 'true'
shell: bash
env:
RELEASE_TAG: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
git tag -a "$RELEASE_TAG" -m "Release $RELEASE_TAG"
git push origin "$RELEASE_TAG"
- name: Create Gitea release
if: steps.changes.outputs.changed == 'true'
shell: bash
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
RELEASE_TAG: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
server_url="${GITEA_SERVER_URL:-${GITHUB_SERVER_URL:-}}"
repository="${GITEA_REPOSITORY:-${GITHUB_REPOSITORY:-}}"
if [[ -z "$server_url" || -z "$repository" ]]; then
echo "GITEA_SERVER_URL and GITEA_REPOSITORY are required" >&2
exit 1
fi
curl --fail-with-body --silent --show-error \
--request POST \
--header "Authorization: token ${GITEA_TOKEN}" \
--header "Content-Type: application/json" \
"${server_url%/}/api/v1/repos/${repository}/releases" \
--data "$(printf '{"tag_name":"%s","name":"%s","body":"Automated Go dependency update."}' "$RELEASE_TAG" "$RELEASE_TAG")"
-29
View File
@@ -2,32 +2,3 @@
* pb协议文件生成命令
`protoc --proto_path=pkg/websocket/codec/protobuf/protocol --go_out=pkg/websocket/codec/protobuf/protocol --go_opt=paths=source_relative base.proto`
## 自动更新依赖并发布版本
仓库包含 `.gitea/workflows/dependency-release.yml`。启用 Gitea Actions 后,它会在每周日 03:17 UTC(北京时间 11:17)运行,也可以在 Actions 页面手动运行:
1. 使用 `go get -u ./...``go mod tidy` 更新依赖。
2. 执行 `go test ./...`,测试失败时不会提交或发布。
3. 有依赖变更时提交 `go.mod``go.sum`,创建下一个 `vMAJOR.MINOR.PATCH` 补丁版本标签,并创建 Gitea Release。
### 树莓派上的 Runner 配置
在树莓派上安装并注册 Gitea `act_runner`,注册标签中包含 `self-hosted`,并确保 Runner 环境有 Git、Go、Node.js、`curl`。工作流使用 `runs-on: self-hosted`,因此不会依赖 GitHub-hosted Runner。
在仓库的 **Settings -> Secrets -> Actions** 中新增:
- `GITEA_TOKEN`:一个能读写仓库内容、创建标签和 Release 的 Gitea Personal Access Token。
如果默认分支启用了保护规则,还需要允许该 Token 所属账号直接推送。
首次使用时建议先在仓库中手动创建一个 `v0.1.0` 以后的 SemVer 标签;如果没有任何 `vMAJOR.MINOR.PATCH` 标签,工作流会从 `v0.1.0` 开始。
```text
1. 安装并注册 act_runner,标签包含 self-hosted
2. Runner 安装 Git、Go、Node.js、curl
3. 添加 SecretGITEA_TOKEN
4. Token 允许读写仓库、创建标签和 Release
5. 若默认分支受保护,允许该 Token 所属账号推送
```
+5 -6
View File
@@ -1,7 +1,6 @@
package captcha
import (
"context"
"fmt"
"gitea.bvbej.com/bvbej/base-golang/pkg/cache"
"github.com/mojocn/base64Captcha"
@@ -13,7 +12,7 @@ import (
var _ base64Captcha.Store = (*store)(nil)
type store struct {
cache cache.RedisRepo
cache cache.Repo
ttl time.Duration
logger *zap.Logger
ns string
@@ -21,7 +20,7 @@ type store struct {
}
func (s *store) Set(id string, value string) error {
err := s.cache.Set(context.Background(), fmt.Sprintf("%s%s%s", s.ns, s.prefix, id), value, s.ttl)
err := s.cache.Set(fmt.Sprintf("%s%s%s", s.ns, s.prefix, id), value, s.ttl)
if err != nil {
return err
}
@@ -29,9 +28,9 @@ func (s *store) Set(id string, value string) error {
}
func (s *store) Get(id string, clear bool) string {
value, err := s.cache.Get(context.Background(), fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
value, err := s.cache.Get(fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
if err == nil && clear {
_, _ = s.cache.Del(context.Background(), fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
s.cache.Del(fmt.Sprintf("%s%s%s", s.ns, s.prefix, id))
}
return value
}
@@ -44,7 +43,7 @@ func (s *store) Verify(id, answer string, clear bool) bool {
return strings.ToLower(value) == strings.ToLower(answer)
}
func NewStore(cache cache.RedisRepo, ttl time.Duration, namespace string) base64Captcha.Store {
func NewStore(cache cache.Repo, ttl time.Duration, namespace string) base64Captcha.Store {
return &store{
cache: cache,
ttl: ttl,