Skip to content

Commit

Permalink
Merge pull request #1736 from intuit/support-main
Browse files Browse the repository at this point in the history
Support "main" as a default "baseBranch"
  • Loading branch information
hipstersmoothie committed Jan 21, 2021
2 parents 8802b0e + 4f534da commit be24135
Show file tree
Hide file tree
Showing 45 changed files with 301 additions and 236 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

---

<div align="center"><a href="https://circleci.com/gh/intuit/auto"><img src="https://img.shields.io/circleci/project/github/intuit/auto/master.svg?style=flat-square&logo=circleci" alt="CircleCI" /></a> <a href="https://codecov.io/gh/intuit/auto"><img src="https://img.shields.io/codecov/c/github/intuit/auto.svg?style=flat-square&logo=codecov" alt="Codecov" /></a> <a href="https://www.npmjs.com/package/auto"><img src="https://img.shields.io/npm/v/auto.svg?style=flat-square&logo=npm" alt="npm" /></a> <a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-30-orange.svg?style=flat-square&logo=github" alt="All Contributors" /></a> <a href="https://www.npmjs.com/package/auto"><img src="https://img.shields.io/npm/dt/auto.svg?style=flat-square&logo=npm" alt="npm" /></a> <a href="https://github.com/intuit/auto"><img src="https://img.shields.io/badge/release-auto.svg?style=flat-square&colorA=888888&amp;colorB=9B065A&amp;label=auto&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAACzElEQVR4AYXBW2iVBQAA4O+/nLlLO9NM7JSXasko2ASZMaKyhRKEDH2ohxHVWy6EiIiiLOgiZG9CtdgG0VNQoJEXRogVgZYylI1skiKVITPTTtnv3M7+v8UvnG3M+r7APLIRxStn69qzqeBBrMYyBDiL4SD0VeFmRwtrkrI5IjP0F7rjzrSjvbTqwubiLZffySrhRrSghBJa8EBYY0NyLJt8bDBOtzbEY72TldQ1kRm6otana8JK3/kzN/3V/NBPU6HsNnNlZAz/ukOalb0RBJKeQnykd7LiX5Fp/YXuQlfUuhXbg8Di5GL9jbXFq/tLa86PpxPhAPrwCYaiorS8L/uuPJh1hZFbcR8mewrx0d7JShr3F7pNW4vX0GRakKWVk7taDq7uPvFWw8YkMcPVb+vfvfRZ1i7zqFwjtmFouL72y6C/0L0Ie3GvaQXRyYVB3YZNE32/+A/D9bVLcRB3yw3hkRCdaDUtFl6Ykr20aaLvKoqIXUdbMj6GFzAmdxfWx9iIRrkDr1f27cFONGMUo/gRI/jNbIMYxJOoR1cY0OGaVPb5z9mlKbyJP/EsdmIXvsFmM7Ql42nEblX3xI1BbYbTkXCqRnxUbgzPo4T7sQBNeBG7zbAiDI8nWfZDhQWYCG4PFr+HMBQ6l5VPJybeRyJXwsdYJ/cRnlJV0yB4ZlUYtFQIkMZnst8fRrPcKezHCblz2IInMIkPzbbyb9mW42nWInc2xmE0y61AJ06oGsXL5rcOK1UdCbEXiVwNXsEy/6+EbaiVG8eeEAfxvaoSBnCH61uOD7BS1Ul8ESHBKWxCrdyd6EYNKihgEVrwOAbQruoytuBYIFfAc3gVN6iawhjKyNCEpYhVJXgbOzARyaU4hCtYizq5EI1YgiUoIlT1B7ZjByqmRWYbwtdYjoWoN7+LOIQefIqKawLzK6ID69GGpQgwhhEcwGGUzfEPAiPqsCXadFsAAAAASUVORK5CYII=" alt="Auto Release" /></a> <a href="https://app.snyk.io/org/hipstersmoothie/project/f32a03c3-9884-4fc9-9ac5-525c48799d4c"><img src="https://img.shields.io/snyk/vulnerabilities/github/intuit/auto/package.json.svg?style=flat-square&logo=snyk&logoColor=lightgrey" alt="" /></a> <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fintuit%2Fauto?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fintuit%2Fauto.svg?type=shield"/></a>
<div align="center"><a href="https://circleci.com/gh/intuit/auto"><img src="https://img.shields.io/circleci/project/github/intuit/auto/main.svg?style=flat-square&logo=circleci" alt="CircleCI" /></a> <a href="https://codecov.io/gh/intuit/auto"><img src="https://img.shields.io/codecov/c/github/intuit/auto.svg?style=flat-square&logo=codecov" alt="Codecov" /></a> <a href="https://www.npmjs.com/package/auto"><img src="https://img.shields.io/npm/v/auto.svg?style=flat-square&logo=npm" alt="npm" /></a> <a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-30-orange.svg?style=flat-square&logo=github" alt="All Contributors" /></a> <a href="https://www.npmjs.com/package/auto"><img src="https://img.shields.io/npm/dt/auto.svg?style=flat-square&logo=npm" alt="npm" /></a> <a href="https://github.com/intuit/auto"><img src="https://img.shields.io/badge/release-auto.svg?style=flat-square&colorA=888888&amp;colorB=9B065A&amp;label=auto&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAACzElEQVR4AYXBW2iVBQAA4O+/nLlLO9NM7JSXasko2ASZMaKyhRKEDH2ohxHVWy6EiIiiLOgiZG9CtdgG0VNQoJEXRogVgZYylI1skiKVITPTTtnv3M7+v8UvnG3M+r7APLIRxStn69qzqeBBrMYyBDiL4SD0VeFmRwtrkrI5IjP0F7rjzrSjvbTqwubiLZffySrhRrSghBJa8EBYY0NyLJt8bDBOtzbEY72TldQ1kRm6otana8JK3/kzN/3V/NBPU6HsNnNlZAz/ukOalb0RBJKeQnykd7LiX5Fp/YXuQlfUuhXbg8Di5GL9jbXFq/tLa86PpxPhAPrwCYaiorS8L/uuPJh1hZFbcR8mewrx0d7JShr3F7pNW4vX0GRakKWVk7taDq7uPvFWw8YkMcPVb+vfvfRZ1i7zqFwjtmFouL72y6C/0L0Ie3GvaQXRyYVB3YZNE32/+A/D9bVLcRB3yw3hkRCdaDUtFl6Ykr20aaLvKoqIXUdbMj6GFzAmdxfWx9iIRrkDr1f27cFONGMUo/gRI/jNbIMYxJOoR1cY0OGaVPb5z9mlKbyJP/EsdmIXvsFmM7Ql42nEblX3xI1BbYbTkXCqRnxUbgzPo4T7sQBNeBG7zbAiDI8nWfZDhQWYCG4PFr+HMBQ6l5VPJybeRyJXwsdYJ/cRnlJV0yB4ZlUYtFQIkMZnst8fRrPcKezHCblz2IInMIkPzbbyb9mW42nWInc2xmE0y61AJ06oGsXL5rcOK1UdCbEXiVwNXsEy/6+EbaiVG8eeEAfxvaoSBnCH61uOD7BS1Ul8ESHBKWxCrdyd6EYNKihgEVrwOAbQruoytuBYIFfAc3gVN6iawhjKyNCEpYhVJXgbOzARyaU4hCtYizq5EI1YgiUoIlT1B7ZjByqmRWYbwtdYjoWoN7+LOIQefIqKawLzK6ID69GGpQgwhhEcwGGUzfEPAiPqsCXadFsAAAAASUVORK5CYII=" alt="Auto Release" /></a> <a href="https://app.snyk.io/org/hipstersmoothie/project/f32a03c3-9884-4fc9-9ac5-525c48799d4c"><img src="https://img.shields.io/snyk/vulnerabilities/github/intuit/auto/package.json.svg?style=flat-square&logo=snyk&logoColor=lightgrey" alt="" /></a> <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fintuit%2Fauto?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fintuit%2Fauto.svg?type=shield"/></a>
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square&logo=producthunt" alt="code style: prettier" /></a></div>

