diff --git a/.github/scripts/release-check-duplicate.sh b/.github/scripts/release-check-duplicate.sh new file mode 100755 index 000000000..5659fc7fd --- /dev/null +++ b/.github/scripts/release-check-duplicate.sh @@ -0,0 +1,24 @@ +#!/bin/env bash +set -e + +root=$(cd "$(dirname $0)/../.." && pwd) +# build new version number +local_sdk_version=$(cat $root/sdk_version) +local_sdk_version_major=$(echo $local_sdk_version | cut -d '.' -f 1) +local_sdk_version_minor=$(echo $local_sdk_version | cut -d '.' -f 2) +new_sdk_version_minor=$(( local_sdk_version_minor + 1 )) +new_sdk_version="$local_sdk_version_major.$new_sdk_version_minor.0" + +branch_name="autobuild-$new_sdk_version" + +if [ -z "$GH_TOKEN" ]; then + echo "GH_TOKEN is missing, abort." + exit 1 +fi + +result=$(curl -s -u LolUserName:$GH_TOKEN "https://api.github.com/repos/outscale/osc-sdk-go/pulls" | jq ".[] | select(.title == \"$new_sdk_version version\") | .title") + +if [ ! -z "$result" ]; then + echo "Pull request seems to alread exist, abort." + exit 1 +fi diff --git a/Makefile b/Makefile index 2c7c5309d..838e5bb15 100644 --- a/Makefile +++ b/Makefile @@ -68,13 +68,17 @@ gofmt: # Used by bot to auto-release # GH_TOKEN and SSH_PRIVATE_KEY are needed .PHONY: auto-release -auto-release: osc-api-check release-build release-push release-pr +auto-release: osc-api-check release-check-duplicate release-build release-push release-pr @echo OK .PHONY: osc-api-check osc-api-check: bash .github/scripts/osc-api-check.sh +.PHONY: release-check-duplicate +release-check-duplicate: + bash .github/scripts/release-check-duplicate.sh + .PHONY: release-build release-build: bash .github/scripts/release-build.sh