Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtARTs36 committed Mar 8, 2022
1 parent e67de9d commit 712fb4f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.MD export-ignore
21 changes: 21 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CI Git Tagger

CI Git Tagger - tools for sending tags to remote git.

## Install

Run command: `composer require artarts36/ci-git-tagger`

## Usage

```php
<?php

use ArtARTs36\CiGitTagger\Remote\Credentials;
use ArtARTs36\CiGitTagger\Tag\Tag;
use ArtARTs36\CiGitTagger\Tagger\Factory;

$tagger = Factory::local()->create(__DIR__, new Credentials('login', 'token'));

$tagger->tag(Tag::make('0.1.6', 'v{$TAG}_{$BRANCH}_${COMMIT}'));
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"artarts36/git-handler": "^1.1",
"artarts36/git-handler": "^1.1.12",
"ondram/ci-detector": "^4.1"
}
}
10 changes: 8 additions & 2 deletions src/Tagger/GitTagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use ArtARTs36\CiGitTagger\Remote\Credentials;
use ArtARTs36\CiGitTagger\Tag\Tag;
use ArtARTs36\GitHandler\Contracts\Handler\GitHandler;
use ArtARTs36\GitHandler\Exceptions\TagAlreadyExists;
use ArtARTs36\GitHandler\Making\MakingPush;
use Psr\Http\Message\UriInterface;

Expand All @@ -18,14 +19,19 @@ public function __construct(private GitHandler $git, private Credentials $creden

public function tag(Tag $tag): void
{
$this->git->tags()->add($tag->name, $tag->message?->render());
try {
$this->git->tags()->add($tag->name, $tag->message?->render());
} catch (TagAlreadyExists) {
//
}

$this->git->pushes()->send(function (MakingPush $push) {
$push
->onRemote(function (UriInterface $uri) {
return $uri->withUserInfo($this->credentials->login, $this->credentials->token);
})
->onSetUpStream();
->onSetUpStream()
->tags();
});
}
}

0 comments on commit 712fb4f

Please sign in to comment.