Generate SDKs #93
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 SDKs | |
on: | |
workflow_dispatch: | |
inputs: | |
version_postfix: | |
description: 'Additional version postfix for the SDK' | |
required: false | |
type: string | |
default: '' | |
push: | |
branches: | |
- 'release-**' | |
jobs: | |
preprocess-specifications: | |
name: Preprocess OpenAPI specifications | |
runs-on: ubuntu-22.04 | |
env: | |
ORIG_SPEC_DIR: ${{ github.workspace }}/res | |
SPEC_DIR: ${{ github.workspace }}/specs_preprocessed | |
PREPROCESSING_DIR: ${{ github.workspace }}/sdk-blueprints/preprocessing | |
steps: | |
- name: Checkout workflow repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Preprocess OpenAPI specifications | |
id: preprocess | |
run: | | |
python3 -m pip install -r $PREPROCESSING_DIR/requirements.txt | |
python3 $PREPROCESSING_DIR/preprocessing.py $ORIG_SPEC_DIR $SPEC_DIR | |
- name: Sanitize artifact name | |
id: sanitize | |
run: | | |
specs_artifact_name=$(echo "processed-specs-${{ github.ref_name }}" | tr -d '\r\n' | tr '":<>|*?\\/' '_') | |
echo "specs_artifact_name=$specs_artifact_name" >> $GITHUB_ENV | |
- name: Upload preprocessed specifications as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.specs_artifact_name }} | |
path: ${{ env.SPEC_DIR }} | |
retention-days: 7 | |
generate-python-sdk: | |
name: Generate Python SDK | |
needs: preprocess-specifications | |
uses: ./.github/workflows/generate-python-sdk.yml | |
secrets: inherit | |
with: | |
python_sdk_pr_base_branch: ${{ vars.PYTHON_SDK_PR_BASE_BRANCH }} | |
version_postfix: ${{ github.event.inputs.version_postfix }} | |
create-and-merge-pr: | |
name: Create and Merge Pull Request for release | |
needs: generate-python-sdk | |
runs-on: ubuntu-22.04 | |
env: | |
OPENAPI_CLIENT_PR_BASE_BRANCH: ${{ vars.OPENAPI_CLIENT_PR_BASE_BRANCH }} | |
permissions: | |
contents: write | |
pull-requests: write | |
outputs: | |
pr_number: ${{ steps.create_pr.outputs.pr_number }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Create a token | |
id: create-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.APP_ID }} | |
private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Create Pull Request for openapi-clients | |
id: create_pr | |
env: | |
GH_TOKEN: ${{ steps.create-token.outputs.token }} | |
run: | | |
pr_output=$(gh pr create \ | |
--title "PR for ${{ github.ref_name }}" \ | |
--body "This PR created automatically after pushing changes to language-sdk repos." \ | |
--head "${{ github.ref_name }}" \ | |
--base "${{ env.OPENAPI_CLIENT_PR_BASE_BRANCH }}") | |
pr_number=$(echo "$pr_output" | grep -oE '[0-9]+$') | |
echo "Pull Request #$pr_number created successfully." | |
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT | |
- name: Merge Pull Request | |
env: | |
GH_TOKEN: ${{ steps.create-token.outputs.token }} | |
run: | | |
gh pr merge ${{ steps.create_pr.outputs.pr_number }} \ | |
--squash \ | |
--delete-branch \ | |
--subject "Auto-merge: Update openapi" |