Skip to content

feat: add GoReleaser configuration and GitHub Actions release workflow#53

Merged
Svtter merged 2 commits into
mainfrom
feat/goreleaser-config
May 15, 2026
Merged

feat: add GoReleaser configuration and GitHub Actions release workflow#53
Svtter merged 2 commits into
mainfrom
feat/goreleaser-config

Conversation

@Svtter
Copy link
Copy Markdown
Contributor

@Svtter Svtter commented May 15, 2026

Summary

This PR adds GoReleaser configuration and a GitHub Actions workflow for automated releases when tags are pushed.

Changes

  • .goreleaser.yaml: Complete GoReleaser configuration with:

    • Project name: static-html
    • Build from ./cmd/html-server
    • Cross-compilation for linux, darwin, windows (amd64, arm64)
    • Checksum generation
    • Version info via ldflags
  • .github/workflows/release.yml: GitHub Actions workflow that:

    • Triggers on tag push (v*)
    • Uses self-hosted runner
    • Runs GoReleaser with Go 1.24
    • Has contents: write permission

Test plan

  • Review configuration files
  • Test release workflow with a tag (e.g., v0.1.0)

🤖 Generated with Claude Code

- Add .goreleaser.yaml with cross-compilation targets for linux, darwin, and windows (amd64, arm64)
- Configure build from ./cmd/html-server with version info ldflags
- Add checksum generation and archive configuration
- Add .github/workflows/release.yml for automated releases on tag push
- Use self-hosted runner with Go 1.24

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

不可合并

摘要: PR 引入了 GoReleaser 配置和 release workflow,但存在构建阻断性问题,ldflags 引用了不存在的变量。

阻塞项:

  1. .goreleaser.yaml:21-24 — ldflags 引用了不存在的变量。 配置中的 -X main.version={{.Version}}-X main.commit={{.Commit}}-X main.date={{.Date}} 要求 main 包中存在 versioncommitdate 三个变量,但 cmd/html-server/main.go 及整个代码库中均未定义它们。Go linker 会报错 main.version is not defined构建必定失败。需要在 cmd/html-server/main.go(或同包的其他文件)中添加:
    var version, commit, date string

建议项:

  1. .github/workflows/release.yml:30version: latest 存在风险。 建议固定到一个具体版本(如 v2.15.4),避免因上游更新引入不兼容变更导致 workflow 意外失败。
  2. .github/workflows/release.yml:14runs-on: self-hosted 确认是否确实需要使用自托管 runner;若可使用 GitHub-hosted runner(如 ubuntu-latest),则更通用且安全。
  3. .goreleaser.yaml:5go generate ./... 无必要。 当前代码库没有 go:generate 指令,该 hook 执行无实际效果,可移除。
  4. .goreleaser.yaml:50-54ownername 使用了 YAML | 块标量。 会引入尾部换行符,建议改为纯标量格式:
    owner: '{{ .Env.GITHUB_REPOSITORY_OWNER }}'
    name: '{{ .Tag }}'
    (但 GoReleaser 默认会自动推断 repo 信息,此段可完全省略。)
  5. .github/workflows/release.yml:23 — 建议使用 go-version-file: go.mod 替代硬编码 go-version: '1.24',可自动保持与项目一致,减少维护成本。

New%20session%20-%202026-05-15T05%3A44%3A28.657Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown

无遗漏

PR body 中列出的所有需求均已实现:

  • project_name: static-html ✅
  • Build from ./cmd/html-server ✅ (line 18: dir: ./cmd/html-server)
  • Cross-compilation: linux/darwin/windows (amd64/arm64) ✅ (lines 11-17)
  • Checksum generation ✅ (lines 38-39)
  • Version info via ldflags ✅ (lines 21-24)
  • Triggers on tag push (v*) ✅ (workflow lines 4-6)
  • Uses self-hosted runner ✅ (line 13)
  • Runs GoReleaser with Go 1.24 ✅ (lines 20-31)
  • contents: write permission ✅ (lines 8-9)

无新增代码被修改,完全新增的两个配置文件,不存在集成遗漏问题。

New%20session%20-%202026-05-15T05%3A44%3A22.444Z
opencode session  |  github run

- Add version.go in cmd/html-server with version variables
- Remove go generate hook from .goreleaser.yaml
- Remove github block from release config
- Pin goreleaser-action to v2.6.1
- Use go-version-file instead of hardcoded go-version

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

可合并

上一轮 review 中报告的阻塞项(ldflags 引用不存在的变量)已通过新增 cmd/html-server/version.go 修复,workflow 中 version: latestgo-version-file 等问题也已修正。

阻塞项:无

建议项:

  1. .github/workflows/release.yml:13runs-on: self-hosted。确认是否需要自托管 runner;如果项目是开源的,ubuntu-latest 更通用,其他人 fork 后也能直接运行 release workflow。

New%20session%20-%202026-05-15T05%3A57%3A27.688Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown

发现遗漏

Summary: 对比 PR body 中的需求与实现,整体匹配度高,但发现一处微小偏差。

LOW

  1. 需求描述与实际实现存在偏差:Go 版本设置方式不匹配
    • 需求描述(PR body): "Runs GoReleaser with Go 1.24"
    • 实现(release.yml:23): 实际使用 go-version-file: go.mod,未硬编码 '1.24'。虽然 go.mod 中指定了 go 1.24.1,实际效果一致,但需求描述与实现方式不匹配。若未来 go.mod 版本升级而 workflow 预期不变,可能产生歧义。
    • 建议: 更新 PR body 描述为 Go version from go.mod 以匹配实际实现,或在 workflow 中改用硬编码 go-version: '1.24' 以贴合描述。

New%20session%20-%202026-05-15T05%3A57%3A30.490Z
opencode session  |  github run

@Svtter Svtter merged commit 576ba3b into main May 15, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant