'Can't deploy new version of published Google apps script app with Rest API

When trying to use https://developers.google.com/apps-script/api/reference/rest/v1/projects.deployments/update to update an existing deployment with a new version in clasp cli (https://github.com/google/clasp) I get error Read-only deployments may not be modified.

The deployment is a published/approved apps script project. So far I have worked around the problem by updating version manually in the GUI. Would be great if anyone knows how I can do that with the API.



Solution 1:[1]

Archived deployments are set to read-only, they can't be modified or deleted. you can find the solution in google documentation about managing deployments:

If you want to edit an archived deployment, you must redeploy it ...

If you need to deploy a new version then the solution is not to update the version of an existing deployment, but to make a new deployment with the new version.

Google documentation says:

A version is automatically created when you create a new deployment. You can also create a new version from an existing deployment ...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1