Add automatization script

parent 587d2fdb
Pipeline #21405735 passed with stages
in 25 minutes and 17 seconds
/label ~"CI/CD"
/label ~release
/label ~Deliverable
/milestone %"X.Y"
/assign MENTION_RELEASE_MANAGER_HERE
/milestone %"{{.Major}}.{{.Minor}}"
/assign @{{.ReleaseManagerHandle}}
# GitLab Runner X.Y release checklist
# GitLab Runner {{.Major}}.{{.Minor}} release checklist
GitLab Runner Release manager: **MENTION_RELEASE_MANAGER_HERE**
GitLab Runner Release manager: **@{{.ReleaseManagerHandle}}**
Release blog post MR: **LINK_HERE**
Release blog post MR: **gitlab-com/www-gitlab-com!{{.ReleaseBlogPostMR}}**
Runner entries need to be added to blog post until: **DEADLINE_FOR_RUNNER_ITEMS_ADDITION_INTO_BLOG_POST_HERE**
Runner entries need to be added to blog post until: **{{.ReleaseBlogPostDeadline}}**
Technical description of the release, with commands examples, can be found at:
https://gitlab.com/gitlab-org/gitlab-runner/blob/master/docs/release_process/how_to_release_runner.md
......@@ -26,22 +26,22 @@ https://gitlab.com/gitlab-org/gitlab-runner/blob/master/docs/release_process/how
deadline for 7th working day before 22nd, however if the deadline from the MR is earlier, then
use the eraliest one.
- [ ] Update the `X.Y.` and `X-Y-` to a specific release version
- [ ] Update the `.Major` and `.Minor` to a specific release version
## First working day after 7th - **vX.Y.0-rc1 release**
## First working day after 7th - **v{{.Major}}.{{.Minor}}.0-rc1 release**
- [ ] check if Pipeline for `master` is passing: [![pipeline status](https://gitlab.com/gitlab-org/gitlab-runner/badges/master/pipeline.svg)](https://gitlab.com/gitlab-org/gitlab-runner/commits/master)
- [ ] add all required fixes to make `master` Pipeline passing
- [ ] add **vX.Y.0-rc1** CHANGELOG entries
- [ ] tag and push **vX.Y.0-rc1**
- [ ] create and push `X-Y-stable` branch
- [ ] checkout to `master`, update `VERSION` file to `X.Y+1.0` and push `master`
- [ ] deploy **vX.Y.0-rc1** (https://gitlab.com/gitlab-com/runbooks/blob/master/howto/update-gitlab-runner-on-managers.md)
- [ ] add **v{{.Major}}.{{.Minor}}.0-rc1** CHANGELOG entries
- [ ] tag and push **v{{.Major}}.{{.Minor}}.0-rc1**
- [ ] create and push `{{.Major}}-{{.Minor}}-stable` branch
- [ ] checkout to `master`, update `VERSION` file to `{{.Major}}.{{inc .Minor}}.0` and push `master`
- [ ] deploy **v{{.Major}}.{{.Minor}}.0-rc1** (https://gitlab.com/gitlab-com/runbooks/blob/master/howto/update-gitlab-runner-on-managers.md)
_New features_ window is closed - things not merged into `master` up to
this day, will be released with next release.
## 7 working days before 22th (**DEADLINE_FOR_RUNNER_ITEMS_ADDITION_INTO_BLOG_POST_HERE**)
## 7 working days before 22th (**{{.ReleaseBlogPostDeadline}}**)
- [ ] prepare entries for the release blog post. Items can be generated with `./scripts/changelog2releasepost | less`
- [ ] add release entry:
......@@ -49,19 +49,19 @@ this day, will be released with next release.
Add description to the `SECONDARY FEATURES` list using following template:
```markdown
- name: GitLab Runner X.Y
- name: GitLab Runner {{.Major}}.{{.Minor}}
available_in: [core, starter, premium, ultimate]
documentation_link: 'https://docs.gitlab.com/runner'
documentation_text: "Read through the documentation on GitLab Runner"
documentation_text: "Read through the documentation of GitLab Runner"
description: |
We're also releasing GitLab Runner X.Y today! GitLab Runner is the open source project
We're also releasing GitLab Runner {{.Major}}.{{.Minor}} today! GitLab Runner is the open source project
that is used to run your CI/CD jobs and send the results back to GitLab.
##### Most interesting changes:
* [__Title__](https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/__ID__)
List of all changes can be found in GitLab Runner's [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-runner/blob/vX.Y.0/CHANGELOG.md).
List of all changes can be found in GitLab Runner's [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-runner/blob/v{{.Major}}.{{.Minor}}.0/CHANGELOG.md).
```
## At 20th - next RC release
......@@ -69,11 +69,11 @@ this day, will be released with next release.
At this day we should release an RC version, if there was no RC recently - especially
if the only RC version was the _RC1_ released near 7th day of month.
- [ ] check if Pipeline for `X-Y-stable` is passing: [![pipeline status](https://gitlab.com/gitlab-org/gitlab-runner/badges/X-Y-stable/pipeline.svg)](https://gitlab.com/gitlab-org/gitlab-runner/commits/X-Y-stable)
- [ ] add all required fixes to make `X-Y-stable` Pipeline passing
- [ ] add **vX.Y.0-rcZ** CHANGELOG entries
- [ ] tag **vX.Y.0-rcZ**
- [ ] deploy **vX.Y.0-rcZ** (https://gitlab.com/gitlab-com/runbooks/blob/master/howto/update-gitlab-runner-on-managers.md)
- [ ] check if Pipeline for `{{.Major}}-{{.Minor}}-stable` is passing: [![pipeline status](https://gitlab.com/gitlab-org/gitlab-runner/badges/{{.Major}}-{{.Minor}}-stable/pipeline.svg)](https://gitlab.com/gitlab-org/gitlab-runner/commits/{{.Major}}-{{.Minor}}-stable)
- [ ] add all required fixes to make `{{.Major}}-{{.Minor}}-stable` Pipeline passing
- [ ] add **v{{.Major}}.{{.Minor}}.0-rcZ** CHANGELOG entries
- [ ] tag **v{{.Major}}.{{.Minor}}.0-rcZ**
- [ ] deploy **v{{.Major}}.{{.Minor}}.0-rcZ** (https://gitlab.com/gitlab-com/runbooks/blob/master/howto/update-gitlab-runner-on-managers.md)
## At 22th - the release day
......@@ -96,11 +96,11 @@ When deciding to release a new RC version, please update the checklist using the
template:
```markdown
## At _day here_ - **vX.Y.0-rcZ** release
## At _day here_ - **v{{.Major}}.{{.Minor}}.0-rcZ** release
- [ ] check if Pipeline for `X-Y-stable` is passing: [![pipeline status](https://gitlab.com/gitlab-org/gitlab-runner/badges/X-Y-stable/pipeline.svg)](https://gitlab.com/gitlab-org/gitlab-runner/commits/X-Y-stable)
- [ ] add all required fixes to make `X-Y-stable` Pipeline passing
- [ ] add **vX.Y.0-rcZ** CHANGELOG entries
- [ ] tag **vX.Y.0-rcZ**
- [ ] deploy **vX.Y.0-rcZ** (https://gitlab.com/gitlab-com/runbooks/blob/master/howto/update-gitlab-runner-on-managers.md)
- [ ] check if Pipeline for `{{.Major}}-{{.Minor}}-stable` is passing: [![pipeline status](https://gitlab.com/gitlab-org/gitlab-runner/badges/{{.Major}}-{{.Minor}}-stable/pipeline.svg)](https://gitlab.com/gitlab-org/gitlab-runner/commits/{{.Major}}-{{.Minor}}-stable)
- [ ] add all required fixes to make `{{.Major}}-{{.Minor}}-stable` Pipeline passing
- [ ] add **v{{.Major}}.{{.Minor}}.0-rcZ** CHANGELOG entries
- [ ] tag **v{{.Major}}.{{.Minor}}.0-rcZ**
- [ ] deploy **v{{.Major}}.{{.Minor}}.0-rcZ** (https://gitlab.com/gitlab-com/runbooks/blob/master/howto/update-gitlab-runner-on-managers.md)
```
......@@ -394,6 +394,16 @@ check-tags-in-changelog:
echo "$$tag: \t $$state"; \
done
prepare_release_checklist_issue: opts ?= ""
prepare_release_checklist_issue: major := $(shell cat VERSION | awk -F'.' '{print $$1}')
prepare_release_checklist_issue: minor := $(shell cat VERSION | awk -F'.' '{print $$2}')
prepare_release_checklist_issue:
@go run ./scripts/prepare_release_checklist_issue.go \
-issue-template-file ".gitlab/issue_templates/Release Checklist.md" \
-major $(major) \
-minor $(minor) \
$(opts)
development_setup:
test -d tmp/gitlab-test || git clone https://gitlab.com/gitlab-org/gitlab-test.git tmp/gitlab-test
if prlctl --version ; then $(MAKE) -C tests/ubuntu parallels ; fi
......
package main
import (
"bufio"
"bytes"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"text/template"
)
type ReleaseMetadata struct {
Major int
Minor int
ReleaseManagerHandle string
ReleaseBlogPostMR int
ReleaseBlogPostDeadline string
}
const GITLAB_RUNNER_PROJECT_ID = "gitlab-org/gitlab-runner"
var reader *bufio.Reader
var releaseMetadata ReleaseMetadata
var templateFilePath = flag.String("issue-template-file", ".gitlab/issue_templates/Release Checklist.md", "Path to a file with issue template")
var dryRun = flag.Bool("dry-run", false, "Show issue content instead of creating it in GitLab")
var noInteractive = flag.Bool("no-interactive", false, "Don't ask, just try to work!")
var major = flag.String("major", "", "Major version number")
var minor = flag.String("minor", "", "Minor version number")
var releaseManagerHandle = flag.String("release-manager-handle", "", "GitLab.com handle of the release manager")
var releaseBlogPostMR = flag.String("release-blog-post-mr", "", "ID of the Release Blog Post MR")
var releaseBlogPostDeadline = flag.String("release-blog-post-deadline", "", "Deadline for adding Runner specific content to the Release Blog Post")
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\n %s [OPTIONS]\n\nOptions:\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
prepareMetadata()
content := prepareIssueContent()
title := prepareIssueTitle()
if *dryRun {
printIssue(title, content)
} else {
postIssue(title, content)
}
}
func prepareMetadata() {
var err error
askOnce("Major version number:", major)
releaseMetadata.Major, err = strconv.Atoi(*major)
if err != nil {
panic(err)
}
askOnce("Minor version number:", minor)
releaseMetadata.Minor, err = strconv.Atoi(*minor)
if err != nil {
panic(err)
}
askOnce("GitLab.com handle of the release manager:", releaseManagerHandle)
releaseMetadata.ReleaseManagerHandle = *releaseManagerHandle
askOnce("ID of the Release Blog Post MR:", releaseBlogPostMR)
releaseMetadata.ReleaseBlogPostMR, err = strconv.Atoi(*releaseBlogPostMR)
if err != nil {
panic(err)
}
askOnce("Deadline for adding Runner specific content to the Release Blog Post:", releaseBlogPostDeadline)
releaseMetadata.ReleaseBlogPostDeadline = *releaseBlogPostDeadline
}
func askOnce(prompt string, result *string) {
if *noInteractive {
return
}
fmt.Println(prompt)
if *result != "" {
fmt.Printf("[%s]: ", *result)
}
if reader == nil {
reader = bufio.NewReader(os.Stdin)
}
data, _, err := reader.ReadLine()
if err != nil {
panic(err)
}
newResult := string(data)
newResult = strings.TrimSpace(newResult)
if newResult != "" {
*result = newResult
}
if *result == "" {
panic("Can't be left empty!")
}
}
func prepareIssueContent() string {
data, err := ioutil.ReadFile(*templateFilePath)
if err != nil {
panic(err)
}
tpl := template.New("release-issue")
tpl.Funcs(template.FuncMap{
"inc": func(i int) int {
return i + 1
},
})
tpl, err = tpl.Parse(string(data))
if err != nil {
panic(err)
}
var output []byte
buffer := bytes.NewBuffer(output)
err = tpl.Execute(buffer, releaseMetadata)
if err != nil {
panic(err)
}
return buffer.String()
}
func prepareIssueTitle() string {
return fmt.Sprintf("GitLab Runner %d.%d release checklist", releaseMetadata.Major, releaseMetadata.Minor)
}
func printIssue(title, content string) {
fmt.Println()
fmt.Println("====================================")
fmt.Printf(" Title: %s\n", title)
fmt.Printf("Content:\n\n%s\n", content)
fmt.Println("====================================")
fmt.Println()
}
type createIssueOptions struct {
Title string `json:"title"`
Description string `json:"description"`
}
type createIssueResponse struct {
WebURL string `json:"web_url"`
}
func postIssue(title, content string) {
newIssueURL := fmt.Sprintf("https://gitlab.com/api/v4/projects/%s/issues", url.QueryEscape(GITLAB_RUNNER_PROJECT_ID))
options := &createIssueOptions{
Title: title,
Description: content,
}
jsonBody, err := json.Marshal(options)
if err != nil {
panic(err)
}
req, err := http.NewRequest(http.MethodPost, newIssueURL, bytes.NewBuffer(jsonBody))
if err != nil {
panic(err)
}
token := os.Getenv("GITLAB_API_PRIVATE_TOKEN")
req.Header.Set("Private-Token", token)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
var response createIssueResponse
err = json.Unmarshal(body, &response)
if err != nil {
panic(err)
}
fmt.Printf("Created new issue: %s", response.WebURL)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment