actions icon indicating copy to clipboard operation
actions copied to clipboard

Move `master` branch to `main`

Open jennybc opened this issue 2 years ago • 19 comments

The master branch of this repository will soon be renamed to main, as part of a coordinated change across several GitHub organizations (including, but not limited to: tidyverse, r-lib, tidymodels, and sol-eng). We anticipate this will happen by the end of September 2021.

That will be preceded by a release of the usethis package, which will gain some functionality around detecting and adapting to a renamed default branch. There will also be a blog post at the time of this master --> main change.

The purpose of this issue is to:

  • Help us firm up the list of targetted repositories
  • Make sure all maintainers are aware of what's coming
  • Give us an issue to close when the job is done
  • Give us a place to put advice for collaborators re: how to adapt

message id: euphoric_snowdog

jennybc avatar Sep 08 '21 00:09 jennybc

I think this is a bad idea for this particular repo, because people almost everywhere have this in their workflow:

https://github.com/r-lib/actions/blob/55aea734d73636a0617990c2899c8f86ef8a9877/.github/workflows/check-full.yaml#L43

Because the yml assumes the action lives in @master this will break all those workflows.

jeroen avatar Sep 09 '21 20:09 jeroen

That's workflow config for this repo itself (which presumably should be updated).

But the examples we encourage other people to use (and that usethis grabs) use other tags, e.g., v1:

https://github.com/r-lib/actions/blob/55aea734d73636a0617990c2899c8f86ef8a9877/examples/check-full.yaml#L48

This has been true for "a while".

jennybc avatar Sep 09 '21 22:09 jennybc

So, I think if someone notices that the branch renaming breaks their GHA, it might have a healthy effect of nudging them to update their workflows.

jennybc avatar Sep 09 '21 22:09 jennybc

OK, I did not know that @v1 was the recommended branch. A quick GH search shows about half of the workflows use @master... perhaps we can leave the master branch around for a bit longer for backward compat (just a copy of main).

jeroen avatar Sep 10 '21 08:09 jeroen

Even if workflows do use master GitHub sets up automatic redirection when you rename the branch via their API.

When you rename a branch on GitHub, any URLs that contain the old branch name are automatically redirected to the equivalent URL for the renamed branch.

https://docs.github.com/en/github/administering-a-repository/managing-branches-in-your-repository/renaming-a-branch

jimhester avatar Sep 10 '21 12:09 jimhester

Though potentially this could still impact the actions here as raw git pull requests are not affected

Although file URLs are automatically redirected, raw file URLs are not redirected. Also, GitHub does not perform any redirects if users perform a git pull for the previous branch name.

jimhester avatar Sep 10 '21 12:09 jimhester

So maybe we would have to do this (I should really read the whole article before commenting 😁)

GitHub Actions workflows do not follow renames, so if your repository publishes an action, anyone using that action with @{old-branch-name} will break. You should consider adding a new branch with the original content plus an additional commit reporting that the branch name is deprecated and suggesting that users migrate to the new branch name.

jimhester avatar Sep 10 '21 12:09 jimhester

But anyway I agree with @jeroen that we need to be more careful when renaming this repo vs others.

jimhester avatar Sep 10 '21 12:09 jimhester

I have an exclusion list to omit specific repos that are otherwise covered by my "whole org" approach (of which r-lib is one).

Should I put r-lib/actions on the exclusion list? That's what I'm hearing.

jennybc avatar Sep 10 '21 16:09 jennybc

yes, we will need to be careful in how we change this one, likely adding a deprecation message to actions used from 'master' after the switch happens.

jimhester avatar Sep 10 '21 17:09 jimhester

OK, r-lib/actions is now excluded from my current bulk renaming effort re: default branch. I'll leave this issue open, since it sounds like the switch will eventually happen, but in a more customized way, on a different schedule.

jennybc avatar Sep 10 '21 17:09 jennybc

Maybe for this repo the default branch should be v1 instead of main such that we don't need to keep moving the tag for every bug fix. Many other action repos use e.g. v1 and v2 for their moving branches, and for tags (if any) they use v1.2.3

jeroen avatar Sep 14 '21 20:09 jeroen

I'm about to do the master --> main push in bulk now and have just reminded myself to exclude this one. Correct me if I'm wrong.

Whenever this gets dealt with, we also need to think about this bit at the top of all example workflows:

# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help

Should master be replaced with main, HEAD, v1?

jennybc avatar Oct 27 '21 17:10 jennybc

We can keep master around for a while and make the soon to be official v2 branch the default.

gaborcsardi avatar Dec 09 '21 17:12 gaborcsardi

For the record, this is mostly done in v2. The next steps will be to document v2 and how the tags work in general in the main README, and then making v2 the default branch. This will happen once we tested v2 a bit.

gaborcsardi avatar Dec 12 '21 22:12 gaborcsardi

I was updating a broken GHA workflows and reflexively specified r-lib/actions/setup-r@main, assuming main is the new master. I saw:

Error: Unable to resolve action `r-lib/actions@main`, unable to find version `main`

Of course I should have checked first. I only comment to say that, since the expectation is now for main to be the default, I expect many more will encounter this same issue.

t-kalinowski avatar Dec 13 '21 17:12 t-kalinowski

Do not use master or main, the former is arbitrary, and will be obsolete, the latter will probably never exist. Use v1 for the "current" actions, or v2 for the one coming soon: https://github.com/r-lib/actions/releases/tag/v2

gaborcsardi avatar Dec 13 '21 18:12 gaborcsardi

FYI usethis will gain some awareness of these version issues: https://github.com/r-lib/usethis/issues/1541

jennybc avatar Dec 13 '21 19:12 jennybc

Now the v2-branch is the default. master is still around, and will be around for a while.

At some point I'll add a warning to the actions that use @master, to point them to using @v2, and then a couple of months later delete master.

We can keep this issue around until all this is done.

gaborcsardi avatar Dec 14 '21 10:12 gaborcsardi

I just renamed master to old, I am pretty sure that it is mostly defunct now, anyway.

gaborcsardi avatar Oct 19 '22 12:10 gaborcsardi

wondering why all my cron actions suddenly broke.

For anyone who stumbles on this after googling Error: Unable to resolve action r-lib/actions@master change it to @v2 and you should be back in action.

PatLittle avatar Oct 19 '22 21:10 PatLittle

I am sorry for the inconvenience. @master was never meant for public use, actually, and many @v2 actions are much better than @master, which is still available under the name @old, so hopefully the switch will improve your workflows.

gaborcsardi avatar Oct 19 '22 21:10 gaborcsardi

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue

github-actions[bot] avatar Nov 04 '22 13:11 github-actions[bot]