Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 2b-generate-java-client.yaml #359

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/2-pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ concurrency:
jobs:
publish-container-image:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.retrieve-container-image.outputs.CONTAINER_IMAGE }}
permissions:
packages: write
steps:
Expand Down Expand Up @@ -92,3 +94,18 @@ jobs:
package-name: carbon-aware-sdk
package-type: container
package-version-ids: ${{ steps.list-older-images.outputs.REMOVE_IMAGES }}
- name: Retrieve container image
id: retrieve-container-image
run: |
CONTAINER_IMAGE=`echo "$DOCKER_METADATA_OUTPUT_TAGS" | head -n 1 | cut -d ':' -f 1`
echo "CONTAINER_IMAGE=$CONTAINER_IMAGE" > "$GITHUB_OUTPUT"

publish-java-client:
needs: publish-container-image
permissions:
packages: write
contents: write
uses: ./.github/workflows/2b-generate-java-client.yaml
with:
image: ${{ needs.publish-container-image.outputs.image }}
tag: pre
96 changes: 96 additions & 0 deletions .github/workflows/2b-generate-java-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Generate WebAPI client library for Java

on:
workflow_call:
inputs:
image:
required: true
type: string
tag:
required: true
type: string

jobs:
generate-java-client:
runs-on: ubuntu-latest
outputs:
apiver: ${{ steps.detect-api-version.outputs.API_VERSION }}
services:
webapi:
image: ${{ inputs.image }}:${{ inputs.tag }}
ports:
- 8080:80
options: >-
--health-cmd "curl -sS http://localhost/health"
--health-interval 3s
--health-timeout 5s
--health-retries 5
permissions:
packages: write
env:
API: http://localhost:8080/api/v1/swagger.yaml
REPO: ${{ github.server_url }}/${{ github.repository }}
steps:
- name: Detect API version
id: detect-api-version
run: |
API_VERSION=`curl -sS ${{ env.API }} | yq -r .info.version`
if [ "${{ inputs.tag }}" = "pre" ]; then
API_VERSION="$API_VERSION-SNAPSHOT"
fi
echo "API_VERSION=$API_VERSION" >> "$GITHUB_OUTPUT"
- name: Prepare
run: |
mkdir work pages
npm install -g @openapitools/[email protected]
- name: Generate client library
run: |
echo '{"apiPackage": "foudation.greensoftware.carbonaware.webapi.client", "artifactDescription": "Carbon Aware SDK client library for Java", "artifactId": "casdk-client", "artifactVersion": "${{ steps.detect-api-version.outputs.API_VERSION }}", "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": null}' > 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@v3
with:
distribution: temurin
java-version: 8
- name: Run Maven
run: mvn -B deploy javadoc:javadoc
env:
GITHUB_TOKEN: ${{ github.token }}
working-directory: work
- name: Upload Javadoc
uses: actions/upload-artifact@v3
with:
name: javadoc
path: work/target/apidocs

push-javadoc:
needs: generate-java-client
concurrency: push-to-doc-website
runs-on: ubuntu-latest
env:
DOCPATH: docs/apidocs/${{ needs.generate-java-client.outputs.apiver }}/java
permissions:
contents: write
steps:
- name: Checkout doc-website branch
uses: actions/checkout@v3
with:
ref: doc-website
- name: Prepare
run: mkdir -p ${{ env.DOCPATH }}
- name: Download Javadoc
uses: actions/download-artifact@v3
with:
name: javadoc
path: ${{ env.DOCPATH }}
- name: Push Javadoc
run: |
git config --global user.name "Green-Software-Foundation"
git config --global user.email "[email protected]"
git add ${{ env.DOCPATH }}
git commit -m "Add Javadoc for WeebAPI ${{ needs.generate-java-client.outputs.apiver }}"
git push origin doc-website
env:
GITHUB_TOKEN: ${{ github.token }}
17 changes: 17 additions & 0 deletions .github/workflows/4-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ env:
jobs:
publish-container-image:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.retrieve-container-image.outputs.CONTAINER_IMAGE }}
permissions:
packages: write
steps:
Expand Down Expand Up @@ -41,3 +43,18 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
- name: Retrieve container image
id: retrieve-container-image
run: |
CONTAINER_IMAGE=`echo "$DOCKER_METADATA_OUTPUT_TAGS" | head -n 1 | cut -d ':' -f 1`
echo "CONTAINER_IMAGE=$CONTAINER_IMAGE" > "$GITHUB_OUTPUT"

publish-java-client:
needs: publish-container-image
permissions:
packages: write
contents: write
uses: ./.github/workflows/2b-generate-java-client.yaml
with:
image: ${{ needs.publish-container-image.outputs.image }}
tag: latest