-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Packaging and Version Distribution Commands for Plugins (#115)
* Introduce Packaging and Version Distribution Commands for Plugins * Apply cs fix
- Loading branch information
Showing
7 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of MineAdmin. | ||
* | ||
* @link https://www.mineadmin.com | ||
* @document https://doc.mineadmin.com | ||
* @contact [email protected] | ||
* @license https://github.com/mineadmin/MineAdmin/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Mine\AppStore\Command\Repository; | ||
|
||
use Hyperf\Command\Annotation\Command; | ||
use Mine\AppStore\Command\AbstractCommand; | ||
use Mine\AppStore\Plugin; | ||
use Swoole\Coroutine\System; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
#[Command] | ||
class PushCommand extends AbstractCommand | ||
{ | ||
protected const COMMAND_NAME = 'push'; | ||
|
||
public function __invoke(): int | ||
{ | ||
$path = $this->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 = <<<SHELL | ||
cd {$basepath} && {$splitLinuxBin} {$repositoryPath} {$repository} {$bin} | ||
SHELL; | ||
$result = System::exec($shell); | ||
if ($result['code'] !== 0) { | ||
$this->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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of MineAdmin. | ||
* | ||
* @link https://www.mineadmin.com | ||
* @document https://doc.mineadmin.com | ||
* @contact [email protected] | ||
* @license https://github.com/mineadmin/MineAdmin/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Mine\AppStore\Command\Repository; | ||
|
||
use Hyperf\Command\Annotation\Command; | ||
use Mine\AppStore\Command\AbstractCommand; | ||
use Mine\AppStore\Plugin; | ||
use Swoole\Coroutine\System; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
#[Command] | ||
class ReleaseCommand extends AbstractCommand | ||
{ | ||
public const COMMAND_NAME = 'release'; | ||
|
||
public function __invoke(): int | ||
{ | ||
$path = $this->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 = <<<SHELL | ||
cd {$basepath} && {$splitLinuxBin} {$repositoryPath} {$repository} {$version} {$bin} | ||
SHELL; | ||
$result = System::exec($shell); | ||
if ($result['code'] !== 0) { | ||
$this->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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters