Compare commits

...

5 Commits

Author SHA1 Message Date
Pavel Shevaev bbeb16fba8 Downgrading to PHP7 compatibility
Publish PHP Package / docker (push) Successful in 6s Details
2024-08-13 11:15:21 +03:00
Pavel Shevaev 9cbde9a855 Downgrading to PHP7 compatibility
Publish PHP Package / docker (push) Successful in 6s Details
2024-08-13 11:12:53 +03:00
Pavel Shevaev 3a6aed2d29 Adding typehints and optional root .git directory check
Publish PHP Package / docker (push) Successful in 7s Details
2024-08-13 10:57:09 +03:00
Pavel Shevaev d57847f525 Добавить .gitea/workflows/build_composer.yaml
Publish PHP Package / docker (push) Successful in 5s Details
2024-02-13 12:48:49 +03:00
Pavel Shevaev 6f5b05e890 Изменил(а) на 'composer.json' 2023-10-24 18:27:52 +03:00
3 changed files with 41 additions and 14 deletions

View File

@ -0,0 +1,28 @@
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 }}

View File

@ -4,8 +4,5 @@
"homepage": "https://git.bit5.ru/bit/taskman_git",
"require": {
"php": ">=7.4"
},
"autoload": {
"files": ["git.inc.php"]
}
}

View File

@ -12,7 +12,7 @@ task('git_info', function()
echo $info;
});
function git_do($repo, $action, &$out = NULL, $verbose = true)
function git_do(string $repo, string $action, &$out = NULL, bool $verbose = true)
{
$cli = "cd $repo && git $action";
if($verbose)
@ -24,14 +24,16 @@ function git_do($repo, $action, &$out = NULL, $verbose = true)
throw new Exception("Error executing command: $cli ($result)");
}
function git_is_repo($directory)
function git_is_repo(string $directory, bool $check_root = false) : bool
{
if($check_root && !is_dir("$directory/.git"))
return false;
$output = [];
git_do($directory, "rev-parse --is-inside-work-tree", $output, false);
return !empty($output) && $output[0] === 'true';
}
function git_rev_from_commit_message($message)
function git_rev_from_commit_message(string $message) : string
{
// Regular expression pattern to extract the commit hash
$pattern = '/\b[0-9a-f]{7,40}\b/';
@ -42,7 +44,7 @@ function git_rev_from_commit_message($message)
return $commit_hash;
}
function get_git_last_remote_tag($repo)
function get_git_last_remote_tag(string $repo) : mixed
{
$remote_tags = [];
git_do($repo, 'ls-remote --tags origin', $output, false);
@ -60,7 +62,7 @@ function get_git_last_remote_tag($repo)
return _get_last_version_tag($remote_tags);
}
function _get_last_version_tag(array $tags)
function _get_last_version_tag(array $tags) : mixed
{
if(!$tags)
return false;
@ -74,11 +76,11 @@ function _get_last_version_tag(array $tags)
class GitVersion
{
public $major;
public $minor;
public $patch;
public int $major;
public int $minor;
public int $patch;
static function parse($version_str)
static function parse($version_str) : GitVersion
{
$parts = explode('.', $version_str);
if(sizeof($parts) != 3)
@ -92,7 +94,7 @@ class GitVersion
return $v;
}
function bump($up_mode)
function bump(int $up_mode)
{
if($up_mode == 1)
++$this->patch;
@ -111,7 +113,7 @@ class GitVersion
throw new Exception("Unsupported up mode: $up_mode");
}
function encode()
function encode() : string
{
return 'v'.$this->major.'.'.$this->minor.'.'.$this->patch;
}