Skip to content

Fixes patch blog post for single version

Mayra Cabrera requested to merge fixes-patch-project-for-single-version into master

What does this MR do and why?

Updates blog post code to use a single version when a patch release is prepared for a specific version. This commit fixes two bugs:

  • Removes the raise exception when no bug fixes are present. For example, when preparing an expedited patch release
  • Make sure the blog post template is compatible with a single version.

Related to gitlab-com/gl-infra/delivery#20058 (closed)

Test

Single version

I was able to reproduce the error by creating a patch release for a version that has no pressure: 16.8

[1] pry(main)> require 'release_tools/tasks'
=> true
[2] pry(main)> version = ReleaseTools::Version.new('16.8.8')
=> "16.8.8"
[3] pry(main)> prepare = ReleaseTools::Tasks::Release::Prepare.new(version)
=> #<ReleaseTools::Tasks::Release::Prepare:0x0000000110ae1468 @version="16.8.8">
[4] pry(main)> prepare.execute
.....
2024-04-17 10:36:52.423974 I ReleaseTools::PatchRelease::UnreleasedCommits -- Fetching unreleased commits -- {:project=>gitlab-org/omnibus-gitlab, :tag=>"16.8.7+ee.0", :branch=>"16-8-stable", :commits=>0}
2024-04-17 10:36:52.423995 I ReleaseTools::PatchRelease::UnreleasedMergeRequests -- Fetched unreleased merge requests -- {:project=>gitlab-org/omnibus-gitlab, :version=>"16.8.7", :count=>0}
Add blog post for  patch release.


NoMethodError: undefined method `tr' for nil:NilClass
from /Users/mayra-cabrera/code/release-tools/lib/release_tools/patch_release/blog_merge_request.rb:199:in `hyphenated_version'

With the fixes on this MR, I was able to create:

  1. Task issue gitlab-org/release/tasks#10226 (closed)
  2. Blog post gitlab-com/www-gitlab-com!134046 (closed)
  3. The task issue successfully referenced the blog post
  4. The blog post successfully links the issue
Issue Blog post
Screenshot_2024-04-17_at_1.22.27_p.m. Screenshot_2024-04-17_at_1.22.39_p.m.
Full log
[1] pry(main)> require 'release_tools/tasks'
=> true
[2] pry(main)> version = ReleaseTools::Version.new('16.8.8')
=> "16.8.8"
[3] pry(main)> prepare = ReleaseTools::Tasks::Release::Prepare.new(version)
=> #<ReleaseTools::Tasks::Release::Prepare:0x000000010f6ceae8 @version="16.8.8">
[4] pry(main)> prepare.execute
2024-04-19 09:49:21.547511 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:21 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/issues" -
2024-04-19 09:49:21.912690 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:21 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/milestones" -
2024-04-19 09:49:22.277449 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:22 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/milestones?id=gitlab-org%2Frelease%2Ftasks&include_ancestors=true&page=2&per_page=20&state=all" -
2024-04-19 09:49:22.687328 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:22 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/milestones?id=gitlab-org%2Frelease%2Ftasks&include_ancestors=true&page=3&per_page=20&state=all" -
2024-04-19 09:49:22.976445 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:22 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/milestones?id=gitlab-org%2Frelease%2Ftasks&include_ancestors=true&page=4&per_page=20&state=all" -
2024-04-19 09:49:23.322561 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:23 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/milestones?id=gitlab-org%2Frelease%2Ftasks&include_ancestors=true&page=5&per_page=20&state=all" -
2024-04-19 09:49:23.565843 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:23 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/milestones?id=gitlab-org%2Frelease%2Ftasks&include_ancestors=true&page=6&per_page=20&state=all" -
2024-04-19 09:49:23.866455 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:23 -0600] 200 "GET https://gitlab.com/api/v4/groups/gitlab-org/milestones" -
2024-04-19 09:49:24.171387 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:24 -0600] 200 "GET https://gitlab.com/api/v4/groups/gitlab-org/milestones?id=gitlab-org&include_ancestors=true&page=2&per_page=20&state=all" -
2024-04-19 09:49:24.442274 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:24 -0600] 200 "GET https://gitlab.com/api/v4/groups/gitlab-org/milestones?id=gitlab-org&include_ancestors=true&page=3&per_page=20&state=all" -
2024-04-19 09:49:24.702331 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:24 -0600] 200 "GET https://gitlab.com/api/v4/groups/gitlab-org/milestones?id=gitlab-org&include_ancestors=true&page=4&per_page=20&state=all" -
2024-04-19 09:49:25.017738 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:25 -0600] 200 "GET https://gitlab.com/api/v4/groups/gitlab-org/milestones?id=gitlab-org&include_ancestors=true&page=5&per_page=20&state=all" -
2024-04-19 09:49:26.782179 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:26 -0600] 201 "POST https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/issues" 6967
2024-04-19 09:49:27.346516 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:27 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/issues" -
2024-04-19 09:49:27.805736 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:27 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/issues" -
--> Issue "TEST - Release 16.8.8" created.
    https://gitlab.com/gitlab-org/release/tasks/-/issues/10226
