-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #471 from YaSuenag/pr/generate-java-webapi-client
Add GHA workflow for generating WebAPI client library for Java
- Loading branch information
Showing
134 changed files
with
256 additions
and
23,337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: 4.a-Generate WebAPI client libraries | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
registry: | ||
type: string | ||
required: true | ||
image-repo: | ||
type: string | ||
required: true | ||
tag: | ||
type: string | ||
required: false | ||
default: latest | ||
workflow_dispatch: | ||
inputs: | ||
registry: | ||
type: string | ||
required: false | ||
default: ghcr.io | ||
image-repo: | ||
type: string | ||
required: false | ||
default: "green-software-foundation/carbon-aware-sdk" | ||
tag: | ||
type: string | ||
required: false | ||
default: latest | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
detect-api-version: | ||
uses: ./.github/workflows/detect-webapi-version.yaml | ||
with: | ||
registry: ${{ inputs.registry }} | ||
image-repo: ${{ inputs.image-repo }} | ||
tag: ${{ inputs.tag }} | ||
|
||
generate-java-client: | ||
needs: detect-api-version | ||
uses: ./.github/workflows/4.a.1-generate-webapi-client-java.yaml | ||
with: | ||
image: ${{ needs.detect-api-version.outputs.image }} | ||
apiver: ${{ needs.detect-api-version.outputs.apiver }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: 4.a.1-Generate WebAPI client library for Java | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image: | ||
required: true | ||
type: string | ||
apiver: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
generate-java-client: | ||
runs-on: ubuntu-latest | ||
services: | ||
webapi: | ||
image: ${{ inputs.image }} | ||
ports: | ||
- 8080:8080 | ||
options: >- | ||
--health-cmd "curl -sS http://localhost:8080/health" | ||
--health-interval 3s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
permissions: | ||
packages: write | ||
env: | ||
API: http://localhost:8080/api/v1/swagger.yaml | ||
steps: | ||
- name: Prepare | ||
run: | | ||
mkdir work pages | ||
npm install -g @openapitools/[email protected] | ||
- name: Generate client library | ||
run: | | ||
echo '{"apiPackage": "foundation.greensoftware.carbonaware.webapi.client", "artifactDescription": "Carbon Aware SDK client library for Java", "artifactId": "casdk-client", "artifactVersion": "${{ inputs.apiver }}", "developerOrganization": "Green Software Foundation", "developerOrganizationUrl": "https://greensoftware.foundation/", "groupId": "foundation.greensoftware", "licenseName": "MIT License", "scmUrl": "${{ env.REPO }}", "artifactUrl": "${{ env.REPO }}/packages/", "scmConnection": "${{ github.repositoryUrl }}", "scmDeveloperConnection": "${{ github.repositoryUrl }}", "licenseUrl": "https://opensource.org/license/mit/", "developerName": "Green Software Foundation", "developerEmail": "[email protected]"}' > config.json | ||
openapi-generator-cli generate -i ${{ env.API }} -g java -o work -c config.json | ||
sed -i "s|</project>|<distributionManagement><repository><id>github</id><name>GitHub Packages</name><url>https://maven.pkg.github.com/${{ github.repository }}</url></repository></distributionManagement></project>|" work/pom.xml | ||
shell: bash | ||
- name: Setup Java 8 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 8 | ||
cache: maven | ||
- name: Run Maven | ||
run: mvn -B deploy javadoc:javadoc | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
working-directory: work | ||
- name: Upload Javadoc | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: javadoc | ||
path: work/target/apidocs | ||
|
||
push-javadoc: | ||
needs: generate-java-client | ||
concurrency: push-to-doc-website | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCPATH: casdk-docs/static/client-apidocs/${{ inputs.apiver }}/java | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Prepare | ||
run: mkdir -p ${{ env.DOCPATH }} | ||
- name: Download Javadoc | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: javadoc | ||
path: ${{ env.DOCPATH }} | ||
- name: Push Javadoc | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add ${{ env.DOCPATH }} | ||
git commit -m "Add Javadoc for WebAPI ${{ inputs.apiver }}" | ||
git push origin ${{ github.ref_name }} | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Detect API version from OpenAPI document in WebAPI container image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
registry: | ||
type: string | ||
required: true | ||
image-repo: | ||
type: string | ||
required: true | ||
tag: | ||
type: string | ||
required: false | ||
default: latest | ||
outputs: | ||
image: | ||
value: ${{ jobs.make-image-name-for-pull.outputs.image }} | ||
apiver: | ||
value: ${{ jobs.detect-api-version.outputs.apiver }} | ||
|
||
jobs: | ||
make-image-name-for-pull: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image: ${{ steps.make-image-name.outputs.IMAGE_NAME }} | ||
steps: | ||
- name: Make string for pulling container image | ||
id: make-image-name | ||
run: | | ||
REPO=${{ inputs.registry }}/${{ inputs.image-repo }} | ||
REPO_LOWER=${REPO,,} | ||
echo "IMAGE_NAME=$REPO_LOWER:${{ inputs.tag }}" >> "$GITHUB_OUTPUT" | ||
detect-api-version: | ||
needs: make-image-name-for-pull | ||
runs-on: ubuntu-latest | ||
services: | ||
webapi: | ||
image: ${{ needs.make-image-name-for-pull.outputs.image }} | ||
ports: | ||
- 8080:8080 | ||
options: >- | ||
--health-cmd "curl -sS http://localhost:8080/health" | ||
--health-interval 3s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
outputs: | ||
apiver: ${{ steps.detect-api-version.outputs.CURRENT_API_VERSION }} | ||
steps: | ||
- name: Detect API version | ||
id: detect-api-version | ||
run: | | ||
API_VERSION=`curl -sS http://localhost:8080/api/v1/swagger.yaml | yq -r .info.version` | ||
echo "CURRENT_API_VERSION=$API_VERSION" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.