Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ship your CLI tool built by golang to your user...
Search
taichi nakashima
August 09, 2014
6.9k
11
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ship your CLI tool built by golang to your user #golangstudy
http://connpass.com/event/7814/
taichi nakashima
August 09, 2014
More Decks by taichi nakashima
See All by taichi nakashima
Platform Engineering at Mercari (Platform Engineering Kaigi 2024)
tcnksm
6
5.7k
Platform Engineering at Mercari
tcnksm
8
5.9k
Embedded SRE at Mercari
tcnksm
0
1.6k
How We Harden Platform Security at Mercari
tcnksm
2
1.9k
SRE Practices in Mercari Microservices
tcnksm
11
15k
開発者向けの基盤をつくる
tcnksm
38
12k
How We Structure Our Work At Mercari Microservices Platform Team
tcnksm
11
24k
Microservices Platform on Kubernetes at Mercari
tcnksm
16
17k
Introduction to Mercari Micorservices Platform Team
tcnksm
5
3.7k
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
55
12k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
240
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Statistics for Hackers
jakevdp
799
230k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
WCS-LA-2024
lcolladotor
0
790
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
200
Docker and Python
trallard
47
4.1k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
160
Tell your own story through comics
letsgokoyo
1
1k
Transcript
Ship your CLI tool built by Golang: Compile, Release, Downloading
http://wallbase.cc/wallpaper/1950578
I’m Taichi Nakashima @deeeet tcnksm
http://deeeet.com/writing
YAPC::Asia Tokyo 2014 2014-08-29 14:10:00
ghr dmux https://github.com/tcnksm/dmux https://github.com/tcnksm/ghr - docker + tmux = dmux
! - Easy to ship your project on Github to your user cli-init https://github.com/tcnksm/cli-init - TheThe easy way to start building Golang CLI docc https://github.com/tcnksm/docc - docc open your project document ⋆ 100 ⋆ 38 ⋆ 39 ⋆ 7
TL;DR GoݴޠͰ࡞ͬͨCLIπʔϧΛΫʔϧʹship͠Α͏ʂ
I built Cool CLI tool ! Make your life easy,
Make you happy, Please use it !
Before Golang When you create great tool, and want to
ship it to user.
Lightweight Language • Python -> pip • Ruby -> rubygems
• Perl -> CPAN • Node -> npm
Lightweight Language • pipͬͯԿʁ • CPANͬͯԿʁ • ݁ہԿΛΠϯετʔϧ͢Εྑ͍ͷʁ • Rubyݏ͍͔ͩΒ…
After Golang When you create great tool, and want to
ship it to user.
Cross-Compile and Release it Download it and place it in
your $PATH
Super Easy, but • ޮΑ͘Cross-Compile͢Δʹʁ • ؆୯ʹϦϦʔε͢ΔʹʁͲ͜ʹϗετ͢Ε͍͍ͷʁ • ؆୯ͳΠϯετʔϧํ๏Λఏڙ͢Δʹʁ
Cross-Compiling generate binaries for multiple platform
Tools • davecheney/golang-crosscompile • bash࣮ • laher/goxc • ߴػೳ (ύοέʔδϯά,
bintrayͷΞοϓϩʔυ…) • mitchellh/gox • γϯϓϧ, ฒྻ࣮ߦ
$ GOOS=linux GOARCH=amd64 go build awesome-tool.go
$ gox ! --> darwin/386: github.com/tcnksm/awesome --> darwin/amd64: github.com/tcnksm/awesome -->
linux/386: github.com/tcnksm/awesome --> linux/amd64: github.com/tcnksm/awesome --> linux/arm: github.com/tcnksm/awesome --> freebsd/386: github.com/tcnksm/awesome --> freebsd/amd64: github.com/tcnksm/awesome --> openbsd/386: github.com/tcnksm/awesome
$ gox \ -os="darwin linux windows" \ -arch="386 amd64" \
-output "pkg/{{.OS}}_{{.Arch}}/{{.Dir}} " !
Releasing Upload artifacts on Github bintray.com, Drone.io
Hosting Services
$ echo “Releasing bintray with API” ! $ curl -T
${FILE.EXT} \ -u${USER}:${API_KEY} \ https://api.bintray.com/content/${USER}/${NAME}/${FILE}
https://bintray.com/tcnksm/dmux/dmux/0.1.0/view/files
$ echo “Releasing Github with API” ! $ curl -X
POST -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${GITHUB_TOKEN}" \ -H "Content-Type: ${CONTENT_TYPE}" \ --data-binary @“${ARCHIVE}" \ https://uploads.github.com/repos/${OWNER}/${REPO}/ releases/${RELEASE_ID}/assets?name=${ARCHIVE_NAME} \
https://github.com/tcnksm/ghr/releases
ghr https://github.com/tcnksm/ghr - Easy to ship your project on Github
to your user
$ ghr v0.1.0 pkg/ ! --> Uploading: pkg/0.1.0_SHASUMS --> Uploading:
pkg/ghr_0.1.0_darwin_386.zip --> Uploading: pkg/ghr_0.1.0_darwin_amd64.zip --> Uploading: pkg/ghr_0.1.0_linux_386.zip --> Uploading: pkg/ghr_0.1.0_linux_amd64.zip --> Uploading: pkg/ghr_0.1.0_windows_386.zip --> Uploading: pkg/ghr_0.1.0_windows_amd64.zip
Release with CI-as-a-Service CI-as-a-ServiceͰςετͷ௨ͬͨͷΛίϯύΠϧͯ͠ Githubbintray, Drone.ioʹϦϦʔε͢Δ
developer Wercker Ͱ Go ͷϓϩδΣΫτΛΫϩείϯύΠϧ͠ɺGitHub ʹϦϦʔε͢Δ http://motemen.hatenablog.com/entry/2014/06/27/xcompile-go-and-release-to-github-with-wercker
developer Wercker Ͱ Go ͷϓϩδΣΫτΛΫϩείϯύΠϧ͠ɺGitHub ʹϦϦʔε͢Δ http://motemen.hatenablog.com/entry/2014/06/27/xcompile-go-and-release-to-github-with-wercker git push
developer Wercker Ͱ Go ͷϓϩδΣΫτΛΫϩείϯύΠϧ͠ɺGitHub ʹϦϦʔε͢Δ http://motemen.hatenablog.com/entry/2014/06/27/xcompile-go-and-release-to-github-with-wercker git push hook
developer Wercker Ͱ Go ͷϓϩδΣΫτΛΫϩείϯύΠϧ͠ɺGitHub ʹϦϦʔε͢Δ http://motemen.hatenablog.com/entry/2014/06/27/xcompile-go-and-release-to-github-with-wercker git push hook
Test & Cross-Compile
developer Wercker Ͱ Go ͷϓϩδΣΫτΛΫϩείϯύΠϧ͠ɺGitHub ʹϦϦʔε͢Δ http://motemen.hatenablog.com/entry/2014/06/27/xcompile-go-and-release-to-github-with-wercker git push hook
Release ! Test & Cross-Compile
Downloading Give more easy way to install your tool
Download and place it in $PATH ! े͕ͩϢʔβʹͱͬͯΊΜͲ͍͘͞ɽ ͬͱ؆୯ʹπʔϧΛΠϯετʔϧ͢ΔͨΊͷखஈΛఏڙ͍ͨ͠ɽ Ϣʔβ͕πʔϧΛ͍࢝ΊΔ·ͰͷোนΛԼ͛Α͏ʂ
Package manager? • OSX → Homebrew • Debian→ Deb package
• RedHat → RPM package
Redirect distribution pattern • heroku/hk • flynn/flynn-cli
$ L=/usr/local/bin/hk && curl -sL -A "`uname -sp`" https:// hk.heroku.com/hk.gz
| zcat >$L && chmod +x $L
user HerokuͱGithubΛͬͨ౷Ұతͳπʔϧ http://deeeet.com/writing/2014/08/07/github-heroku-dist/
user • darwin_386.zip • darwin_amd64.zip • linux_386.zip • linux_amd64.zip …
HerokuͱGithubΛͬͨ౷Ұతͳπʔϧ http://deeeet.com/writing/2014/08/07/github-heroku-dist/
user curl -sL -A `uname -sp` HerokuͱGithubΛͬͨ౷Ұతͳπʔϧ http://deeeet.com/writing/2014/08/07/github-heroku-dist/ • darwin_386.zip
• darwin_amd64.zip • linux_386.zip • linux_amd64.zip …
user curl -sL -A `uname -sp` Detect platform HerokuͱGithubΛͬͨ౷Ұతͳπʔϧ http://deeeet.com/writing/2014/08/07/github-heroku-dist/
• darwin_386.zip • darwin_amd64.zip • linux_386.zip • linux_amd64.zip …
user curl -sL -A `uname -sp` redirect Detect platform HerokuͱGithubΛͬͨ౷Ұతͳπʔϧ
http://deeeet.com/writing/2014/08/07/github-heroku-dist/ • darwin_386.zip • darwin_amd64.zip • linux_386.zip • linux_amd64.zip …
user curl -sL -A `uname -sp` redirect package Detect platform
HerokuͱGithubΛͬͨ౷Ұతͳπʔϧ http://deeeet.com/writing/2014/08/07/github-heroku-dist/ • darwin_386.zip • darwin_amd64.zip • linux_386.zip • linux_amd64.zip …
re-dist-ghr https://github.com/tcnksm/re-dist-ghr - Redirect installation for ghr
require "formula" ! class Ghr < Formula homepage "https://github.com/tcnksm/ghr" version
'v0.1.1' url "https://github.com/tcnksm/ghr/releases/download/v0.1.1/ghr_v0.1.1_darwin_amd64.zip" sha1 “e5c793001f004b670df77cb57bc033c89201b485" ! depends_on :arch => :intel ! def install bin.install 'ghr' end end $ cat homebrew-ghr/ghr.rb
$ brew tap tcnksm/ghr $ brew install ghr
Demo