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

private_homebrew_20170525.pdf

5ade34f8bdf1b55c4ff82c11cf23cf42?s=47 Masayuki Morita
May 25, 2017
23

 private_homebrew_20170525.pdf

5ade34f8bdf1b55c4ff82c11cf23cf42?s=128

Masayuki Morita

May 25, 2017
Tweet

Transcript

  1. ඇެ։ͳࣾ಺ݶͷCLIπʔϧΛ HomebrewͰ഑෍͍ͨ͠ 2017/05/25 @minamijoyo

  2. ࣗݾ঺հ • ৿ా ਅ೭ (Masayuki Morita) • Twitter/GitHub: @minamijoyo •

    CrowdWorks Inc. • Πϯϑϥ୲౰ • ͍͍ͩͨAWS/Terraform/Dockerͱ͔͍ͬͯ͡Δ
  3. ࠓ೔ͷςʔϚ

  4. ࣾ಺ݶͷCLIπʔϧͷ഑෍ํ๏

  5. ίϯςΩετ • ࣾ಺αʔόʹHTTPϦΫΤετΛ౤͛Δͪΐͬͱ͠ ͨࣾ಺ݶͷCLIπʔϧΛॻ͖͍ͨ • CLIπʔϧΛॻ͘ͳΒGo (※ݸਓͷײ૝Ͱ͢) • ͨͩࣾ͠಺શһ͕Goͷ։ൃ؀ڥΛ͍࣋ͬͯΔΘ͚ Ͱ͸ͳ͍ͷͰgit

    cloneͯ͠Ϗϧυͱ͔͸μϝ • ίϯύΠϧࡁͷόΠφϦΛ഑෍͍ͨ͠
  6. ʢͦ΋ͦ΋ʣ OSSͰެ։͢Δ৔߹

  7. GitHub Releaseϖʔδʹ ϏϧυࡁΈͷόΠφϦΛ ஔ͍͓ͯ͘ͷ͕؆୯

  8. None
  9. curlͷϫϯϥΠφʔͰ μ΢ϯϩʔυͯ͠΋Β͏ $ curl -fsSL https://github.com/ minamijoyo/myaws/releases/download/ v0.3.0/myaws_v0.3.0_darwin_amd64.tar.gz \ |

    tar -xzC /usr/local/bin && chmod +x /usr/local/bin/myaws
  10. ඇެ։ͳ ࣾ಺ݶͷCLIπʔϧͷ৔߹

  11. GitHubͷAPIτʔΫϯ࢖ͬͯ ͜Μͳ͔Μ͡Ͱ͍͚ͦ͏ʁ $ curl -fsSL https://GITHUB_TOKEN@github.com/ yourcompany/hoge/releases/download/v0.1.0/ hoge_v0.1.0_darwin_amd64.tar.gz curl: (22)

    The requested URL returned error: 404 Not Found
  12. ਖ਼ղ͸…

  13. $ curl -sLJO -H 'Accept: application/octet-stream' \ "https://$GITHUB_TOKEN@api.github.com/repos/ yourcompany/hoge/releases/assets/$( \

    curl -sL https://$GITHUB_TOKEN@api.github.com/ repos/yourcompany/hoge/releases/tags/v0.1.0 \ | jq '.assets[] | select(.name | contains("darwin")) | .id')" GitHub APIΛ࢖ͬͯ curl+jqͰ͕Μ͹Δ
  14. ͳΔ΄ͲΘ͔ΒΜ

  15. ΋ͬͱ͍͍͔Μ͡ͰཔΉ

  16. Homebrew

  17. ࣗ࡞πʔϧΛ HomebrewͰ഑෍͢Δ

  18. OSSͰެ։͢Δ৔߹

  19. require "formula" class Myaws < Formula homepage "https://github.com/minamijoyo/myaws" url "https://github.com/minamijoyo/myaws/releases/download/

    v0.3.0/myaws_v0.3.0_darwin_amd64.tar.gz" sha256 "a2d9bccb4d95556b81d50bb7338dc12815acb0b4e19e28adff1a235b0a44fca4" head "https://github.com/minamijoyo/myaws.git" version "0.3.0" def install bin.install "myaws" end end brew tap༻ͷFormulaΛ࡞੒
  20. brew tap༻ͷϦϙδτϦΛ࡞੒ ˞CSFXUBQ༻ͷϦϙδτϦ໊͸ IPNFCSFX9999Ͱͳ͍ͱ͍͚ͳ͍͜ͱʹ஫ҙ

  21. $ brew install minamijoyo/myaws/myaws $ brew tap minamijoyo/myaws $ brew

    install myaws ΋͘͠͸ߦͰ·ͱΊͯ CSFXUBQͯ͠JOTUBMM
  22. ඇެ։ͳ ࣾ಺ݶͷCLIπʔϧͷ৔߹

  23. HomebrewͰ Ͳ͏͢Ε͹Α͍͔ͳʁͱ υΩϡϝϯτ΍ίʔυΛಡΜͩͱ͜Ζ…

  24. Homebrewʹ ͦΜͳػೳ͸ͳ͔ͬͨ (׬)

  25. ͱݟ͔͚ͤͯ

  26. ͳ͔ͬͨͷͰ Homebrewຊମʹ ػೳΛ௥Ճ͠ͱ͍ͨ

  27. IUUQTHJUIVCDPN)PNFCSFXCSFXQVMM

  28. ࢖͍ํ

  29. require "formula" class Hoge < Formula homepage "https://github.com/yourcompany/hoge" url "https://github.com/yourcompany/hoge/releases/

    download/v0.1.0/hoge_v0.1.0_darwin_amd64.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy sha256 "6de411ff3e4b1658a413dd6181fcXXXXXXXXXXXXXXXXXXXX" head "https://github.com/yourcompany/hoge.git" version "0.1.0" def install bin.install "hoge" end end FormulaͷurlઃఆͰ GitHubPrivateRepositoryReleaseDownloadStrategyΛࢦఆ
  30. $ brew tap yourcompany/tap git@github.com:yourcompany/homebrew-tap.git CSFXUBQͷϦϙδτϦ΋ඇެ։ͳͷͰ ύεΛHJUϓϩτίϧࢦఆͯ͠44)ೝূ͢Δ $ brew tap

    yourcompany/tap https://$TOKEN@github.com/yourcompany/ homebrew-tap.git ˞CSFXUBQͷϦϙδτϦΛIUUQTͰ (JU)VCτʔΫϯͰೝূ͍ͨ͠৔߹͸ҎԼͰ΋Մ
  31. $ export HOMEBREW_GITHUB_API_TOKEN=xxx ϦϦʔε෺Λμ΢ϯϩʔυ͢ΔͨΊʹ πʔϧͷϦϙδτϦʹΞΫηεݖݶ͕͋ΔτʔΫϯΛ )0.&#3&8@(*5)6#@"1*@50,&/ʹFYQPSU $ brew install hoge

    ͜ΕͰඇެ։ͳπʔϧ΋CSFXJOTUBMMͰ͖ΔΑ͏ʹͳΔ
  32. આ໌͕ૣ͗ͯ͢෼͔ΒΜ͔ͬͨਓ޲͚ˣ ʮHomebrewͰϓϥΠϕʔτͳGitHubϦϙδτ ϦͷReleaseϖʔδ͔Βࣾ಺πʔϧΛ഑෍͢Δʯ http://qiita.com/minamijoyo/items/ 8bb3c80974b77b8ae81f

  33. Ͳ͏ͧ͝ར༻Լ͍͞ (׬)