Skip to content

Commit

Permalink
Add VERSION constants within AutoMapper class and use it to cache tra…
Browse files Browse the repository at this point in the history
…nsformers (#21)

* Add VERSION constants within AutoMapper class and use it to cache transformers
* Add some documentation about contributing & releases
* Add static version check in CI
  • Loading branch information
Korbeil authored Dec 11, 2023
1 parent 174461c commit 9c43e0d
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/scripts/check-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

LAST_TAG=`git describe --tags --abbrev=0`
IFS=. components=(${LAST_TAG##*-})
exit `php -r "require_once __DIR__.'/vendor/autoload.php'; use AutoMapper\AutoMapper; echo (AutoMapper::MAJOR_VERSION >= intval(\"${components[0]}\") && AutoMapper::MINOR_VERSION >= intval(\"${components[1]}\")) ? 0 : 1;"`
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,23 @@ jobs:
run: composer update --prefer-stable
- name: tests
run: vendor/bin/phpunit
check-version:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master
- name: cache-composer
uses: actions/cache@v2
with:
path: ~/.composer/cache/
key: composer-${{ github.sha }}
- name: setup
uses: shivammathur/[email protected]
with:
php-version: 8.2
coverage: none
extensions: mbstring, fileinfo, json, intl, dom
- name: composer install
run: composer update --prefer-stable
- name: check version
run: ./.github/scripts/check-version.sh
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- [GH#22](https://github.com/jolicode/automapper/pull/22) Added generic AST extractor
- [GH#21](https://github.com/jolicode/automapper/pull/21) Add VERSION constants within AutoMapper class and use it for transformers hashes

### Changed
- [GH#19](https://github.com/jolicode/automapper/pull/19) Use attributes everywhere instead of annotations
Expand Down
16 changes: 16 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Contributing

## Releasing

Whenever you're doing a release you need to do some updates in order for the project to keep history on what was done
and some other stuff.

### Changelog

First you'll need to update the CHANGELOG file (`./CHANGELOG.md`), take everything under the `Unreleased` section and
create a new section for your new tag with the today's date.

### Version

When a new version is tagged, you have to update the version constants within the `AutoMapper/AutoMapper` so
transformers can be updated with last AutoMapper version.
3 changes: 2 additions & 1 deletion docs/navigation.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- [Quick start](/)
- [Symfony](/symfony)
- [Symfony](/symfony)
- [Contributing](/contributing)
7 changes: 7 additions & 0 deletions src/AutoMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
*/
class AutoMapper implements AutoMapperInterface, AutoMapperRegistryInterface, MapperGeneratorMetadataRegistryInterface
{
public const VERSION = '8.1.0-DEV';
public const VERSION_ID = 80100;
public const MAJOR_VERSION = 8;
public const MINOR_VERSION = 1;
public const RELEASE_VERSION = 0;
public const EXTRA_VERSION = 'DEV';

/** @var MapperGeneratorMetadataInterface[] */
private array $metadata = [];

Expand Down
2 changes: 2 additions & 0 deletions src/MapperMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public function getHash(): string
$hash .= filemtime($reflection->getFileName());
}

$hash .= AutoMapper::VERSION_ID;

return $hash;
}

Expand Down

0 comments on commit 9c43e0d

Please sign in to comment.