2024-04-19 09:49:28.433326 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:28 -0600] 201 "POST https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/issues/10226/links" 26603
2024-04-19 09:49:28.994568 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:28 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Fbuild%2FCNG/repository/compare" -
2024-04-19 09:49:28.994851 I ReleaseTools::PatchRelease::UnreleasedCommits -- Fetching unreleased commits -- {:project=>gitlab-org/build/CNG, :tag=>"v16.8.7", :branch=>"16-8-stable", :commits=>0}
2024-04-19 09:49:28.994904 I ReleaseTools::PatchRelease::UnreleasedMergeRequests -- Fetched unreleased merge requests -- {:project=>gitlab-org/build/CNG, :version=>"16.8.7", :count=>0}
2024-04-19 09:49:29.375709 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:29 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Fgitaly/repository/compare" -
2024-04-19 09:49:29.375839 I ReleaseTools::PatchRelease::UnreleasedCommits -- Fetching unreleased commits -- {:project=>gitlab-org/gitaly, :tag=>"v16.8.7", :branch=>"16-8-stable", :commits=>0}
2024-04-19 09:49:29.375861 I ReleaseTools::PatchRelease::UnreleasedMergeRequests -- Fetched unreleased merge requests -- {:project=>gitlab-org/gitaly, :version=>"16.8.7", :count=>0}
2024-04-19 09:49:29.679559 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:29 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/compare" -
2024-04-19 09:49:29.679706 I ReleaseTools::PatchRelease::UnreleasedCommits -- Fetching unreleased commits -- {:project=>gitlab-org/gitlab, :tag=>"v16.8.7-ee", :branch=>"16-8-stable-ee", :commits=>0}
2024-04-19 09:49:29.679728 I ReleaseTools::PatchRelease::UnreleasedMergeRequests -- Fetched unreleased merge requests -- {:project=>gitlab-org/gitlab, :version=>"16.8.7", :count=>0}
2024-04-19 09:49:30.071596 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:30 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-pages/repository/compare" -
2024-04-19 09:49:30.071722 I ReleaseTools::PatchRelease::UnreleasedCommits -- Fetching unreleased commits -- {:project=>gitlab-org/gitlab-pages, :tag=>"v16.8.7", :branch=>"16-8-stable", :commits=>0}
2024-04-19 09:49:30.071751 I ReleaseTools::PatchRelease::UnreleasedMergeRequests -- Fetched unreleased merge requests -- {:project=>gitlab-org/gitlab-pages, :version=>"16.8.7", :count=>0}
2024-04-19 09:49:30.469468 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:30 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Fomnibus-gitlab/repository/compare" -
2024-04-19 09:49:30.469595 I ReleaseTools::PatchRelease::UnreleasedCommits -- Fetching unreleased commits -- {:project=>gitlab-org/omnibus-gitlab, :tag=>"16.8.7+ee.0", :branch=>"16-8-stable", :commits=>0}
2024-04-19 09:49:30.469616 I ReleaseTools::PatchRelease::UnreleasedMergeRequests -- Fetched unreleased merge requests -- {:project=>gitlab-org/omnibus-gitlab, :version=>"16.8.7", :count=>0}
2024-04-19 09:49:30.708654 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:30 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests" 2
2024-04-19 09:49:30.712870 I ReleaseTools::PatchRelease::BlogMergeRequest -- Created blog post file
2024-04-19 09:49:31.082977 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:31 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/repository/branches/create-16-8-8-post" -
2024-04-19 09:49:31.083196 I ReleaseTools::PatchRelease::BlogMergeRequest -- Created branch -- {:branch_name=>"create-16-8-8-post", :project=>"gitlab-com/www-gitlab-com"}
2024-04-19 09:49:31.083233 I ReleaseTools::PatchRelease::BlogMergeRequest -- Committing blog content -- {:project=>"gitlab-com/www-gitlab-com", :branch=>"create-16-8-8-post"}
2024-04-19 09:49:31.992953 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:31 -0600] 201 "POST https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/repository/commits" 728
2024-04-19 09:49:32.426906 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:32 -0600] 200 "GET https://gitlab.com/api/v4/groups/gitlab-org/milestones" -
2024-04-19 09:49:32.891937 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:32 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/issues" -
2024-04-19 09:49:33.092508 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:33 -0600] 200 "GET https://gitlab.com/api/v4/user" -
--> Blog Merge Request "Draft: Adding 16.8.8 blog post" created.
2024-04-19 09:49:34.052663 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:34 -0600] 201 "POST https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests" 2403
    https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/134046
