Building and Releasing Golang binaries

Building and Releasing Golang binaries

7ef3cd04888c6d17f34d43e29ec3d46f?s=128

Carlos Alexandro Becker

September 21, 2017
Tweet

Transcript

  1. BUILDING AND RELEASING GOLANG BINARIES #1 CHANGELOG

  2. TEXT $ WHOAMI ▸ Site Reliability Engineer @ ContaAzul ▸

    @caarlos0 on twitter, github, etc ▸ Writing stuff in Go since ~2015
  3. BUILDING AND RELEASING GOLANG BINARIES #1 CHANGELOG

  4. TEXT AGENDA ▸ Building ▸ Releasing ▸ Automation ▸ Questions

  5. BUILDING

  6. BUILDING CROSS-COMPILING GO ▸ Go can build from and to

    basically any platform ▸ Statically linked binaries (no deps!!!) ▸ GOOS=windows GOARCH=amd64 go build -o blah_win64
 GOOS=linux GOARCH=amd64 go build -o blah_linux64
 GOOS=darwin GOARCH=amd64 go build -o blah_darwin64
 ...
  7. RELEASING

  8. RELEASING LINUX PACKAGES ▸ DEB and RPM packages ▸ fpm

    --a-thousand-params ▸ Snaps ▸ snapcraft --another-thousand-params config.yml
  9. RELEASING HOMEBREW ▸ Homebrew core ▸ Harder to get things

    in there: licensing, replicating dependencies into the recipe, etc ▸ brew install mytool ▸ Homebrew taps ▸ brew install caarlos0/tap/mytool
  10. RELEASING DOCKER ▸ FROM scratch
 COPY mybin /
 ENTRYPOINT ["/mybin"]

    ▸ docker build -t user/img:tag . ▸ docker tag user/img:tag user/img:latest ▸ docker push user/img:tag ▸ docker push user/img:latest
  11. RELEASING GITHUB RELEASES ▸ git tag && git push ▸

    Upload artifacts ▸ Generate and upload checksums maybe ▸ Edit the release notes
  12. "THE PROCESS"

  13. TEXT RELEASING MY GO APP THE FIRST TIME: ▸ Tag

    ▸ Cross compile ▸ Checksums ▸ Release notes ▸ .deb, .rpm, .snap ▸ docker images ▸ Upload ▸ Update homebrew tap
  14. HMM, THAT'S ACTUALLY NOT THAT BAD! Carlos Becker TEXT

  15. TEXT RELEASING MY GO APP FOR THE 10TH TIME: ▸

    Tag ▸ Cross compile ▸ Checksums ▸ Release notes ▸ .deb, .rpm, .snap ▸ docker images ▸ Upload ▸ Update homebrew tap
  16. None
  17. None
  18. None
  19. None
  20. ... Carlos Becker TEXT

  21. None
  22. None
  23. AUTOMATION INTENSIFIES

  24. TEXT ./RELEASE.SH ▸ Copy-paste all the commands in one file

    ▸ chmod +x ▸ ./release.sh
  25. TEXT ./RELEASE.SH ▸ No parallelism ▸ Every repo has its

    own release.sh ▸ GNU vs BSD coreutils aka "Works on my machine" ▸ Random deps or really hacky scripts
  26. None
  27. GORELEASER INTRODUCING

  28. GORELEASER FEATURES ▸ Checks git state ▸ Changelog between tags

    ▸ Builds for several platforms ▸ Archiving (tar.gz, zip) ▸ FPM, Snapcraft and Docker integration ▸ Homebrew taps ▸ Checksums ▸ Snapshots ▸ Fairly customisable
  29. GORELEASER INIT ▸ goreleaser init ▸ vim .goreleaser.yml ▸ git

    add .goreleaser.yml ▸ git commit -m 'goreleaser setup!'
  30. GORELEASER RELEASE PROCESS ▸ git tag x.y.z ▸ git push

    x.y.z ▸ goreleaser
  31. GORELEASER CI INTEGRATION ▸ after_success:
 test -n "$TRAVIS_TAG" && curl

    -fsL https://git.io/goreleaser | bash ▸ Push the tag ▸ Drink some coffee
  32. None
  33. None
  34. HOW IT WORKS

  35. None
  36. None
  37. None
  38. None
  39. GORELEASER WHY BOTHER ▸ Easy release process ▸ More releases

    ▸ Smaller changes ▸ Reproducible releases ▸ Fewer and more traceable bugs ▸ Same process across multiple repos ▸ Focus on your code
  40. STATS

  41. "THATS NICE, BUT NO ONE WILL GIVE A CRAP ABOUT

    IT ANYWAY..." Carlos Becker TEXT
  42. Generated with caarlos0/starcharts

  43. Generated with goreleaser/users

  44. THANKS!

  45. QUESTIONS?

  46. GORELEASER LINKS ▸ https://goreleaser.com ▸ #goreleaser on https://gophers.slack.com ▸ https://github.com/goreleaser/goreleaser

    ▸ https://github.com/goreleaser/users ▸ https://github.com/caarlos0/starcharts ▸ https://brew.sh ▸ http://snapcraft.io ▸ https://github.com/jordansissel/fpm