How can I version my flow?

Prefect 2.0

You can attach an arbitrary version string to your flow and create separate deployments for each flow version.

Here is an example leveraging an environment variable to specify a flow version:

@flow(name="versioned_flow", version=os.getenv("GIT_COMMIT_SHA"))

Prefect 1.0

Prefect 1.0 automatically versions flows during registration based on changes to the flow’s metadata. If flow’s metadata changed since the last registration, Prefect 1.0 automatically increments your flow version and archives the previous one. This automatic versioning allows for bookkeeping and a correct reflection of the flow run’s history based on the flow version triggered by a specific flow run. This page provides a more detailed overview.