Skip to content

Merge "REST: Use features of OpenAPI v3.1" #11

Merge "REST: Use features of OpenAPI v3.1"

Merge "REST: Use features of OpenAPI v3.1" #11

name: Publish REST API Client
on:
push:
branches: [ master ]
paths:
- repo/rest-api/src/RouteHandlers/openapi.json
jobs:
build-and-publish-api-client:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Define next package version
run: |
NEXT_PATCH_VERSION=$(npx semver $(npm view @wmde/wikibase-rest-api version) --increment patch)
CURRENT_OAS_DOC_INTERFACE_VERSION=$(npx semver --coerce $(jq -r .info.version repo/rest-api/src/RouteHandlers/openapi.json))
NEXT_VERSION=$(printf "$NEXT_PATCH_VERSION\n$CURRENT_OAS_DOC_INTERFACE_VERSION" | sort -V | tail -1)
echo "VERSION=$NEXT_VERSION" >> $GITHUB_ENV
- name: Build the API client
uses: addnab/docker-run-action@v3
with:
image: openapitools/openapi-generator-cli
options: -v ${{ github.workspace }}:/local -w /local
run: |
/usr/local/bin/docker-entrypoint.sh generate \
-i openapi-dereferenced.json \
-g javascript \
-o api-client \
--additional-properties=usePromises=true \
--additional-properties=projectName=@wmde/wikibase-rest-api \
--additional-properties=projectDescription="Wikibase REST API Client" \
--additional-properties=licenseName="BSD-3-Clause license" \
--additional-properties=projectVersion=${{ env.VERSION }}
- name: Install and build generated client
run: |
sudo chown -R $(whoami) api-client/
npm i --prefix api-client/
- name: Prepend a custom section to the generated README.md
run: |
# append the generated README to the custom one, but without the headline
tail -n +2 api-client/README.md >> .github/workflows/publishRestApiClient/README.md
mv .github/workflows/publishRestApiClient/README.md api-client/README.md
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.WMDE_NPM_AUTH_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.WMDE_NPM_AUTH_TOKEN }}" > ~/.npmrc
cd api-client/
npm publish --access public