2024-04-19 09:49:34.470296 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:34 -0600] 200 "GET https://gitlab.com/api/v4/projects/gitlab-com%2Fwww-gitlab-com/merge_requests" -
=> #<Gitlab::ObjectifiedHash:217580 {hash: {"id"=>145077622, "iid"=>10226, "project_id"=>5064907, "title"=>"TEST - Release 16.8.8", "description"=>"## Preparation\n\nStable branches for [GitLab Managed Versioning] projects are required to have a green pipeline\nto perform a patch release. For each of the following branches verify the pipeline is green:\n* GitLab\n  - [ ] [16-8-stable-ee](https://gitlab.com/gitlab-org/gitlab/-/commits/16-8-stable-ee)\n* cng-ee\n    - [ ] [16-8-stable](https://gitlab.com/gitlab-org/build/CNG/-/commits/16-8-stable)\n* gitaly\n    - [ ] [16-8-stable](https://gitlab.com/gitlab-org/gitaly/-/commits/16-8-stable)\n* gitlab-pages\n    - [ ] [16-8-stable](https://gitlab.com/gitlab-org/gitlab-pages/-/commits/16-8-stable)\n* omnibus-gitlab-ee\n    - [ ] [16-8-stable](https://gitlab.com/gitlab-org/omnibus-gitlab/-/commits/16-8-stable)\n\n\nIf a failure is found the resolution process differs between each project:\n* For GitLab project failures, follow the [broken stable branch] process.\n* For GitLab components, contact the maintainers and notify them about the failure.\n\n- [ ] Ensure that any post-deploy migrations in the stable branch have been executed on GitLab.com by [executing the post-deploy migration pipeline]:\n  `/chatops run post_deploy_migrations execute`.\n\n## Packaging\n\n- [ ] Check if mirroring synced stable branches to dev. If the output is :white_check_mark: for every repo, we can proceed to tag.\n      Note. If GitLab Canonical to Security mirroring has diverged on the default branch due to security merges this mirror is expected to show as a broken and can be safely ignored.\n\n   ```\n   /chatops run mirror status\n   ```\n- [ ] Tag `16.8.8` and **confirm the job has finished**:\n    ```sh\n    /chatops run release tag 16.8.8\n    ```\n- [ ] While waiting for packages to build, [review and complete the blog post]. => https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/134046\n  - If the blog post failed to generate, it can be generated manually from the release-tools project with `rake release:patch_release_blog_post`.\n- [ ] Check the progress of the EE/CE packages:\n  - [ ] EE: [16.8.8+ee.0](https://dev.gitlab.org/gitlab/omnibus-gitlab/-/commits/16.8.8+ee.0)\n  - [ ] CE: [16.8.8+ce.0](https://dev.gitlab.org/gitlab/omnibus-gitlab/-/commits/16.8.8+ce.0)\n\nNote this  may take a while (around 80 minutes).\n\n## Deploy\n\n- For patch releases, the only available environment for deploys is `release.gitlab.net`. All GitLab Inc. team members can login to that installation using their email address (through google oauth). \n- Deployment to release.gitlab.net will only be performed for the current release version. If a previous version is being released, you can move to the next section and begin publishing.\n\n### release.gitlab.net\n\n- Deployments to release.gitlab.net are performed automatically.\n\n<details>\n  <summary>Instructions to manually deploy if required.</summary>\n\nIf you need to manually run a deployment, you can do so as follows:\n\n```sh\n/chatops run deploy 16.8.8-ee.0 release\n```\n\n</details>\n\n- [ ] Verify the deployment to release.gitlab.net has successfully completed. A slack notification will be posted in `#announcements`.\n\n## Release\n\n\n**16.8.8**\n- [ ] Publish the packages via ChatOps:\n   ```\n   /chatops run publish 16.8.8\n   ```\n- [ ] Verify that the chatops `publish` pipeline created by running the above command succeeded.\n- [ ] Verify the `check-packages` job completes successfully on the [EE Pipeline](https://dev.gitlab.org/gitlab/omnibus-gitlab/-/commits/16.8.8+ee.0)\n- [ ] Verify the `check-packages` job completes successfully on the [CE Pipeline](https://dev.gitlab.org/gitlab/omnibus-gitlab/-/commits/16.8.8+ce.0)\n- [ ] Verify that Docker images appear on `hub.docker.com`: [EE](https://hub.docker.com/r/gitlab/gitlab-ee/tags) / [CE](https://hub.docker.com/r/gitlab/gitlab-ce/tags)\n\n\n## Final steps\n\n- [ ] Merge the blog post.\n- [ ] Notify the patch release has been published (`blog post link` needs to be replaced with the actual link).\n   ```\n   /chatops run notify \":mega: GitLab Patch Release: 16.8.8 has just been released: <blog post link>! Share this release blog post with your network to ensure broader visibility across our community.\"\n   ```\n- [ ] Create the `16.8.8` version on [version.gitlab.com](https://version.gitlab.com/versions/new?version=16.8.8).\n\n## Release Certification\n\nThe [release certification process](https://about.gitlab.com/handbook/ceo/chief-of-staff-team/jihu-support/release-certification.html) may apply to this release. cc @gitlab-com/gl-security/product-security/federal-application-security\n\n[broken stable branch]: https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/how-to-fix-broken-stable-branch.md\n[GitLab Managed Versioning]: https://gitlab.com/gitlab-org/release/docs/-/tree/master/components/managed-versioning\n[review and complete the blog post]: https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/patch/blog-post.md\n[executing the post-deploy migration pipeline]: https://gitlab.com/gitlab-org/release/docs/-/tree/master/general/post_deploy_migration#how-to-execute-post-deploy-migrations", "state"=>"opened", "created_at"=>"2024-04-19T15:49:25.732Z", "updated_at"=>"2024-04-19T15:49:35.179Z", "closed_at"=>nil, "closed_by"=>nil, "labels"=>["Monthly Release"], "milestone"=>{"id"=>3128143, "iid"=>94, "group_id"=>9970, "title"=>"16.8", "description"=>"", "state"=>"active", "created_at"=>"2023-06-02T08:12:00.651Z", "updated_at"=>"2023-08-22T21:36:14.839Z", "due_date"=>"2024-01-12", "start_date"=>"2023-12-16", "expired"=>true, "web_url"=>"https://gitlab.com/groups/gitlab-org/-/milestones/94"}, "assignees"=>[], "author"=>{"id"=>33100, "username"=>"mayra-cabrera", "name"=>"Mayra Cabrera", "state"=>"active", "locked"=>false, "avatar_url"=>"https://gitlab.com/uploads/-/system/user/avatar/33100/avatar.png", "web_url"=>"https://gitlab.com/mayra-cabrera"}, "type"=>"ISSUE", "assignee"=>nil, "user_notes_count"=>0, "merge_requests_count"=>0, "upvotes"=>0, "downvotes"=>0, "due_date"=>"2024-04-26", "confidential"=>false, "discussion_locked"=>nil, "issue_type"=>"issue", "web_url"=>"https://gitlab.com/gitlab-org/release/tasks/-/issues/10226", "time_stats"=>{"time_estimate"=>0, "total_time_spent"=>0, "human_time_estimate"=>nil, "human_total_time_spent"=>nil}, "task_completion_status"=>{"count"=>21, "completed_count"=>0}, "weight"=>nil, "blocking_issues_count"=>0, "has_tasks"=>false, "_links"=>{"self"=>"https://gitlab.com/api/v4/projects/5064907/issues/10226", "notes"=>"https://gitlab.com/api/v4/projects/5064907/issues/10226/notes", "award_emoji"=>"https://gitlab.com/api/v4/projects/5064907/issues/10226/award_emoji", "project"=>"https://gitlab.com/api/v4/projects/5064907", "closed_as_duplicate_of"=>nil}, "references"=>{"short"=>"#10226", "relative"=>"#10226", "full"=>"gitlab-org/release/tasks#10226"}, "severity"=>"UNKNOWN", "subscribed"=>true, "moved_to_id"=>nil, "service_desk_reply_to"=>nil, "epic_iid"=>nil, "epic"=>nil, "iteration"=>nil, "health_status"=>nil}}
[5] pry(main)> 2024-04-19 09:49:36.096631 D ReleaseTools::GitlabClient -- [HTTParty] [2024-04-19 09:49:36 -0600] 200 "PUT https://gitlab.com/api/v4/projects/gitlab-org%2Frelease%2Ftasks/issues/10226" -

Regular patch release (3 versions)

10:04:26  bundle exec pry --gem
[1] pry(main)> generator =  ReleaseTools::Security::ReleasePreparation::GenerateBlogPost.new
[2] pry(main)> generator.execute
Blog post linking to the tracking issue
Screenshot_2024-04-19_at_10.08.57_a.m.

Author Check-list

  • [-] Has documentation been updated?
Edited by Mayra Cabrera

Merge request reports