Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building and Releasing Golang binaries

Building and Releasing Golang binaries

Avatar for Carlos Alexandro Becker

Carlos Alexandro Becker

September 21, 2017
Tweet

More Decks by Carlos Alexandro Becker

Other Decks in Technology

Transcript

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

    @caarlos0 on twitter, github, etc ▸ Writing stuff in Go since ~2015
  2. 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
 ...
  3. RELEASING LINUX PACKAGES ▸ DEB and RPM packages ▸ fpm

    --a-thousand-params ▸ Snaps ▸ snapcraft --another-thousand-params config.yml
  4. 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
  5. 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
  6. RELEASING GITHUB RELEASES ▸ git tag && git push ▸

    Upload artifacts ▸ Generate and upload checksums maybe ▸ Edit the release notes
  7. TEXT RELEASING MY GO APP THE FIRST TIME: ▸ Tag

    ▸ Cross compile ▸ Checksums ▸ Release notes ▸ .deb, .rpm, .snap ▸ docker images ▸ Upload ▸ Update homebrew tap
  8. TEXT RELEASING MY GO APP FOR THE 10TH TIME: ▸

    Tag ▸ Cross compile ▸ Checksums ▸ Release notes ▸ .deb, .rpm, .snap ▸ docker images ▸ Upload ▸ Update homebrew tap
  9. 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
  10. 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
  11. GORELEASER INIT ▸ goreleaser init ▸ vim .goreleaser.yml ▸ git

    add .goreleaser.yml ▸ git commit -m 'goreleaser setup!'
  12. GORELEASER CI INTEGRATION ▸ after_success:
 test -n "$TRAVIS_TAG" && curl

    -fsL https://git.io/goreleaser | bash ▸ Push the tag ▸ Drink some coffee
  13. 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
  14. "THATS NICE, BUT NO ONE WILL GIVE A CRAP ABOUT

    IT ANYWAY..." Carlos Becker TEXT
  15. 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