From a9815bebb8bbb109c721ef5a73e7651de01f0882 Mon Sep 17 00:00:00 2001 From: Andrew McIntosh Date: Sat, 20 Nov 2021 08:45:38 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Add=20version=20and=20tagging=20?= =?UTF-8?q?scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bump-version.php | 11 +++++++++++ Makefile | 11 ++++++++++- composer.json | 3 ++- scripts/tag_version.sh | 17 +++++++++++++++++ src/FreshBooksClientConfig.php | 2 +- 5 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 .bump-version.php create mode 100755 scripts/tag_version.sh diff --git a/.bump-version.php b/.bump-version.php new file mode 100644 index 0000000..3738190 --- /dev/null +++ b/.bump-version.php @@ -0,0 +1,11 @@ + '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 +]; diff --git a/Makefile b/Makefile index c9fc536..03c1665 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/composer.json b/composer.json index 7faf4de..8bfba36 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/scripts/tag_version.sh b/scripts/tag_version.sh new file mode 100755 index 0000000..bfa7b4f --- /dev/null +++ b/scripts/tag_version.sh @@ -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 diff --git a/src/FreshBooksClientConfig.php b/src/FreshBooksClientConfig.php index c3d89c3..b6eaa32 100644 --- a/src/FreshBooksClientConfig.php +++ b/src/FreshBooksClientConfig.php @@ -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')); } /**