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

Wacker#2 GithubとTravis CIを使った継続的なタグ付きリリース/cont...

Wacker#2 GithubとTravis CIを使った継続的なタグ付きリリース/continuous tagged release with Github and Travis CI.

Wacker#2で話題提供したスライドです。GithubとTravis CIを使って、リリースのタグ管理を自動化します。

KamataRyo

May 22, 2016
Tweet

More Decks by KamataRyo

Other Decks in Technology

Transcript

  1. NBTUFSϒϥϯν CoffeeScript SASS HTML package.json bower.json !JavaScript !CSS !node_modules !bower_components

    ϩʔΧϧϦϙδτϦ ! gitignored ྫ͑͹8FC։ൃͷϦϙδτϦ w ։ൃ؀ڥ͕(SVOUɺ(VMQɺͦΕΒͷϓϥάΠϯͳ ͲͷOQNΛؚΉ w ΫϥΠΞϯταΠυͷϥΠϒϥϦ͸#PXFSͰ؅ཧ w $P⒎FF4DSJQUɾ4"44͔Β+BWB4DSJQUɾ$44Λ ίϯύΠϧ w FUD w ίϯύΠϧޙͷϑΝΠϧ͸HJUJHOPSF
  2. $ git tag v1.0.x $ git push origin v1.0.x $

    git diff —name-status master v1.0.x M HTML M CoffeeScript M SASS M package.json M bower.json ͦͷ··λάΛϓογϡ͢Δͱ w ະίϯύΠϧ w ༨ܭͳϑΝΠϧΛؚΉ
  3. ϦϦʔεϖʔδ͔Β͸ ίϯύΠϧޙͷϑΝΠϧͷΈΛ഑෍͍ͨ͠ +BWB4DSJQUɺ$44ɺ)5.-ɺόϯυϧ͞ΕͨϥΠϒϥϦ $ git tag v1.0.x $ git push

    origin v1.0.x $ git diff —name-status master v1.0.x # ๬·͍ࠩ͠෼ M HTML A JavaScript A CSS A node_modules A bower_components D CoffeeScript D SASS D package.json D bower.json
  4. NBTUFSϒϥϯν NBTUFSϒϥϯν CoffeeScript SASS HTML package.json !bower.json !JavaScript !CSS !node_modules

    bower_components SFMFBTFϒϥϯν ϩʔΧϧϦϙδτϦ ϦϞʔτϦϙδτϦ CoffeeScript SASS HTML package.json bower.json HTML JavaScript CSS node_modules bower_components ! gitignored
  5. $ more ./.travis.yml language: node_js node: - 0.10 - 0.11

    branches: only: - master # masterϒϥϯνʹ൓Ԡ - /^v?[0-9](\.[0-9])*/ # λάͷpushʹ΋൓Ԡ env: global: - GH_REF: github.com/user/repo.git - secure: “gWwMOgIBTvzbTN…” # GH_TOKEN # ଓ͘ 5SBWJT$*ͷઃఆ 
  6. # ଓ͖ before_script: - npm install - npm run build

    # Ϗϧυ script: - npm test # ςετ after_success: - bash bin/deploy.sh # σϓϩΠ 5SBWJT$*ͷઃఆ 
  7. $ more ./bin/deploy.sh set -e # Τϥʔ͕ग़ͨΒࢭΊΔ if [[ "false"

    != "$TRAVIS_PULL_REQUEST" ]]; then exit # ϓϧϦΫΤετʹରͯ͠͸σϓϩΠ͠ͳ͍ elif ! [[ "master" == "$TRAVIS_BRANCH" ]]; then if [[ "" == "$TRAVIS_TAG" ]]; then exit # ϚελʔϒϥϯνҎ֎Ͱλά͕ͳ͍࣌σϓϩΠ͠ͳ͍ fi fi # ଓ͘ σϓϩΠ༻γΣϧεΫϦϓτ  σϓϩΠํ๏͸pSFHPCZKQ͞ΜͷهࣄΛࢀߟʹ͠·ͨ͠ɻ
  8. # ଓ͖ rm -rf .git # gitͷϑΥϧμΛશফڈ echo "CSS CoffeeScript

    package.json bower.json" > .gitignore # ෆཁͳϑΝΠϧΛignore # =====͜͜·ͰͰ׬શͳύοέʔδ͕׬੒===== # Travis CIଆͰͷgitͷઃఆ git init git config user.name "user" git config user.email “[email protected]" # ଓ͘ σϓϩΠ༻γΣϧεΫϦϓτ 
  9. # ଓ͖ # ϦϦʔε༻ͷύοέʔδΛίϛοτ git add . git commit -m

    "Deploy from travis." # ଓ͘ σϓϩΠ༻γΣϧεΫϦϓτ 
  10. # ଓ͖ # master΁ͷpushͩͬͨ৔߹ɺ'latest'ͱ͍͏branch΁ڧ੍push͢Δ # Τϥʔ࣌ʹΞΫηετʔΫϯ͕ग़ྗ͞Εͳ͍Α͏ʹ͢Δ if [[ "master" ==

    "$TRAVIS_BRANCH" ]]; then git push --force --quiet \ "https://${GH_TOKEN}@${GH_REF}" master:latest \ > /dev/null 2>&1 fi # ଓ͘ σϓϩΠ༻γΣϧεΫϦϓτ 
  11. # ଓ͖ # λάͷpushͩͬͨ৔߹ɺϦϦʔε಺༰Λڧ੍తʹॻ͖׵͑Δ if ! [[ "" == "$TRAVIS_TAG"

    ]]; then # tagΛ࡟আ git push --force --quiet \ "https://${GH_TOKEN}@${GH_REF}" “:$TRAVIS_TAG” \ > /dev/null 2>&1 # վΊͯtagΛpush git tag "$TRAVIS_TAG" git push --force --quiet --tag \ "https://${GH_TOKEN}@${GH_REF}" “$option" \ > /dev/null 2>&1 # Τϥʔ࣌ʹGH_TOKEN͕ग़ྗ͞Εͳ͍Α͏ʹ͢Δ fi σϓϩΠ༻γΣϧεΫϦϓτ