Generate SDK #27
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 | |
env: | |
# Go / Node / PostgreSQL version to use in the CI | |
NODE_VER: "20" | |
jobs: | |
generate: | |
name: Generate SDK | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
env: | |
OPENAPI_GENERATOR_VERSION: "${{ github.event.inputs.openapi-generator-version }}" | |
permissions: | |
contents: write | |
steps: | |
- name: Check Tag | |
id: 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: "${{ env.NODE_VER }}" | |
registry-url: https://registry.npmjs.org/ | |
- name: Generate SDK to check for changes | |
run: ./generate.sh | |
- name: Check for 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 "::error ::No changes to the Multibaas APIv0 specifications detected." 1>&2 | |
exit 1 | |
fi | |
- name: Generate SDK with new package version | |
run: ./generate.sh ${{ github.event.inputs.version }} | |
- name: Setup Git Configurations | |
run: | | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "<>" | |
- name: Push if there are changes | |
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 | |
- name: Publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
run: npm publish --access public |