英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论