diff --git a/bin/semver b/bin/semver index a70f2a8..e8403bc 100755 --- a/bin/semver +++ b/bin/semver @@ -28,7 +28,7 @@ function bump_version_file { local publishingVersion="${1}" local newVersion=$( bump_patch $publishingVersion) local versionFile=${2:-version.properties} - updateVersionFile $newVersion $publishingVersion $versionFile $3 + updateVersionFile $newVersion $publishingVersion $versionFile "${3}" } # Updates version.properties with given version, sets publishedVersion to the $VERSION diff --git a/makefiles/release.make b/makefiles/release.make index 00bf887..12156b1 100644 --- a/makefiles/release.make +++ b/makefiles/release.make @@ -6,17 +6,24 @@ github_release := $(SHIPKIT_BIN)/github_release semver := $(SHIPKIT_BIN)/semver changelog := $(SHIPKIT_BIN)/changelog +VERSION_FILENAME ?= version.properties +VERSION_SET_SNAPSHOT ?= false + +shipkit: + version: + filename: + update-changelog: | _verify_VERSION _verify_PUBLISHED_VERSION _verify_RELEASE_CHANGELOG _verify_PROJECT_FULLNAME - $(changelog) update_changelog $(VERSION) $(PUBLISHED_VERSION) $(RELEASE_CHANGELOG) $(PROJECT_FULLNAME) + $(changelog) update_changelog "$(VERSION)" "$(PUBLISHED_VERSION)" "$(RELEASE_CHANGELOG)" "$(PROJECT_FULLNAME)" echo "update-changelog success" update-readme-version: | _verify_VERSION $(semver) replace_version "$(VERSION)" README.md echo "update-readme-version success" -bump-version-props: | _verify_VERSION - $(semver) bump_version_file "$(VERSION)" version.properties - echo "bump-version-props success" +bump-version-file: | _verify_VERSION + $(semver) bump_version_file "$(VERSION)" "$(VERSION_FILENAME)" "$(VERSION_SET_SNAPSHOT)" + echo "bump-version-file success on $(VERSION_FILENAME) for v:$(VERSION)" # updates change log, bumps version, updates the publishingVersion in README push-version-bumps: @@ -39,7 +46,7 @@ create-github-release: | _verify_VERSION _verify_RELEASABLE_BRANCH _verify_PROJE $(github_release) create_github_release $(VERSION) $(RELEASABLE_BRANCH) $(PROJECT_FULLNAME) $(GITHUB_TOKEN) echo "create-github-release success" -semantic-release: update-changelog update-readme-version bump-version-props create-github-release push-version-bumps +semantic-release: update-changelog update-readme-version bump-version-file create-github-release push-version-bumps echo "Releasable ... doing version bump, changelog and tag push" endif # end RELEASABLE_BRANCH diff --git a/tests/fixtures/versions/Makefile b/tests/fixtures/versions/Makefile index f95a5f9..725ab61 100644 --- a/tests/fixtures/versions/Makefile +++ b/tests/fixtures/versions/Makefile @@ -1,5 +1,3 @@ include Shipkit.make -include makefiles/secrets.make +include makefiles/release.make -version-cd-dir: - cd build && $(GIT_SECRET_SH) --version diff --git a/tests/fixtures/versions/bin/gpg b/tests/fixtures/versions/bin/gpg deleted file mode 100755 index 4a76493..0000000 --- a/tests/fixtures/versions/bin/gpg +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -read key -echo mock-gpg "$key" diff --git a/tests/semver.bats b/tests/semver.bats index e759760..c3255b9 100644 --- a/tests/semver.bats +++ b/tests/semver.bats @@ -1,5 +1,12 @@ #!/usr/bin/env bats source "$SHIPKIT_BIN/semver" +load test_helper + +setup() { + export FIXTURE_DIR="$BATS_TEST_DIRNAME/fixtures/versions" + export VERSION_FILENAME=build/semver_tests/version.env + export VERSION_SET_SNAPSHOT=true +} @test 'bump_patch' { version=$(bump_patch "1.2.3 ") @@ -27,3 +34,24 @@ source "$SHIPKIT_BIN/semver" grep "snapshot=true" $semverFile } + +@test 'make sure git-secret-version works' { + + semverFile=$VERSION_FILENAME + echo "version=1.0.1" > $semverFile + echo "publishedVersion=1.0.0" >> $semverFile + echo "snapshot=false" >> $semverFile + + grep "version=1.0.1" $semverFile + grep "publishedVersion=1.0.0" $semverFile + grep "snapshot=false" $semverFile + + run make -f $FIXTURE_DIR/Makefile bump-version-file VERSION=1.0.1 + __debug "${status}" "${output}" "${lines[@]}" + + [ "$status" -eq 0 ] + grep "version=1.0.2" $semverFile + grep "publishedVersion=1.0.1" $semverFile + grep "snapshot=true" $semverFile + # [ "${lines[0]}" == "tests/fixtures/bin/curl \"http://localhost\" | cat -" ] +}