From e51f16c59119239bcce823c3a271f086ef86cfdf Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Mon, 30 Mar 2020 12:52:19 -0500 Subject: [PATCH 1/9] ci: add git to s3 script and CircleCI config --- .circleci/config.yml | 72 ++++++++++++++++++++++++++++++++++------- .circleci/svn-deploy.sh | 23 +++++++++++++ .svnignore | 1 + 3 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 .circleci/svn-deploy.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b0614d..d5f6a33 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,22 +1,72 @@ version: 2.1 -jobs: - test: +commands: + install_dependencies: + description: "Install development dependencies." + steps: + - run: composer install + +executors: + base: + docker: + - image: circleci/buildpack-deps:latest + working_directory: /tmp + php_node: docker: - image: circleci/php:7.3.3-stretch-node-browsers + working_directory: /tmp/src + +jobs: + checkout: + executor: base steps: - - checkout - - prepare-environment + - checkout: + path: src + - persist_to_workspace: + root: /tmp + paths: + - src + + standards: + executor: php_node + steps: + - attach_workspace: + at: /tmp + - install_dependencies - run: composer phpcs -commands: - prepare-environment: - description: "Install dependencies." - steps: - - run: composer install + deploy_svn: + executor: base + steps: + - attach_workspace: + at: /tmp + - run: + command: | + SLUG=grep 'Text Domain:' ./plugin.php | awk -F: '{print $2}' | sed 's/^\s//' + VERSION=grep 'Version:' ./plugin.php | awk -F: '{print $2}' | sed 's/^\s//' + chmod +x ./svn-deploy.sh + ./svn-deploy.sh workflows: version: 2 - check-wp-cs: + check-standards: jobs: - - test + - checkout: + filters: + tags: + only: /.*/ + - standards: + filters: + tags: + only: /.*/ + requires: + - checkout + - deploy_svn: + requires: + - checkout + - standards + filters: + tags: + only: /.*/ + branches: + only: master diff --git a/.circleci/svn-deploy.sh b/.circleci/svn-deploy.sh new file mode 100644 index 0000000..1e6f7f5 --- /dev/null +++ b/.circleci/svn-deploy.sh @@ -0,0 +1,23 @@ +#!/bin/bash +CURDIR=$(pwd); +TMPDIR=~/.plugin-release-script; + +mkdir $TMPDIR; +cd $TMPDIR; +svn co https://plugins.svn.wordpress.org/$SLUG --depth=empty .; +svn up trunk +svn up tags --depth=empty +cd trunk; +rm -rf * .* *.*; +### Clone the repo at the specific version tag +git clone --branch $VERSION git@github.com:$SLUG.git --depth 1 . +### This is where you would run any build commands +svn propset svn:ignore -F .svnignore .; +cd ../; +svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm; +svn add --force .; +svn cp trunk tags/$VERSION; +svn ci -m "Tagging $VERSION from Github" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD"; +cd $CURDIR; +rm -rf $TMPDIR; +echo 'Done!'; diff --git a/.svnignore b/.svnignore index b74f328..7a30b5e 100644 --- a/.svnignore +++ b/.svnignore @@ -3,3 +3,4 @@ .gitattributes .svnignore node_modules +.circlci From 258993ffaf08ae711dfe631e991ed3cb9664107b Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Mon, 30 Mar 2020 15:22:25 -0500 Subject: [PATCH 2/9] ci: include all deploy scripting in config --- .circleci/config.yml | 117 +++++++++++++++++++++++++++++++++++----- .circleci/svn-deploy.sh | 23 -------- 2 files changed, 104 insertions(+), 36 deletions(-) delete mode 100644 .circleci/svn-deploy.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index d5f6a33..cdd89bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,6 +5,54 @@ commands: description: "Install development dependencies." steps: - run: composer install + mkdir_artifacts: + description: "Make Artifacts directory" + steps: + - run: + command: | + [ ! -d "/tmp/artifacts" ] && mkdir /tmp/artifacts &>/dev/null + svn_setup: + description: "Setup SVN" + parameters: + slug: + type: string + steps: + - mkdir_artifacts + - run: + command: | + cd /tmp/artifacts + SLUG=grep 'Text Domain:' /tmp/src/plugin.php | awk -F: '{print $2}' | sed 's/^\s//' + svn co https://plugins.svn.wordpress.org/$SLUG --depth=empty . + svn up trunk + svn up tags --depth=empty + cd trunk + rm -rf * .* *.* + cp -r /tmp/src/* . + svn propset svn:ignore -F .svnignore . + svn_add_changes: + description: "Add changes to SVN" + steps: + - deply: + command: | + cd /tmp/artifacts + svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm + svn add --force . + svn_create_tag: + description: "Create a SVN tag" + steps: + - deploy: + command: | + cd /tmp/artifacts + VERSION=grep 'Version:' /tmp/src/plugin.php | awk -F: '{print $2}' | sed 's/^\s//' + svn cp trunk tags/$VERSION + svn_commit: + description: "Commit changes to SVN" + steps: + - deploy: + command: | + cd /tmp/artifacts + VERSION=grep 'Version:' /tmp/src/plugin.php | awk -F: '{print $2}' | sed 's/^\s//' + svn ci -m "Tagging $VERSION from Github" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" executors: base: @@ -27,46 +75,89 @@ jobs: paths: - src - standards: + checks: executor: php_node steps: - attach_workspace: at: /tmp - install_dependencies - run: composer phpcs + - persist_to_workspace: + root: /tmp + paths: + - src - deploy_svn: + deploy_svn_branch: executor: base steps: - attach_workspace: at: /tmp - - run: - command: | - SLUG=grep 'Text Domain:' ./plugin.php | awk -F: '{print $2}' | sed 's/^\s//' - VERSION=grep 'Version:' ./plugin.php | awk -F: '{print $2}' | sed 's/^\s//' - chmod +x ./svn-deploy.sh - ./svn-deploy.sh + - svn_setup + - svn_add_changes + - svn_commit + + deploy_svn_tag: + executor: base + steps: + - attach_workspace: + at: /tmp + - svn_setup + - svn_add_changes + - svn_create_tag + - svn_commit workflows: version: 2 - check-standards: + checks: + jobs: + - checkout + - checks: + requires: + - checkout + + branch_deploy: + jobs: + - checkout: + filters: + branchs: + only: master + - checks: + requires: + - checkout + filters: + branchs: + only: master + - deploy_svn_branch: + requires: + - checkout + - checks + filters: + branchs: + only: master + + tag_deploy: jobs: - checkout: filters: tags: - only: /.*/ + only: /^\d+\.\d+\.\d+$/ + branches: + only: master - standards: filters: tags: - only: /.*/ + only: /^\d+\.\d+\.\d+$/ + branches: + only: master requires: - checkout - - deploy_svn: + - deploy_svn_tag: + context: genesis-svn requires: - checkout - standards filters: tags: - only: /.*/ + only: /^\d+\.\d+\.\d+$/ branches: only: master diff --git a/.circleci/svn-deploy.sh b/.circleci/svn-deploy.sh deleted file mode 100644 index 1e6f7f5..0000000 --- a/.circleci/svn-deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -CURDIR=$(pwd); -TMPDIR=~/.plugin-release-script; - -mkdir $TMPDIR; -cd $TMPDIR; -svn co https://plugins.svn.wordpress.org/$SLUG --depth=empty .; -svn up trunk -svn up tags --depth=empty -cd trunk; -rm -rf * .* *.*; -### Clone the repo at the specific version tag -git clone --branch $VERSION git@github.com:$SLUG.git --depth 1 . -### This is where you would run any build commands -svn propset svn:ignore -F .svnignore .; -cd ../; -svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm; -svn add --force .; -svn cp trunk tags/$VERSION; -svn ci -m "Tagging $VERSION from Github" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD"; -cd $CURDIR; -rm -rf $TMPDIR; -echo 'Done!'; From 013f0c7563f164d75130b4ed83a1bacef57071b1 Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Mon, 30 Mar 2020 15:23:48 -0500 Subject: [PATCH 3/9] ci: fix branches typo --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cdd89bc..8635243 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -119,20 +119,20 @@ workflows: jobs: - checkout: filters: - branchs: + branches: only: master - checks: requires: - checkout filters: - branchs: + branches: only: master - deploy_svn_branch: requires: - checkout - checks filters: - branchs: + branches: only: master tag_deploy: From 8baf6f4a0f1f267673887774f9b1f516757e6882 Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Mon, 30 Mar 2020 15:26:15 -0500 Subject: [PATCH 4/9] ci: fix missing param --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8635243..4879a3e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,9 +13,6 @@ commands: [ ! -d "/tmp/artifacts" ] && mkdir /tmp/artifacts &>/dev/null svn_setup: description: "Setup SVN" - parameters: - slug: - type: string steps: - mkdir_artifacts - run: From 27315c4b7441a53bdae12120e98e182bad3c166b Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Mon, 30 Mar 2020 15:27:11 -0500 Subject: [PATCH 5/9] ci: fix deploy typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4879a3e..1ad0ecd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,7 @@ commands: svn_add_changes: description: "Add changes to SVN" steps: - - deply: + - deploy: command: | cd /tmp/artifacts svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm From 52e99ccf1fdd1e4eb405b92c4b1ebc33f8239feb Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Mon, 30 Mar 2020 15:28:16 -0500 Subject: [PATCH 6/9] ci: fix new job naming --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ad0ecd..3126752 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -140,7 +140,7 @@ workflows: only: /^\d+\.\d+\.\d+$/ branches: only: master - - standards: + - checks: filters: tags: only: /^\d+\.\d+\.\d+$/ @@ -152,7 +152,7 @@ workflows: context: genesis-svn requires: - checkout - - standards + - checks filters: tags: only: /^\d+\.\d+\.\d+$/ From 34a568754e7b446e53431979ae893ec92ebb6089 Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Mon, 30 Mar 2020 15:48:48 -0500 Subject: [PATCH 7/9] ci: forgot to add context to branch_deploy workflow --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3126752..f205291 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -125,6 +125,7 @@ workflows: branches: only: master - deploy_svn_branch: + context: genesis-svn requires: - checkout - checks From f90e899c8f0e91357ec0bbd541def0b51e823490 Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Tue, 31 Mar 2020 09:38:44 -0500 Subject: [PATCH 8/9] fix: typo in .svnignore file --- .svnignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.svnignore b/.svnignore index 7a30b5e..d315849 100644 --- a/.svnignore +++ b/.svnignore @@ -3,4 +3,4 @@ .gitattributes .svnignore node_modules -.circlci +.circleci From 80191d03b1150d379b6a9b80c5a7b4f6d535ccde Mon Sep 17 00:00:00 2001 From: Ben Moore Date: Tue, 31 Mar 2020 10:33:58 -0500 Subject: [PATCH 9/9] chore: adjust order of requires and filters in workflows --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f205291..a4f94f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -142,13 +142,13 @@ workflows: branches: only: master - checks: + requires: + - checkout filters: tags: only: /^\d+\.\d+\.\d+$/ branches: only: master - requires: - - checkout - deploy_svn_tag: context: genesis-svn requires: