douhuan1937 2019-09-05 13:55 采纳率: 0%
浏览 429
已采纳

如何制作goreleaser脚本以在本地构建deb文件?

I am an absolute novice in Golang but I want to modify a Go build script to build a file locally only instead of publishing it to GitHub.

https://github.com/dahendel/docker-machine-driver-cloudstack/blob/master/.goreleaser.yml

How to proceed?

  • 写回答

1条回答 默认 最新

  • doumanju2533 2019-09-06 11:04
    关注

    I have cloned your repo and try that in my local machine. Here is the steps :

    1. Git clone

    2. executing Dry run (testing everything before doing a release "for real" :

      $ goreleaser release --skip-publish

    3. show there is no error

       SIGNING ARTIFACTS
        • pipe skipped              error=artifact signing is disabled
      • DOCKER IMAGES
        • pipe skipped              error=docker section is not configured
      • PUBLISHING
        • pipe skipped              error=publishing is disabled
      • release succeeded after 20.75s
      
      
    4. execute goreleaser for release

      $ goreleaser release

    5. goreleaser will created dist folder inside project and this folder will consist of distribution packages (deb, rpm).

    I have encounter some issues and here is what I do :

    • error=missing GITHUB_TOKEN, GITLAB_TOKEN and GITEA_TOKEN

    create github or gitlab token ( https://github.com/settings/tokens) and put it as environment variabel

    export GITHUB_TOKEN=xxxxyyyyyzzzzz
    

    resolve the issue.

    • pre hook failed: xxxx is not within a known GOPATH/src

    as I see in your goreleaser.yaml

    hooks:
    pre: dep ensure
    

    you're using dep ensure, checking $GOPATH and make sure $GOPATH pointing to right path of your Go project.

    • error=dist is not empty, remove it before running goreleaser or use the --rm-dist flag

    dist folder has been created before, you can either manually delete the folder or add flags --rm-dist when executing goreleaser command

    $ goreleaser release --skip-publish --rm-dist
    
    • error=nfpm failed: rpmbuild not present in $PATH

    this error occured as I was running on mac machine so there is no rpmbuild installed, installing rpm, rpmbuild solve the issue

    $brew install rpm
    
    • error=git is currently in a dirty state, please check in your pipeline what can be changing the following files: M Gopkg.lock

    Goreleaser seems to check file diff, so as because running hook (dep ensure) updating the Gopkg.lock and this changes/updates are not pushed to git. The solution is always pushing the changes to git.

    • error=git tag v1.0.5 was not made against commit 3ae83eebd904d33cc549117254e857ebea04df90

    reading from GoReleaser documentation which is "GoReleaser enforces semantic versioning and will error on non-compliant tags. Your tag should be a valid semantic version. If it is not, GoReleaser will error."

    after pushing to git, make sure you have to update the tags, in this case I updates the tags to v1.0.6 (previously v1.0.5).

    make sure release text is there.

    Hope that helps

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)