diff options
-rwxr-xr-x | .gitlab/scripts/changelog.sh | 34 | ||||
-rw-r--r-- | Makefile.internal.mk | 3 | ||||
-rw-r--r-- | Makefile.util.mk | 8 |
3 files changed, 43 insertions, 2 deletions
diff --git a/.gitlab/scripts/changelog.sh b/.gitlab/scripts/changelog.sh new file mode 100755 index 00000000..051f3e2d --- /dev/null +++ b/.gitlab/scripts/changelog.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -euo pipefail + +PUBLIC_PROJECT_ID='734943' # gitlab-org/gitlab-pages +SECURITY_PROJECT_ID='15685887' # gitlab-org/security/gitlab-pages + +if [[ "${SECURITY:-'0'}" == '1' ]] +then + PROJECT_ID="$SECURITY_PROJECT_ID" +else + PROJECT_ID="$PUBLIC_PROJECT_ID" +fi + +function generate_changelog() { + curl --header "PRIVATE-TOKEN: $TOKEN" \ + --data "version=$VERSION&branch=$BRANCH" \ + --fail \ + --silent \ + --show-error \ + "https://gitlab.com/api/v4/projects/$PROJECT_ID/repository/changelog" +} + +echo 'Updating changelog on the remote branch...' + +if generate_changelog +then + echo 'Updating local branch...' + git pull origin "$BRANCH" + echo 'The changelog has been updated' +else + echo "Failed to generate the changelog for version $VERSION on branch $BRANCH" + exit 1 +fi diff --git a/Makefile.internal.mk b/Makefile.internal.mk index 54e7f7da..5a3c9743 100644 --- a/Makefile.internal.mk +++ b/Makefile.internal.mk @@ -1,7 +1,8 @@ REVISION := $(shell git rev-parse --short HEAD || echo unknown) LAST_TAG := $(shell git describe --tags --abbrev=0) COMMITS := $(shell echo `git log --oneline $(LAST_TAG)..HEAD | wc -l`) -VERSION := $(shell cat VERSION) +export VERSION = $(shell cat VERSION) +export BRANCH = $(shell git rev-parse --abbrev-ref HEAD) ifneq (v$(VERSION),$(LAST_TAG)) VERSION := $(shell echo $(VERSION)~beta.$(COMMITS).g$(REVISION)) diff --git a/Makefile.util.mk b/Makefile.util.mk index da29e0c8..2c139eba 100644 --- a/Makefile.util.mk +++ b/Makefile.util.mk @@ -1,6 +1,6 @@ GOLANGCI_LINT_IMAGE := golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) -.PHONY: lint test race acceptance bench cover list deps-check deps-download +.PHONY: lint test race acceptance bench cover list deps-check deps-download changelog OUT_FORMAT ?= colored-line-number LINT_FLAGS ?= $(if $V,-v) @@ -59,3 +59,9 @@ deps-download: .GOPATH/.ok junit-report: .GOPATH/.ok bin/go-junit-report cat tests.out | ./bin/go-junit-report -set-exit-code > junit-test-report.xml + +changelog: + TOKEN='$(GITLAB_PRIVATE_TOKEN)' bash ./.gitlab/scripts/changelog.sh +ifndef GITLAB_PRIVATE_TOKEN + $(error GITLAB_PRIVATE_TOKEN is undefined) +endif |