Updating Definitions #111
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. For fix use "post{N}", for beta use "beta{N}".' | |
required: true | |
type: string | |
default: 'beta1' | |
manual_openapi_client_pr_base_branch: | |
description: | | |
WARNING: Set this to the `main` branch for production releases! | |
This workflow will create a Pull Request (PR) for the `openapi-clients` repository and merge it into the specified base branch. | |
required: true | |
type: string | |
default: 'github-actions-test' | |
manual_sdk_pr_base_branch: | |
description: | | |
WARNING: Set this to the `main` branch for production releases! | |
This workflow will create a Pull Request (PR) for the `language-sdk` (e.g. `python-sdk`) repository and merge it into the specified base branch. | |
required: true | |
type: string | |
default: 'github-actions-test' | |
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: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.manual_sdk_pr_base_branch || vars.PYTHON_SDK_PR_BASE_BRANCH }} | |
python_sdk_branch: ${{ github.event_name == 'workflow_dispatch' && format('release-manual-{0}', github.event.inputs.version_postfix) || github.ref_name }} | |
version_postfix: ${{ github.event_name == 'workflow_dispatch' && 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 | |
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 "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.manual_openapi_client_pr_base_branch || vars.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" |