<br />
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/blog/pr-in-progress.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ date: "Thu, 12 Mar 2020 23:00:02 -0700"

Sometimes you are working on a big feature and you know it will require a lot of changes. These types of pull requests can be a nightmare to review. Taking in all the changes at once can be overwhelming. It makes it easy to miss smaller mistakes and can make it hard to guess the intent of the changes. Multiple features, bug fixes, or even breaking changes may make up this large PR.

One way to manage this problem is by making a PR to the large PR. Other contributors can review a smaller subset of changes and also follow along with development. In previous versions of `auto`, large PRs would not be represented well in the changelog and release notes. It would only include the main PR that got merged into master as the only changelog note.
One way to manage this problem is by making a PR to the large PR. Other contributors can review a smaller subset of changes and also follow along with development. In previous versions of `auto`, large PRs would not be represented well in the changelog and release notes. It would only include the main PR that got merged into `baseBranch` as the only changelog note.

But thanks to [this PR](https://github.com/intuit/auto/pull/359) that isn't true anymore! Now when you merge one PR to another both changes will be represented in the changelog.

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/blog/using-shipit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ date: 'Thu, 12 Mar 2020 23:00:02 -0700'

The main command most users use to interact with `auto` is the shipit command. shipit does all the heaving lifting when releasing your code.

When run on master it will:
When run on `baseBranch` it will:

1. Determine if the last merged PR needs to be released
2. Update a CHANGELOG.md with all you new changes
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/blog/v8.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Run `auto next` from `feature` branch => Publish prerelease to `beta` tag.

The `shipit` command will now also publish a prerelease when ran from a prerelease branch. You can use this in a few different ways:

1. Two release branches: `master` and `next`
1. Two release branches: `baseBranch` and `next`
2. Without `next` Branch (`--only-graduate-with-release-label`)
3. Multiple `next` Branches (ex: `alpha`, `beta`, `rc`)
4. Feature Pre-releases
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/build-platforms/circleci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: CircleCI

The following config declares the `release` job and uses it in the `build_and_release` workflow. The `release` job will run at the end of each build and either release:

- a new `latest` version from `master`
- a new `latest` version from `baseBranch`
- a `canary` build from a pull request (if your package manager plugin implements them)

```yaml
Expand Down Expand Up @@ -51,5 +51,5 @@ Go to Settings -> Checkout SSH Keys -> `Create and add YOUR_USERNAME user key`.

## Examples

- [`auto`](https://github.com/intuit/auto/blob/master/.circleci/config.yml)
- [`auto`](https://github.com/intuit/auto/blob/main/.circleci/config.yml)
- [`reaction`](https://github.com/artsy/reaction/blob/master/.circleci/config.yml)
2 changes: 1 addition & 1 deletion docs/pages/docs/build-platforms/github-actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: GitHub Actions

The following config declares the `release` action that run on all branches. The job will either release:

- a new `latest` version from `master`
- a new `latest` version from `baseBranch`
- a `canary` build from a pull request (only on the main fork and if your package manager plugin implements them)

**`.github/workflows/release.yml`**
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/docs/build-platforms/jenkins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Jenkins 2

The following config declares the `release` action that run on all branches. The job will either release:

- a new `latest` version from `master`
- a new `latest` version from `baseBranch`
- a `canary` build from a pull request (only on the main fork and if your package manager plugin implements them)

**`Jenkinsfile`**
Expand Down Expand Up @@ -74,13 +74,13 @@ pipeline {
}
}
stage('Latest') {
when { branch 'master' }
when { branch 'main' }
steps {
// Jenkins will leave you in a detached HEAD state during builds
// Make sure to checkout your baseBranch here or the push will fail!
// The error will look like the following:
// error: src refspec master does not match any
sh 'git checkout master'
// error: src refspec main does not match any
sh 'git checkout main'
sh 'auto shipit'
}
}
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/docs/build-platforms/travis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Travis CI

The following config declares the `deploy` job that run on all branches. The job will either release:

- a new `latest` version from `master`
- a new `latest` version from `baseBranch`
- a `canary` build from a pull request (if your package manager plugin implements them)

**`.travis.yml`**
Expand Down Expand Up @@ -44,12 +44,12 @@ To fix this add the following lines to your `.travis.yml`

```yml
before_deploy:
- if [ "$TRAVIS_BRANCH" == "master" ];then
git checkout master;
- if [ "$TRAVIS_BRANCH" == "main" ];then
git checkout main;
fi;
```

This code will ensure that your git HEAD is on master when creating a new release.
This code will ensure that your git HEAD is on `baseBranch` when creating a new release.

### Canary Deploy Failing on Forks

Expand Down
3 changes: 2 additions & 1 deletion docs/pages/docs/configuration/autorc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Configure the default release behavior.

### Base Branch

Configure what your repo considers the "master" branch.
Configure what your repo considers the base branch.
Defaults to either `main` or `master`.

```json
{
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/extras/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _From #371_

#### 💥 Breaking Change

- shipit will publish a canary locally when not on master [#371](https://github.com/intuit/auto/pull/371) ([@hipstersmoothie](https://github.com/hipstersmoothie))
- shipit will publish a canary locally when not on `baseBranch` [#371](https://github.com/intuit/auto/pull/371) ([@hipstersmoothie](https://github.com/hipstersmoothie))

#### Authors: 1

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/extras/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ fi

Running `auto label` without the PR number will:

- When run in master will get the labels for the last merged PR
- When run in `baseBranch` will get the labels for the last merged PR
- When run for a PR in CI will use the PR's number
4 changes: 2 additions & 2 deletions docs/pages/docs/extras/shipit.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Read more about preparing you project for pre-releases [here](./next#setting-up-

#### "next" Branch (default)

The suggested way to create pre-releases is by managing 2 branches for your repo: `master` and `next`.
`master` contains the `latest` stable version of the code, and `next` contains future updates.
The suggested way to create pre-releases is by managing 2 branches for your repo: `baseBranch` and `next`.
`baseBranch` contains the `latest` stable version of the code, and `next` contains future updates.

You can change what branches `auto` treats as pre-release branches in your [`.autorc`](../configuration/autorc#prerelease-branches).

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/welcome/quick-merge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you merge a PR while another is publishing:
- they might try to publish the same version number
- one will try to push over the other's changes and fail

> If you ensure that the last build on master has finished you shouldn't run into any problems!
> If you ensure that the last build on `baseBrach` has finished you shouldn't run into any problems!
### Beware Long Publishes

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ In the `Tag version` field enter the version number you just tagged and click `P
The following are options that might be more useful to set in the `.autorc` than with a flag:

```txt
baseBranch Configure what your repo considers the "master" branch.
baseBranch Configure what your repo considers the base branch.
plugins Specify your plugins to load
githubApi If you are using enterprise github, `auto` lets you configure the github API URL that it uses.
githubGraphqlApi If you are using enterprise github and your company hosts the graphql at some other URL than the
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/parse-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const defaultOptions: AutoOption[] = [
const baseBranch: AutoOption = {
name: "base-branch",
type: String,
description: 'Branch to treat as the "master" branch',
description: "Branch to treat as the base branch",
group: "global",
};

Expand Down Expand Up @@ -515,7 +515,7 @@ export const commands: AutoCommand[] = [
defaultValue: false,
group: "main",
description:
'Make auto publish prerelease versions when merging to master. Only PRs merged with "release" label will generate a "latest" release. Only use this flag if you do not want to maintain a prerelease branch, and instead only want to use master.',
'Make auto publish prerelease versions when merging to baseBranch. Only PRs merged with "release" label will generate a "latest" release. Only use this flag if you do not want to maintain a prerelease branch, and instead only want to use baseBranch.',
config: true,
},
],
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/__snapshots__/auto.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exports[`Auto createLabels should create the labels 1`] = `

exports[`Auto should extend config 1`] = `
Object {
"baseBranch": "master",
"baseBranch": "main",
"extends": "@artsy/auto-config/package.json",
"labels": Array [
Object {
Expand Down Expand Up @@ -171,7 +171,7 @@ Object {

exports[`Auto should extend local config 1`] = `
Object {
"baseBranch": "master",
"baseBranch": "main",
"extends": "<PROJECT_ROOT>fake.json",
"labels": Array [
Object {
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/__tests__/__snapshots__/changelog.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ exports[`generateReleaseNotes should add "Push to Next" 1`] = `
#### ⚠️ Pushed to \`next\`
- I was a push to master ([email protected])
- I was a push to main ([email protected])
#### Authors: 1
Expand Down Expand Up @@ -110,7 +110,7 @@ exports[`generateReleaseNotes should be able to customize pushToBaseBranch title
#### Custom Title
- I was a push to master ([email protected])
- I was a push to main ([email protected])
#### Authors: 1
Expand Down Expand Up @@ -183,9 +183,9 @@ exports[`generateReleaseNotes should include PR-less commits as patches 1`] = `
- First Feature [#1235](https://github.custom.com/foobar/auto/pull/1235) ([email protected])
#### ⚠️ Pushed to \`master\`
#### ⚠️ Pushed to \`main\`
- I was a push to master ([email protected])
- I was a push to main ([email protected])
#### Authors: 1
Expand All @@ -195,7 +195,7 @@ exports[`generateReleaseNotes should include PR-less commits as patches 1`] = `
exports[`generateReleaseNotes should include PR-less commits as the default label 1`] = `
"#### 🚀 Enhancement
- I was a push to master ([email protected])
- I was a push to main ([email protected])
- First Feature [#1235](https://github.custom.com/foobar/auto/pull/1235) ([email protected])
#### Authors: 1
Expand Down Expand Up @@ -298,7 +298,7 @@ exports[`generateReleaseNotes should order the section major, minor, patch, then
#### 🐛 Bug Fix
- I was a push to master ([email protected])
- I was a push to main ([email protected])
#### 📝 Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ exports[`Release generateReleaseNotes should include PR-less commits 1`] = `
- First Feature [#1235](https://github.com/web/site/pull/1235) ([email protected])
#### ⚠️ Pushed to \`master\`
#### ⚠️ Pushed to \`main\`
- I should be included ([email protected])
Expand Down Expand Up @@ -116,9 +116,9 @@ exports[`Release generateReleaseNotes should match rebased commits to PRs 1`] =
- Feature [#124](https://github.com/web/site/pull/124) ([email protected])
- I was rebased [#123](https://github.com/web/site/pull/123) ([email protected])
#### ⚠️ Pushed to \`master\`
#### ⚠️ Pushed to \`main\`
- I am a commit to master ([email protected])
- I am a commit to main ([email protected])
#### Authors: 1
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/auto-canary-local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock("@octokit/rest", () => {
return { Octokit };
});

test("shipit should publish canary in locally when not on master", async () => {
test("shipit should publish canary in locally when not on baseBranch", async () => {
const auto = new Auto({ ...defaults, plugins: [] });
auto.logger = dummyLog();
// @ts-ignore
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/__tests__/auto-ci-base-branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ jest.mock("env-ci");
const envSpy = envCi as jest.Mock;
envSpy.mockImplementation(() => ({
isCi: true,
branch: "master",
branch: "main",
}));

import { Auto } from "../auto";

const defaults = {
baseBranch: "main",
owner: "foo",
repo: "bar",
};
Expand Down Expand Up @@ -51,13 +52,13 @@ describe("Auto", () => {
url: "https://google.com",
};

test("should exit successfully if ran from master + CI", async () => {
test("should exit successfully if ran from main + CI", async () => {
const auto = new Auto(defaults);
const exit = jest.fn();

envSpy.mockImplementationOnce(() => ({
isCi: true,
branch: "master",
branch: "main",
}));

// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/auto-make-changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jest

const importMock = jest.fn();
jest.mock("import-cwd", () => (path: string) => importMock(path));
jest.mock("env-ci", () => () => ({ isCi: false, branch: "master" }));
jest.mock("env-ci", () => () => ({ isCi: false, branch: "main" }));
jest.mock("../utils/exec-promise", () => () => Promise.resolve(""));

const defaults = {
Expand Down
Loading

0 comments on commit be24135

Please sign in to comment.