Custom variables and/or stable workflow ID variable
In our release process with knope, we run a PrepareRelease step and raise the release changes on a PR for the rest of the team to review.
As part of our workflow file we manually checkout a branch like so before committing:
[[workflows.steps]]
type = "Command"
command = "git switch -C knope-release"
...
[[workflows.steps]]
type = "Command"
command = "git add ."
At the end of the workflow, once pushed, we delete the local branch so a user can re-run a release next time without a branch conflict because they're the same name.
I saw in the steps reference, there's a SwitchBranches but it seems to only support changing to a branch based on a Jira issue title/name/ID. It would be cool if we could:
- Use another source into this step, like a variable to target a custom branch without needing Jira
- Have some way to tell
SwitchBranchesto generate a branch ID for us, to make unique release branches. PerhapsSwitchBranchesalways generates a short UID and passes it as a variable, so we can make our custom branch name likerelease-$UIDor however we'd like.
I think point 2 might be more controversial, but for us it would make sense to have something like release-abcdefg because we run a monorepo with many versions so it wouldn't make sense to have a release/0.0.1 branch. The unique ID would help avoiding local branch conflicts.
What do you think of this feature?
SwitchBranches is really just a shortcut to
[[workflows.steps]]
type = "Command"
command = "git switch -C $issueBranch"
variables = { "$issueBranch" = "IssueBranch" }
I've actually been thinking about getting rid of that dedicated step since it's pretty niche and I think the only reason we keep the git2 dependency around. I don't have any stats on usage, though.
If you don't need to clean up the local branch, you could do something like this to start?
[[workflows.steps]]
type = "Command"
shell = true
command = "git switch -C release/$(uuidgen)"
I could see having some sort of unique, but stable within a workflow ID as being valuable. Maybe $workflowUUID to be specific? It's probably also a good idea to add a SetVariable step or something in the future so you could do something like:
[[workflows.steps]]
type = "SetVariable"
name = "ReleaseID"
command = "uuidgen"
[[workflows.steps]]
type = "Command"
command = "git switch -C release/$id"
variables = { "$id" = "ReleaseID" }
...
[[workflows.steps]]
type = "Command"
command = "git branch -d release/$id"
variables = { "$id" = "ReleaseID" }