Reputation: 59
Hi I wonder if this scenario is even possible.
I am using openapi-generator with typescript-axios generator option and want to know if it can be automated as below.
This is my initial thought.
I tired this with below work flow but published package doesn't contain generated code. Any help would be appreciated.
name: Node.js Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run-script build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
and my package.json
{
"name": "my-api-client",
"version": "1.0.0",
"description": "Openapi generated typescript-axios client",
"main": "index.js",
"scripts": {
"test": "echo \\\"Error: no test specified\\\" && exit 1",
"build": "openapi-generator-cli generate -g typescript-axios -o src -i https://myapi.com/swagger.json --type-mappings=DateTime=Date && tsc"
},
"keywords": [
"typescript-axios",
"client"
],
"license": "ISC",
"dependencies": {
"axios": "^0.21.0",
"typescript": "^3.8.3"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "^2.0.3",
"@types/node": "^13.9.0"
}
}```
Thank you
Upvotes: 1
Views: 762
Reputation: 59
I accidently add src and lib folder and that was the reason my published package didn't contain those folders. After fixing .gitignore everything works fine.
So basically, my project will only contain package.json and whenever I create a release tag, it will trigger above Github workflow and publish a new openapi-generated client sdk to npm.
Upvotes: 1