diff --git a/bin/release.sh b/bin/release.sh new file mode 100755 index 0000000..8e957ff --- /dev/null +++ b/bin/release.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -e +if (( "$#" == 0 )) +then + echo "Tag has to be provided" + + exit 1 +fi + +NOW=$(date +%s) +CURRENT_BRANCH=$(cd $1 && git rev-parse --abbrev-ref HEAD) +BASEPATH=$1 +VERSION=$3 +REMOTE=$2 +# Always prepend with "v" +if [[ $VERSION != v* ]] +then + VERSION="v$VERSION" +fi + +echo "" +echo "" +echo "Cloning $REMOTE"; +TMP_DIR="/tmp/mineAdmin-split" +REMOTE_URL=$REMOTE + +rm -rf $TMP_DIR; +mkdir $TMP_DIR; + +( + cd $TMP_DIR; + + git clone $REMOTE_URL . + git checkout "$CURRENT_BRANCH"; + + if [[ $(git log --pretty="%d" -n 1 | grep tag --count) -eq 0 ]]; then + echo "Releasing $REMOTE" + git tag $VERSION + git push origin --tags + fi +) + +TIME=$(echo "$(date +%s) - $NOW" | bc) + +printf "Execution time: %f seconds" $TIME \ No newline at end of file diff --git a/bin/split-linux.sh b/bin/split-linux.sh new file mode 100755 index 0000000..fe2bcbc --- /dev/null +++ b/bin/split-linux.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -e +set -x +CURRENT_BRANCH=$(cd $1 && git rev-parse --abbrev-ref HEAD) +bin=$3 +BASEPATH=$1 +REPO=$2 +function split() +{ + SHA1=`$bin/splitsh-lite-linux --prefix=$1` + git push $2 "$SHA1:refs/heads/$CURRENT_BRANCH" -f +} + +function remote() +{ + git remote add $1 $2 || true +} + +remote 'appStore' $REPO +split $BASEPATH $REPO diff --git a/bin/splitsh-lite b/bin/splitsh-lite new file mode 100755 index 0000000..71a4d89 Binary files /dev/null and b/bin/splitsh-lite differ diff --git a/bin/splitsh-lite-linux b/bin/splitsh-lite-linux new file mode 100755 index 0000000..ddefe95 Binary files /dev/null and b/bin/splitsh-lite-linux differ diff --git a/src/Command/Repository/PushCommand.php b/src/Command/Repository/PushCommand.php new file mode 100644 index 0000000..85230b1 --- /dev/null +++ b/src/Command/Repository/PushCommand.php @@ -0,0 +1,52 @@ +input->getArgument('path'); + $repository = $this->input->getArgument('repository'); + $bin = dirname(__DIR__, 3) . '/bin'; + $repositoryPath = Plugin::PLUGIN_PREFIX . DIRECTORY_SEPARATOR . $path; + $splitLinuxBin = $bin . DIRECTORY_SEPARATOR . 'split-linux.sh'; + $basepath = BASE_PATH; + $shell = <<output->error('Fail' . $result['output']); + return $result['code']; + } + $this->output->success('Push successfully'); + return 0; + } + + protected function configure() + { + $this->setDescription('Quickly perform plugin packaging and deployment processing.'); + $this->addArgument('path', InputArgument::REQUIRED, 'Plugin path'); + $this->addArgument('repository', InputArgument::REQUIRED, 'Git Repository path'); + } +} diff --git a/src/Command/Repository/ReleaseCommand.php b/src/Command/Repository/ReleaseCommand.php new file mode 100644 index 0000000..125cf4f --- /dev/null +++ b/src/Command/Repository/ReleaseCommand.php @@ -0,0 +1,53 @@ +argument('path'); + $repository = $this->argument('repository'); + $version = $this->argument('version'); + $bin = dirname(__DIR__, 3) . '/bin'; + $repositoryPath = Plugin::PLUGIN_PREFIX . DIRECTORY_SEPARATOR . $path; + $splitLinuxBin = $bin . DIRECTORY_SEPARATOR . 'release.sh'; + $basepath = BASE_PATH; + $shell = <<output->error('Fail' . $result['output']); + return $result['code']; + } + $this->output->success('Push successfully'); + return 0; + } + + protected function configure() + { + $this->addArgument('path', InputArgument::REQUIRED, 'Plugin path'); + $this->addArgument('repository', InputArgument::REQUIRED, 'Git Repository path'); + $this->addArgument('version', InputArgument::REQUIRED, 'Repository version'); + } +} diff --git a/src/Plugin.php b/src/Plugin.php index 050ddb0..5c05eab 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -36,7 +36,9 @@ class Plugin /** * Plugin root directory. */ - public const PLUGIN_PATH = BASE_PATH . '/plugin'; + public const PLUGIN_PATH = BASE_PATH . '/' . self::PLUGIN_PREFIX; + + public const PLUGIN_PREFIX = 'plugin'; private static array $mineJsonPaths = [];