Skip to content

Commit

Permalink
👷 Add version and tagging scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
amcintosh committed Nov 20, 2021
1 parent 3dac601 commit a9815be
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .bump-version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
// GENERATED by bump_version
return [
'master_branch' => 'main',
'develop_branch' => 'develop',
'version_file' => __DIR__ . '/src/VERSION',
// 'define_version_file' => __DIR__ . '/app/version.php', // you can add a 'PHP accessible' define with the current version
// 'define_version_name' => 'APP_VERSION', // the define name
// 'changelog_file' => __DIR__ . '/CHANGELOG.md', // A basic CHANGELOG
'release_branches' => ['hotfix' => 'hotfix-*', 'release' => 'release-*'], // The branches you should release on
];
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
.PHONY: generate-docs
.PHONY: generate-docs, tag
.PHONY: check-style, test, test-all

generate-docs:
./phpDocumentor.phar -d ./src -t ./docs

OLD_VERSION = $(shell cat src/VERSION)
tag:
@if [ "$(VERSION_PART)" = '' ]; then \
echo "Must specify VERSION_PART to bump (major, minor, patch)."; \
exit 1; \
fi;
./vendor/bin/bump_version bump --$(VERSION_PART)
./scripts/tag_version.sh $(OLD_VERSION)

check-style:
./vendor/bin/phpcs src tests

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"phpunit/phpunit": "9.5.x-dev",
"squizlabs/php_codesniffer": "4.0.x-dev",
"php-http/guzzle7-adapter": "1.x-dev",
"php-http/mock-client": "1.x-dev"
"php-http/mock-client": "1.x-dev",
"quazardous/php-bump-version": "1.0.x-dev"
},
"license": "MIT",
"autoload": {
Expand Down
17 changes: 17 additions & 0 deletions scripts/tag_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

OLD_VERSION=$1
VERSION=`cat ./src/VERSION`
echo ${VERSION}
sed -i '' 's/## Unreleased/## Unreleased\
\
## '"${VERSION}/" ./CHANGELOG.md

git add src/VERSION && \
git add CHANGELOG.md && \
git commit -m "🔖 Update CHANGELOG for release" && \
git push origin main

git tag -a -m "Bump version: ${OLD_VERSION} → ${VERSION}" "release/${VERSION}" && \
git push origin --tags && \
git push origin main
2 changes: 1 addition & 1 deletion src/FreshBooksClientConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
*/
private function getVersion(): string
{
return file_get_contents(dirname(__FILE__) . '/VERSION');
return trim(file_get_contents(dirname(__FILE__) . '/VERSION'));
}

/**
Expand Down

0 comments on commit a9815be

Please sign in to comment.