You can write a Python script to run a geoprocessing tool and publish it as a web tool or a geoprocessing service. This script automates a publishing workflow, even without using ArcGIS Pro. The primary method of using a script to publish is to use ArcPy.
After a customized tool runs successfully, use ArcPy to publish it as a web tool or a geoprocessing service. First, create a service definition draft file using the GeoProcessingSharingDraft class and CreateSharingDraft method. Then, create a service definition file using the Stage Service tool, and use the Upload Service Definition tool to complete the publishing process.
From ArcGIS Pro 3.2 or later, publish a script tool that publishes web tools or layers to any ArcGIS Enterprise deployment for a special workflow. In the script tool, ensure that the script signs into the portal and the script has sufficient publishing permissions.
You can still use the CreateGPSDDraft function to generate a service definition file, but the ability to control the service definition is limited.