Further automate the creation of the stable branch
- Add a current_milestone task helper to automate the stable branch creation. This is effectively almost the same as the method used in
scripts/tw-milestone-plan.rb
- Add a Makefile rule to run the task. This might be a bit overkill to have
make
runrake
, but for the sake of not having two different tools invoked by folks running the docs release, I opted to add this.
Test locally
-
Check out this branch.
-
Run the make rule:
make create-stable-branch
-
The stable branch
15.10
should be created and a new15.10.Dockerfile
should be committed to the branch.
Eventually the task will fail to complete, because the 15.10
branch is already present and a push is forbidden (protected branch). This is normal and expected for this test. In a real scenario, the task will successfully complete.
Here's what you'll see:
❯ make create-stable-branch
INFO: Creating stable branch...
bundle exec rake release:single
INFO: (gitlab-docs): Stashing local changes...
INFO: (gitlab-docs): Checking out main branch and pulling updates...
Switched to branch 'main'
From gitlab.com:gitlab-org/gitlab-docs
* branch main -> FETCH_HEAD
INFO: (gitlab-docs): Creating branch 15.10...
Switched to a new branch '15.10'
INFO: (gitlab-docs): Creating file 15.10.Dockerfile...
INFO: (gitlab-docs): Adding file 15.10.Dockerfile and commiting changes to branch 15.10...
INFO: (gitlab-docs): Pushing branch 15.10. Don't create a merge request...
To gitlab.com:gitlab-org/gitlab-docs.git
! [rejected] 15.10 -> 15.10 (non-fast-forward)
error: failed to push some refs to 'gitlab.com:gitlab-org/gitlab-docs.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
And if you want to test this in the Ruby console:
❯ irb
irb(main):001:0> require_relative 'lib/tasks/task_helpers.rb'
=> true
irb(main):002:0> tasks = TaskHelpers.new
=> #<TaskHelpers:0x00007f6da986ea48>
irb(main):003:0> tasks.current_milestone
=> "15.10"
Edited by Achilleas Pipinellis