From 5618fa99019fa1d77c886d2e378fb2443b569961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=95=E6=8C=81=20=E5=8A=9B=E5=93=89?= Date: Tue, 14 May 2019 12:13:11 +0900 Subject: [PATCH 1/2] Add auto deploy code. --- .circleci/config.yml | 25 +++++++++++++++++++++++-- .circleci/deploy_to_rubygems.sh | 14 ++++++++++++++ .circleci/setup_rubygems.sh | 3 +++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .circleci/deploy_to_rubygems.sh create mode 100644 .circleci/setup_rubygems.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 03e2242..2fa631a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,7 +54,20 @@ jobs: - run: bundle exec rubocop -f html --out report.html - store_artifacts: path: report.html - + publish: + docker: + - image: circleci/ruby:2.4.1 + steps: + - add_ssh_keys: + finerprints: + - "da:94:86:ae:c5:5c:23:4e:50:84:97:0f:24:bf:48:f9" + - checkout + - run: + name: Setup Rubygems + command: bash .circleci/setup_rubygems.sh + - run: + name: Update vresion.rb and publish on RubyGems + command: bash .circleci/deploy_to_rubygems.sh workflows: version: 2 test: @@ -63,4 +76,12 @@ workflows: - system_test lint: jobs: - - syntax_check \ No newline at end of file + - syntax_check + deploy: + jobs: + - publish: + filters: + tags: + only: /^v[0-9]{1,}(\.[0-9]{1,}){2}$/ + branches: + ignore: /.*/ \ No newline at end of file diff --git a/.circleci/deploy_to_rubygems.sh b/.circleci/deploy_to_rubygems.sh new file mode 100644 index 0000000..209d33a --- /dev/null +++ b/.circleci/deploy_to_rubygems.sh @@ -0,0 +1,14 @@ +VERSION=$(git describe --tags | sed -e 's/^v//') +git config user.email "bucky-operator@users.noreply.github.com" +git config user.name "bucky-operator" +# Update version.rb +sed -i -e "s/VERSION = \"[0-9]\{1,\}.[0-9]\{1,\}.[0-9]\{1,\}\"/VERSION = \"$VERSION\"/" lib/bucky/version.rb +git diff +git checkout master +git add lib/bucky/version.rb +git commit -m "Version $VERSION" +# Build and release gem +gem build bucky-core.gemspec +gem push "bucky-core-$VERSION.gem" +# Push to master +git push origin master \ No newline at end of file diff --git a/.circleci/setup_rubygems.sh b/.circleci/setup_rubygems.sh new file mode 100644 index 0000000..af7fa01 --- /dev/null +++ b/.circleci/setup_rubygems.sh @@ -0,0 +1,3 @@ +mkdir ~/.gem +echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials +chmod 0600 /home/circleci/.gem/credentials \ No newline at end of file From ab4ec1098b4197c644b85a255c13771a1f444b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=95=E6=8C=81=20=E5=8A=9B=E5=93=89?= Date: Tue, 14 May 2019 15:52:24 +0900 Subject: [PATCH 2/2] Fix for review. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2fa631a..62ed8f4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,7 +60,7 @@ jobs: steps: - add_ssh_keys: finerprints: - - "da:94:86:ae:c5:5c:23:4e:50:84:97:0f:24:bf:48:f9" + - "6a:f3:d3:b5:a5:da:ce:e0:9f:22:f8:4a:2f:51:67:2b" - checkout - run: name: Setup Rubygems