diff --git a/.circleci/config.yml b/.circleci/config.yml index 01e3cdb..866409a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,14 @@ jobs: # a collection of steps - add_ssh_keys: fingerprints: - "8d:4d:a0:2f:19:d2:d9:8c:ed:83:2c:20:bc:aa:32:f0" + - run: + name: Install subsplit + command: | + sudo wget -O "$(git --exec-path)"/git-subsplit https://raw.githubusercontent.com/dflydev/git-subsplit/master/git-subsplit.sh + sudo chmod +x "$(git --exec-path)"/git-subsplit + - run: + name: auto split packages, push code and tag to new repo. but need submit to packagist.org manually, because it have no API to submit. + command: ./split-packages.sh - run: name: Deploy docs to gh-pages branch command: gh-pages --dotfiles --message "[skip ci] Updates" --dist site diff --git a/.gitignore b/.gitignore index 7495df0..fed93ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ composer.lock /mkdocs.yml /docs/ /site/ +/.subsplit/ diff --git a/split-packages.sh b/split-packages.sh new file mode 100755 index 0000000..9edbc97 --- /dev/null +++ b/split-packages.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +rm -rf .subsplit +git subsplit init `git config --get remote.origin.url` +git subsplit update +for file in `ls */composer.json`; do + target=`node getValueFromJsonFile.js $file extra.component.target` + repo_uri=`echo $target | cut -d "." -f1` + desc=`node getValueFromJsonFile.js $file description` + dir_name=`dirname $file` + hub create -d "$desc" $repo_uri + git subsplit publish \ + $dir_name:git@github.com:$target \ + --heads=master \ + --no-tags + + # create tag + echo -e "\ncreate tag" + version=`node getValueFromJsonFile.js $file version` + repo_name=`echo $repo_uri | cut -d "/" -f2` + rm -rf /tmp/$repo_name + pushd /tmp/ + git clone git@github.com:$target + pushd /tmp/$repo_name + tag_exists=`git ls-remote origin refs/tags/$version` + if [ -z $tag_exists ]; then + git tag -a $version -m 'new version' + git push --tags + fi + pushd +2 + dirs -c + dirs -v +done