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

private_homebrew_20170525.pdf

Masayuki Morita
May 25, 2017
39

 private_homebrew_20170525.pdf

Masayuki Morita

May 25, 2017
Tweet

Transcript

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

    View full-size slide

  2. ࣗݾ঺հ
    • ৿ా ਅ೭ (Masayuki Morita)
    • Twitter/GitHub: @minamijoyo
    • CrowdWorks Inc.
    • Πϯϑϥ୲౰
    • ͍͍ͩͨAWS/Terraform/Dockerͱ͔͍ͬͯ͡Δ

    View full-size slide

  3. ࠓ೔ͷςʔϚ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  6. ʢͦ΋ͦ΋ʣ
    OSSͰެ։͢Δ৔߹

    View full-size slide

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

    View full-size slide

  8. 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

    View full-size slide

  9. ඇެ։ͳ
    ࣾ಺ݶͷCLIπʔϧͷ৔߹

    View full-size slide

  10. GitHubͷAPIτʔΫϯ࢖ͬͯ
    ͜Μͳ͔Μ͡Ͱ͍͚ͦ͏ʁ
    $ curl -fsSL https://[email protected]/
    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

    View full-size slide

  11. $ curl -sLJO -H 'Accept: application/octet-stream' \
    "https://[email protected]/repos/
    yourcompany/hoge/releases/assets/$( \
    curl -sL https://[email protected]/
    repos/yourcompany/hoge/releases/tags/v0.1.0 \
    | jq '.assets[] | select(.name |
    contains("darwin")) | .id')"
    GitHub APIΛ࢖ͬͯ
    curl+jqͰ͕Μ͹Δ

    View full-size slide

  12. ͳΔ΄ͲΘ͔ΒΜ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. OSSͰެ։͢Δ৔߹

    View full-size slide

  16. 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Λ࡞੒

    View full-size slide

  17. brew tap༻ͷϦϙδτϦΛ࡞੒
    ˞CSFXUBQ༻ͷϦϙδτϦ໊͸
    IPNFCSFX9999Ͱͳ͍ͱ͍͚ͳ͍͜ͱʹ஫ҙ

    View full-size slide

  18. $ brew install minamijoyo/myaws/myaws
    $ brew tap minamijoyo/myaws
    $ brew install myaws
    ΋͘͠͸ߦͰ·ͱΊͯ
    CSFXUBQͯ͠JOTUBMM

    View full-size slide

  19. ඇެ։ͳ
    ࣾ಺ݶͷCLIπʔϧͷ৔߹

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  22. ͱݟ͔͚ͤͯ

    View full-size slide

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

    View full-size slide

  24. IUUQTHJUIVCDPN)PNFCSFXCSFXQVMM

    View full-size slide

  25. 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Λࢦఆ

    View full-size slide

  26. $ brew tap yourcompany/tap [email protected]:yourcompany/homebrew-tap.git
    CSFXUBQͷϦϙδτϦ΋ඇެ։ͳͷͰ
    ύεΛHJUϓϩτίϧࢦఆͯ͠44)ೝূ͢Δ
    $ brew tap yourcompany/tap https://[email protected]/yourcompany/
    homebrew-tap.git
    ˞CSFXUBQͷϦϙδτϦΛIUUQTͰ
    (JU)VCτʔΫϯͰೝূ͍ͨ͠৔߹͸ҎԼͰ΋Մ

    View full-size slide

  27. $ export HOMEBREW_GITHUB_API_TOKEN=xxx
    ϦϦʔε෺Λμ΢ϯϩʔυ͢ΔͨΊʹ
    πʔϧͷϦϙδτϦʹΞΫηεݖݶ͕͋ΔτʔΫϯΛ
    )0.&8@(*5)6#@"1*@50,&/ʹFYQPSU
    $ brew install hoge
    ͜ΕͰඇެ։ͳπʔϧ΋CSFXJOTUBMMͰ͖ΔΑ͏ʹͳΔ

    View full-size slide

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

    View full-size slide

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

    View full-size slide