Compare commits
No commits in common. "master" and "v1.0.0" have entirely different histories.
|
@ -1,28 +0,0 @@
|
||||||
name: Publish PHP Package
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Get tag name
|
|
||||||
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: zip and send
|
|
||||||
run: |
|
|
||||||
ls -la
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install -y zip
|
|
||||||
cd ../
|
|
||||||
zip -r ${{ gitea.event.repository.name }}.zip ${{ gitea.event.repository.name }} -x '*.git*'
|
|
||||||
curl -v \
|
|
||||||
--user composer-pbl:${{ secrets.COMPOSER_PSWD }} \
|
|
||||||
--upload-file ${{ gitea.event.repository.name }}.zip \
|
|
||||||
https://git.bit5.ru/api/packages/bit/composer?version=${{ env.TAG }}
|
|
|
@ -1,8 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "bit/taskman_git",
|
"name": "bit/taskman_git",
|
||||||
"description": "taskman git utils",
|
"description": "taskman git utils",
|
||||||
"homepage": "https://git.bit5.ru/bit/taskman_git",
|
"homepage": "https://git.bit5.ru/composer/taskman_git",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.4"
|
"php": ">=7.4"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"classmap": ["git.inc.php"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
24
git.inc.php
24
git.inc.php
|
@ -12,7 +12,7 @@ task('git_info', function()
|
||||||
echo $info;
|
echo $info;
|
||||||
});
|
});
|
||||||
|
|
||||||
function git_do(string $repo, string $action, &$out = NULL, bool $verbose = true)
|
function git_do($repo, $action, &$out = NULL, $verbose = true)
|
||||||
{
|
{
|
||||||
$cli = "cd $repo && git $action";
|
$cli = "cd $repo && git $action";
|
||||||
if($verbose)
|
if($verbose)
|
||||||
|
@ -24,16 +24,14 @@ function git_do(string $repo, string $action, &$out = NULL, bool $verbose = true
|
||||||
throw new Exception("Error executing command: $cli ($result)");
|
throw new Exception("Error executing command: $cli ($result)");
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_is_repo(string $directory, bool $check_root = false) : bool
|
function git_is_repo($directory)
|
||||||
{
|
{
|
||||||
if($check_root && !is_dir("$directory/.git"))
|
|
||||||
return false;
|
|
||||||
$output = [];
|
$output = [];
|
||||||
git_do($directory, "rev-parse --is-inside-work-tree", $output, false);
|
git_do($directory, "rev-parse --is-inside-work-tree", $output, false);
|
||||||
return !empty($output) && $output[0] === 'true';
|
return !empty($output) && $output[0] === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_rev_from_commit_message(string $message) : string
|
function git_rev_from_commit_message($message)
|
||||||
{
|
{
|
||||||
// Regular expression pattern to extract the commit hash
|
// Regular expression pattern to extract the commit hash
|
||||||
$pattern = '/\b[0-9a-f]{7,40}\b/';
|
$pattern = '/\b[0-9a-f]{7,40}\b/';
|
||||||
|
@ -44,7 +42,7 @@ function git_rev_from_commit_message(string $message) : string
|
||||||
return $commit_hash;
|
return $commit_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_git_last_remote_tag(string $repo) : mixed
|
function get_git_last_remote_tag($repo)
|
||||||
{
|
{
|
||||||
$remote_tags = [];
|
$remote_tags = [];
|
||||||
git_do($repo, 'ls-remote --tags origin', $output, false);
|
git_do($repo, 'ls-remote --tags origin', $output, false);
|
||||||
|
@ -62,7 +60,7 @@ function get_git_last_remote_tag(string $repo) : mixed
|
||||||
return _get_last_version_tag($remote_tags);
|
return _get_last_version_tag($remote_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _get_last_version_tag(array $tags) : mixed
|
function _get_last_version_tag(array $tags)
|
||||||
{
|
{
|
||||||
if(!$tags)
|
if(!$tags)
|
||||||
return false;
|
return false;
|
||||||
|
@ -76,11 +74,11 @@ function _get_last_version_tag(array $tags) : mixed
|
||||||
|
|
||||||
class GitVersion
|
class GitVersion
|
||||||
{
|
{
|
||||||
public int $major;
|
public $major;
|
||||||
public int $minor;
|
public $minor;
|
||||||
public int $patch;
|
public $patch;
|
||||||
|
|
||||||
static function parse($version_str) : GitVersion
|
static function parse($version_str)
|
||||||
{
|
{
|
||||||
$parts = explode('.', $version_str);
|
$parts = explode('.', $version_str);
|
||||||
if(sizeof($parts) != 3)
|
if(sizeof($parts) != 3)
|
||||||
|
@ -94,7 +92,7 @@ class GitVersion
|
||||||
return $v;
|
return $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bump(int $up_mode)
|
function bump($up_mode)
|
||||||
{
|
{
|
||||||
if($up_mode == 1)
|
if($up_mode == 1)
|
||||||
++$this->patch;
|
++$this->patch;
|
||||||
|
@ -113,7 +111,7 @@ class GitVersion
|
||||||
throw new Exception("Unsupported up mode: $up_mode");
|
throw new Exception("Unsupported up mode: $up_mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
function encode() : string
|
function encode()
|
||||||
{
|
{
|
||||||
return 'v'.$this->major.'.'.$this->minor.'.'.$this->patch;
|
return 'v'.$this->major.'.'.$this->minor.'.'.$this->patch;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue