Feature/course statistics (#21) #135
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: Publish API client derived from spec | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-ALPHA.[0-9]+' | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: OpenAPI Generator Action | |
uses: kpurdon/[email protected] | |
with: | |
args: "generate -i openapi.yaml -g typescript-fetch -o ./client" | |
- name: Assign client ownership to runner | |
run: sudo chown -R runner client | |
- id: get_version | |
uses: battila7/[email protected] | |
- name: Generate package.json | |
env: | |
TAG_VERSION: ${{ steps.get_version.outputs.version-without-v }} | |
working-directory: ./client | |
run: | | |
cat <<EOF > package.json | |
{ | |
"name": "@polito/api-client", | |
"version": "$TAG_VERSION", | |
"repository":"https://github.com/polito/api-spec" | |
} | |
EOF | |
cat package.json | |
echo -e "// @ts-nocheck\n$(cat runtime.ts)" > runtime.ts | |
# Fix for invalid type generated by GeoJSON spec reference | |
echo -e "// @ts-nocheck\n$(cat models/FeatureAllOfId.ts)" > models/FeatureAllOfId.ts | |
cat <<EOF > README.md | |
# PoliTO API Client | |
Autogenerated typescript-fetch client for the API of PoliTO, based on its [OpenAPI specification](https://github.com/polito/api-spec). | |
EOF | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: 16 | |
registry-url: 'https://npm.pkg.github.com' | |
- run: npm publish | |
working-directory: ./client | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |