Skip to content

feat!: run build by default before deploy #7195

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

Merged

Conversation

ndhoule
Copy link
Contributor

@ndhoule ndhoule commented Apr 10, 2025

Summary

This updates the deploy command to run the configured build command before deployment by default. Previously, this was achieved by passing the --build flag.

To opt into the previous behavior, users can now specify netlify deploy --no-build.

Why are we changing this?

This has long been one of the most common sources of confusion with the Netlify CLI. Developers expect a "deploy" command to deploy their project. We're making this change to follow the Principle of Least Surprise and streamline the experience for new users.

Upgrading

(most common) Build and deploy

Remove the --build flag:

netlify deploy --build [...] # before

netlify deploy [...] # after

Separate build and deploy

Warning

Make sure your deploy command runs in your expected environment, e.g. if you were running FOO=bar netlify build && netlify deploy, make sure FOO is visible to the deploy command, which is now running the build: FOO=bar netlify deploy.

Collapse into one command, if you can:

netlify build && netlify deploy # before

netlify deploy # after

Otherwise, add the --no-build flag:

make spaghetti && netlify deploy # before

make spaghetti && netlify deploy --no-build # after

(rare) Deploy without build step

Add the --no-build flag:

netlify deploy [...] # before (there was no `--build` here)

netlify deploy --no-build [...]

Copy link

github-actions bot commented Apr 10, 2025

📊 Benchmark results

Comparing with 0d48c28

  • Dependency count: 1,150 (no change)
  • Package size: 280 MB (no change)
  • Number of ts-expect-error directives: 404 (no change)

@ndhoule ndhoule changed the base branch from main to nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default--refactor-types April 10, 2025 23:00
@ndhoule ndhoule force-pushed the nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default branch 4 times, most recently from fa80263 to 5f44426 Compare April 11, 2025 22:13
@ndhoule ndhoule force-pushed the nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default--refactor-types branch from 9dc32fe to 24376c5 Compare April 16, 2025 21:04
Base automatically changed from nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default--refactor-types to main April 16, 2025 21:30
@ndhoule ndhoule force-pushed the nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default branch from 5f44426 to 6a799b0 Compare April 16, 2025 21:31
@serhalp serhalp force-pushed the nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default branch from 6a799b0 to a4ab697 Compare April 29, 2025 12:20
@serhalp serhalp self-assigned this Apr 29, 2025
@serhalp serhalp force-pushed the nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default branch from a4ab697 to 433b1c4 Compare April 29, 2025 19:44
This small change updates the `deploy` command to run the configured
`build` command before deployment.

Users who prefer the previous behavior can opt out by specifying
`--no-build` when running `netlify deploy`.
@serhalp serhalp force-pushed the nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default branch from 433b1c4 to db74b2a Compare April 29, 2025 19:53
@serhalp serhalp marked this pull request as ready for review April 29, 2025 20:43
@serhalp serhalp requested review from a team as code owners April 29, 2025 20:43
@@ -109,7 +109,19 @@ Support for package.json's main field, and intrinsic index.js entrypoints are co
'build',
),
)
.option('--build', 'Run build command before deploying', false)
.addOption(
new Option('--build', 'Do not use - this is now the default. Will be removed in future versions.')
Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW I don't think this string can ever be seen

Copy link
Contributor

@sarahetter sarahetter Apr 30, 2025

Choose a reason for hiding this comment

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

Yeah these only get added to generated cli.netlify.com docs

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, because we have hideHelp() it isn't even included there

Copy link
Contributor

@sarahetter sarahetter left a comment

Choose a reason for hiding this comment

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

😎

@serhalp serhalp merged commit 8e95c58 into main Apr 30, 2025
52 checks passed
@serhalp serhalp deleted the nathanhoule/cpla-2545-change-ntl-deploy-to-build-by-default branch April 30, 2025 22:26
serhalp added a commit that referenced this pull request May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants