Green-Software-Foundation / carbon-aware-sdk

Carbon-Aware SDK
https://carbon-aware-sdk.greensoftware.foundation/
MIT License
485 stars 99 forks source link

Publish WebAPI client library for NPM #591

Open YaSuenag opened 6 days ago

YaSuenag commented 6 days ago

Pull Request

Issue Number: #590

Summary

Publish WebAPI client library for NPM

Changes

This PR adds new workflow to generate WebAPI client library for NPM. The artifact would be published to GitHub Packages, so the developer can integrate the library into their own project from GitHub Packages via npm install. (Note that the developer should set GitHub PAT. See GitHub document for details.)

Client library generation happen via both release workflow and workflow dispatch. After this PR, Both Java and NPM library would be pushed into GitHub Packages:

image

And also API documents for each bindings would be pushed into specified branch. main is set by default when the workflow is triggered by publishing new release. The commit would be happened by each bindings:

image

You can see API documents from my forked repo: https://github.com/YaSuenag/carbon-aware-sdk/tree/devel/generate-npm-client/casdk-docs/static/client-apidocs/1.0.0

Note that this PR fixed to specify OpenAPI document title and version from CarbonAwareVariablesConfiguration. It relates to the comment from @danuw in #471.

Checklist

Are there API Changes?

No

Is this a breaking change?

No

Anything else?

I recommend to run .github/workflows/4.a.1-generate-webapi-client-npm.yaml manually after merging this PR to generate client libraries - API version does not synchronize CASDK releases.

This PR Closes #590

danuw commented 12 hours ago

Notes from our conversation about the flow of changes following new client libraries and at what point we save the changes in history so we can have consistency on following releases (history of client libraries etc...)

--- Draft Notes ---

new changes -> dev

dev -> main -> release workflow -> container package

Container version - is SDK version
Doc is indexed on latest version of code

on new container package -> check api version
- If API version version is updated, client api for java, npm etc... will need to be updated
- If API version not updated in new container release, we do not need to update clients libraries 

If API version is updated and we need new client libraries to be generated, what is the impact on documentation and published documentation?

----
start workflow to generate API document -> create PR to dev -> if PR approved, doc is merged into dev branch and new PR to main -> if PR to main approved -> workflow creates a new client library and pushes to github

SDK v1.8: latest
CLib v1.0 : latest

----
start workflow to generate API document v1.1 -> workflow has automated tests for new client library v1.1:pre
 (1) workflow creates a new client libraries and pushes to github -> 1.1 marked as latest
 (2) publish container 
 (2) publish documentation
 (3) automated test & mark latest
 (4) create PR to dev (to keep history) -> if PR approved, doc is merged into dev branch