Workflow file for this run
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
name: Generate WebAPI client library for Java | |
on: | |
workflow_call: | |
inputs: | |
image: | |
required: true | |
type: string | |
jpbs: | |
generate-java-client: | |
runs-on: ubuntu-latest | |
services: | |
webapi: | |
image: ${{ inputs.image }} | |
ports: | |
- 8080:80 | |
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 -s ${{ env.API }} | yq -r .info.version` | |
echo "${{ inputs.image }}" | grep -E ':pre$' | |
if [ $? -eq 0 ]; then | |
API_VERSION="$API_VERSION-SNAPSHOT" | |
fi | |
echo "API_VERSION=$API_VERSION" >> "$GITHUB_OUTPUT" | |
- name: Prepare | |
run: | | |
mkdir work pages | |
npm install -g @openapitools/openapi-generator-cli@2.5.2 | |
- 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: Prepare to upload Javadoc | |
run: | | |
mkdir -p pages/java | |
mv work/target/apidocs pages/java/${{ steps.detect-api-version.outputs.API_VERSION }} | |
shell: bash | |
- name: Upload Javadoc | |
uses: actions/upload-artifact@v3 | |
with: | |
name: javadoc | |
path: pages |