Skip to content

Commit

Permalink
Merge pull request #25 from spejder/fix-release
Browse files Browse the repository at this point in the history
fix release
  • Loading branch information
arnested authored Sep 13, 2022
2 parents b99d0fd + a911ec3 commit c221a2a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 25 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: Bump version

on:
push:
branches:
- master

permissions:
actions: read
contents: write

jobs:
bump-version:
runs-on: ubuntu-latest
Expand All @@ -11,19 +17,29 @@ jobs:
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.42.0
uses: anothrNick/github-tag-action@1.44.0
id: version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
WITH_V: true
DEFAULT_BUMP: patch
- name: Create release
uses: actions/github-script@v6
if: ${{ steps.version.outputs.new_tag }} != ""
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
RELEASE_TAG: ${{ steps.version.outputs.new_tag }}
with:
tag_name: ${{ steps.version.outputs.new_tag }}
release_name: Release ${{ steps.version.outputs.new_tag }}
draft: false
prerelease: false
script: |
try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
} catch (error) {
core.setFailed(error.message);
}
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"jacobsteringa/odoo-client": "<=0.3.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.32 || ^1.0.0",
"squizlabs/php_codesniffer": "^3.5"
"phpstan/phpstan": "^1",
"squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan-deprecation-rules": "^1",
"phpstan/phpstan-symfony": "^1"
}
}
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ parameters:
level: max
paths:
- .
excludes_analyse:
excludePaths:
- vendor
35 changes: 21 additions & 14 deletions src/Odoo/Odoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class Odoo
/**
* Unique identifier for current user
*
* @var integer
* @var integer|null
*/
protected $uid;
protected $uid = null;

/**
* Current users username
Expand Down Expand Up @@ -112,23 +112,25 @@ public function version(): array
{
$response = $this->getClient('common')->call('version');

return $response;
return is_array($response) ? $response : [];
}

/**
* Get timezone
*
* @return string Current timezone
*/
public function timezone(): string
public function timezone(): ?string
{
$params = [
$this->database,
$this->user,
$this->password
];

return $this->getClient('common')->call('timezone_get', $params);
$response = $this->getClient('common')->call('timezone_get', $params);

return is_string($response) ? $response : null;
}

/**
Expand All @@ -153,7 +155,7 @@ public function search(string $model, array $data, int $offset = 0, int $limit =

$response = $this->getClient('object')->call('execute', $params);

return $response;
return is_array($response) ? $response : [];
}

/**
Expand All @@ -164,7 +166,7 @@ public function search(string $model, array $data, int $offset = 0, int $limit =
*
* @return integer Created model id
*/
public function create(string $model, array $data): int
public function create(string $model, array $data): ?int
{
$params = $this->buildParams([
$model,
Expand All @@ -174,7 +176,7 @@ public function create(string $model, array $data): int

$response = $this->getClient('object')->call('execute', $params);

return $response;
return is_int($response) ? $response : null;
}

/**
Expand All @@ -197,7 +199,7 @@ public function read(string $model, array $ids, array $fields = []): array

$response = $this->getClient('object')->call('execute', $params);

return $response;
return is_array($response) ? $response : [];
}

/**
Expand Down Expand Up @@ -229,7 +231,7 @@ public function searchRead(

$response = $this->getClient('object')->call('execute', $params);

return $response;
return is_array($response) ? $response : [];
}

/**
Expand All @@ -252,7 +254,7 @@ public function write(string $model, array $ids, array $fields): array

$response = $this->getClient('object')->call('execute', $params);

return $response;
return is_array($response) ? $response : [];
}

/**
Expand All @@ -271,7 +273,9 @@ public function unlink(string $model, array $ids): bool
$ids
]);

return $this->getClient('object')->call('execute', $params);
$response = $this->getClient('object')->call('execute', $params);

return is_bool($response) ? $response : false;
}

/**
Expand Down Expand Up @@ -302,6 +306,7 @@ public function getReport(string $model, array $ids, string $type = 'qweb-pdf'):
$state = false;

while (!$state) {
/** @var array<string> */
$report = $client->call(
'report_get',
$this->buildParams([$reportId])
Expand Down Expand Up @@ -401,16 +406,18 @@ protected function getClient(?string $path = null): XmlRpcClient
*
* @return int $uid
*/
protected function uid(): int
protected function uid(): ?int
{
if ($this->uid === null) {
$client = $this->getClient('common');

$this->uid = $client->call('login', [
$response = $client->call('login', [
$this->database,
$this->user,
$this->password
]);

$this->uid = is_int($response) ? $response : null;
}

return $this->uid;
Expand Down

0 comments on commit c221a2a

Please sign in to comment.