Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Shushlin <vshushlin@gitlab.com>2021-03-10 15:48:14 +0300
committerVladimir Shushlin <vshushlin@gitlab.com>2021-03-10 15:48:14 +0300
commit98c64e9552bdf27118b82bce664706af93b32b59 (patch)
tree8e0d0545557bd21b5a6bac027ccf02508ddbf951
parent7c293235c4eaca59b4665a32493ecd7269d2a52f (diff)
parentcdd5a1a7dcb2a22d144f9d105d2350e519f4dbcb (diff)
Merge branch 'add-changelog-script-gen' into 'master'
Add changelog generation script See merge request gitlab-org/gitlab-pages!447
-rw-r--r--.gitlab/issue_templates/release.md2
-rwxr-xr-x.gitlab/scripts/changelog.sh34
-rw-r--r--Makefile.internal.mk1
-rw-r--r--Makefile.util.mk8
4 files changed, 43 insertions, 2 deletions
diff --git a/.gitlab/issue_templates/release.md b/.gitlab/issue_templates/release.md
index fad7ecd6..9bfd7c7f 100644
--- a/.gitlab/issue_templates/release.md
+++ b/.gitlab/issue_templates/release.md
@@ -14,7 +14,7 @@
- [ ] Create an MR for [gitlab-pages project](https://gitlab.com/gitlab-org/gitlab-pages).
You can use [this MR](https://gitlab.com/gitlab-org/gitlab-pages/merge_requests/217) as an example.
- [ ] Update `VERSION`
- - [ ] Update `CHANGELOG`
+ - [ ] Update `CHANGELOG`, you can run `make changelog` once you have pushed your branch to the remote server
- [ ] Assign to reviewer
- [ ] Once `gitlab-pages` is merged create a signed+annotated tag pointing to the **merge commit** on the **stable branch**
In case of `master` branch:
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..09f13225 100644
--- a/Makefile.internal.mk
+++ b/Makefile.internal.mk
@@ -2,6 +2,7 @@ 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)
+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..91fa7ea5 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)' VERSION='$(VERSION)' BRANCH='$(BRANCH)' bash ./.gitlab/scripts/changelog.sh
+ifndef GITLAB_PRIVATE_TOKEN
+ $(error GITLAB_PRIVATE_TOKEN is undefined)
+endif