You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Actions运行GoReleaser报yaml: line 26未找到预期键错误

GoReleaser 发布失败 YAML 语法错误排查

错误原因

报错和Token配置无关,是.goreleaser.yml存在YAML缩进语法错误。YAML为缩进敏感格式,同级字段必须保持统一缩进,你的配置里有两处缩进不合法:

  • 第二个构建项(id为solc)中,goarch字段在goos字段下多缩进了2个空格,二者属于同级配置,缩进量必须一致
  • 第二个归档配置项中,id、builds、replacements三个字段在format: zip下多缩进了2个空格,和format属于同级配置,缩进量必须一致
    报错提示的line26正好对应第一处缩进错误的位置。

修正后的完整 .goreleaser.yml 配置

before:
  hooks:
    - go mod tidy

builds:
  - main: cmd/gsolc-select/main.go
    binary: gsolc-select
    id: gsolc-select-cli
    env:
      - CGO_ENABLED=0
    goos: [ windows,linux,darwin ]
    goarch: [ amd64,386,arm,arm64 ]
    ignore:
      - goos: darwin
        goarch: 386
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: arm64
    flags:
      - -trimpath

  - main: cmd/solc/main.go
    binary: solc
    id: solc
    env:
      - CGO_ENABLED=0
    goos: [ windows,linux,darwin ]
    goarch: [ amd64,386,arm,arm64 ]
    ignore:
      - goos: darwin
        goarch: 386
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: arm64

archives:
  - format: zip
    id: gsolc-select
    builds: [ gsolc-select-cli ]
    replacements:
      darwin: macOS

  - format: zip
    id: solc
    builds: [ solc ]
    replacements:
      darwin: macOS

checksum:
  algorithm: sha256

补充说明

  • 你的.github/workflows/release.yml工作流配置没有问题,GitHub自动生成的secrets.GITHUB_TOKEN默认具备仓库发布权限,不需要手动额外配置自定义Token
  • 配置修改后可以先在本地执行goreleaser check命令校验配置合法性,确认无语法错误后再推送标签触发工作流即可正常发布。

内容的提问来源于stack exchange,提问作者fabelx

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 17:18:42