Generate SDK #8
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 SDK | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: The SDK version to generate as "X.Y.Z". | |
default: "X.Y.Z" | |
required: true | |
type: string | |
openapi-generator-version: | |
description: The openapi-generator version to use. '' for the version used during the last generation, 'latest' for latest, 'x.y.z' for version x.y.z. | |
default: "latest" | |
required: true | |
type: string | |
jobs: | |
generate: | |
name: Generate SDK | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 10 | |
env: | |
OPENAPI_GENERATOR_VERSION: "${{ github.event.inputs.openapi-generator-version }}" | |
permissions: | |
contents: write | |
steps: | |
- name: Check Tag | |
run: | | |
if ! [[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then | |
echo "::error ::The provided version has incorrect format: it should match '[0-9]+\.[0-9]+\.[0-9]+(-.+)?'" 1>&2 | |
exit 1 | |
fi | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
- name: Setup Golang | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "stable" | |
- name: Generate SDK to check for changes | |
run: ./generate.sh | |
- name: Check for changes | |
id: check-changes | |
run: | | |
if ! git status --porcelain=v1 | grep -v -e openapitools.json -e .openapi-generator/VERSION | tee /dev/stderr | [ $(wc -l) -ne 0 ]; then | |
echo "::notice ::No changes to the MultiBaas SDK detected." 1>&2 | |
echo "regenerate=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Generate SDK with new package version | |
if: steps.check-changes.outputs.regenerate != 'false' | |
run: ./generate.sh ${{ github.event.inputs.version }} | |
- name: Setup Git Configurations | |
if: steps.check-changes.outputs.regenerate != 'false' | |
run: | | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "<>" | |
- name: Push and tag | |
if: steps.check-changes.outputs.regenerate != 'false' | |
run: | | |
git add . | |
git commit -am "Auto-generated SDK v${{ github.event.inputs.version }}" | |
git tag "v${{ github.event.inputs.version }}" main | |
git push origin "v${{ github.event.inputs.version }}" | |
git push origin main |