How to goreleaser to build sub-folder in github

huangapple go评论74阅读模式
英文:

How to goreleaser to build sub-folder in github

问题

我在 GitHub Action 中使用 goreleaser 进行构建。
因为我的 main.go 文件位于 ./cmd/tes_cli 目录下,在 GitHub Action 中经常出现错误。

repo does not contain a main function.

我查看了原始文档,似乎可以使用 "builds" 来解决。但是我的配置中无法添加 builds

name: Release Go project

on:
  push:
    tags:
      - "*" # 仅在推送新的标签版本时触发,例如 `0.8.4` 或其他版本

jobs:
  build:
    name: GoReleaser build
    runs-on: ubuntu-latest

    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v2
        with:
          fetch-depth: 0 # 参考:https://goreleaser.com/ci/actions/

      - name: Set up Go 1.14
        uses: actions/setup-go@v2
        with:
          go-version: 1.14
        id: go

      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@master
        with:
          version: latest
          args: release --rm-dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
英文:

I use goreleaser to build in github action.
Because my main.go in ./cmd/tes_cli, it always show error in github action.

repo does not contain a main function.

I check the original document, it seems "builds" could works. my configuration could not add builds

name: Release Go project

on:
  push:
    tags:
      - "*" # triggers only if push new tag version, like `0.8.4` or else

jobs:
  build:
    name: GoReleaser build
    runs-on: ubuntu-latest

    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v2
        with:
          fetch-depth: 0 # See: https://goreleaser.com/ci/actions/

      - name: Set up Go 1.14
        uses: actions/setup-go@v2
        with:
          go-version: 1.14
        id: go

      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@master
        with:
          version: latest
          args: release --rm-dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

答案1

得分: 3

添加一个额外的配置文件来解决这个问题。

请参考 https://github.com/kkdai/disqus-importor-go/pull/4/files

args: release -f .goreleaser.yml --rm-dist

链接到另一个配置文件。

# .goreleaser.yml
project_name: import_disqus_cli
builds:
  - env: [CGO_ENABLED=0]
    goos:
      - linux
      - windows
      - darwin
    goarch:
      - amd64
      - arm64
    id: "import_disqus_cli"
    dir: .
    main: ./cmd/test_cli

英文:

Add an extra configuration file to resolve it.

Refer https://github.com/kkdai/disqus-importor-go/pull/4/files

args: release -f .goreleaser.yml --rm-dist

link to another config file.

# .goreleaser.yml
project_name: import_disqus_cli
builds:
  - env: [CGO_ENABLED=0]
    goos:
      - linux
      - windows
      - darwin
    goarch:
      - amd64
      - arm64
    id: "import_disqus_cli"
    dir: .
    main: ./cmd/test_cli

huangapple
  • 本文由 发表于 2021年5月23日 03:38:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/67653504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定