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

如何制作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 有没有办法利用libusb读取usb设备数据
  • ¥15 为什么openeluer里面按不了python3呢?
  • ¥15 关于#matlab#的问题:训练序列与输入层维度不一样
  • ¥15 关于Ubuntu20.04.3LTS遇到的问题:在安装完CUDA驱动后,电脑会进入卡死的情况,但可以通过键盘按键进入安全重启,但重启完又会进入该情况!
  • ¥15 关于#嵌入式硬件#的问题:树莓派第一天重装配置python和opencv后第二天打开就成这样,瞎捣鼓搞出来文件夹还是没把原来的界面调回来
  • ¥20 Arduino 循迹小车程序电路出错故障求解
  • ¥20 Arduino 循迹小车程序电路出错故障求解
  • ¥15 C++数组中找第二小的数字程序纠错
  • ¥15 wannier复现图像时berry曲率极值点与高对称点严重偏移
  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)