Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#11 - create+switch default branch on release #12

Merged
merged 11 commits into from Jul 28, 2020

Conversation

Ocramius
Copy link
Member

@Ocramius Ocramius commented Jul 19, 2020

Fixes #11 by providing default logic for switching to a new default branch at
every release. Specifically:

  • when a newer release target branch exists, use that (i.e. release 1.2.3 => existing branch 1.5.x,
    switch to 1.5.x)
  • when a newer release branch does not exist, create it (i.e. release 1.2.3 => existing branch 1.2.x,
    create 1.3.x from 1.2.x, use 1.3.x)
  • when no release branches exist, skip entire execution

TODOs:

  • try this out in a sandbox repository
  • better documentation? (new feature/ files)
  • update examples
  • get rid of special handling for master, which is not interesting to us anymore
  • document token requirements

Note: it would be good to get this into 1.0.0, since it breaks BC by changing semantics around the master branch naming.

Fixes #11 by providing default logic for switching to a new default branch at
every release. Specifically:

 * when a newer release target branch exists, use that (i.e. release `1.2.3` => existing branch `1.5.x`,
   switch to `1.5.x`)
 * when a newer release branch does not exist, create it (i.e. release `1.2.3` => existing branch `1.2.x`,
   create `1.3.x` from `1.2.x`, use `1.3.x`)
 * when no release branches exist, skip entire execution

TODOs:

 * [ ] try this out in a sandbox repository
 * [ ] better documentation?
 * [ ] update examples
@Ocramius Ocramius added this to the 1.0.0 milestone Jul 19, 2020
@Ocramius Ocramius self-assigned this Jul 19, 2020
@Ocramius
Copy link
Member Author

Trying this out in the real world, it seems that my github actions GITHUB_TOKEN doesn't suffice for this sort of interaction, since that token cannot be used to PATCH /repos/:org/:name

Also tried to use a custom token, but no luck: pinging github support.

@Ocramius
Copy link
Member Author

Yep, seems like GITHUB_TOKEN is scoped too strictly for this: PATCH /repos/:org/:name is not possible with that, and instead a custom admin-alike token is needed.

Don't know yet what the precise scope for it is.

Using a custom token produced the expected results at https://github.com/Ocramius/just-trying-automated-releases/runs/888025697?check_suite_focus=true, in which, by releasing 1.1.0, branch 1.2.x was created, published, and the repository switched to it.

@Ocramius
Copy link
Member Author

Confirmed with github support:

The GITHUB_TOKEN is limited these permissions in the repository containing the workflow:

https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token

The following page details which GitHub App permissions are required for each endpoint and shows that making changes to the repository's settings, including changing the default branch, requires write on administration:

https://docs.github.com/en/rest/reference/permissions-required-for-github-apps#permission-on-administration

If you create a personal access token, the token will need the repo permission and will need to belong to a user with admin permissions on the repository.

…branches in their behavior expectations
…o longer considered the "next major" branch

This used to be an old convention of `doctrine/*` projects, and it is also gone from `doctrine/*`,
where the naming will likely be adjusted to make branch target versions more clear to contributors.
@Ocramius Ocramius force-pushed the feature/#11-add-default-branch-switching branch from 3426737 to 27709ee Compare July 27, 2020 19:57
Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly a few questions.

feature/automated-releases.feature Outdated Show resolved Hide resolved
feature/automated-releases.feature Show resolved Hide resolved
feature/automated-releases.feature Outdated Show resolved Hide resolved
feature/automated-releases.feature Outdated Show resolved Hide resolved
feature/default-branch-switching.feature Outdated Show resolved Hide resolved
Ocramius and others added 2 commits July 27, 2020 22:25
Co-authored-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Co-authored-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
README.md Show resolved Hide resolved
src/Git/Value/BranchName.php Show resolved Hide resolved
src/Git/Value/BranchName.php Outdated Show resolved Hide resolved
@Ocramius Ocramius changed the title Initial draft for #11 - create+switch default branch on release #11 - create+switch default branch on release Jul 28, 2020
@Ocramius Ocramius merged commit 1d4b0b9 into 1.0.x Jul 28, 2020
@Ocramius Ocramius deleted the feature/#11-add-default-branch-switching branch July 28, 2020 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add mechanism to automatically switch active branch on a new minor or major release
4 participants