Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/publish-npm-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish SDK to npm

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build-and-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./sdk
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org/'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build SDK
run: yarn build

- name: Bump version (patch)
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
NEW_VERSION=$(npx semver $CURRENT_VERSION -i patch)
jq --arg v "$NEW_VERSION" '.version = $v' package.json > package.tmp.json && mv package.tmp.json package.json
echo "Nuova versione SDK: $NEW_VERSION"

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn publish --access public
3 changes: 3 additions & 0 deletions sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignora tutti i file nella cartella src, ma tieni .gitkeep
src/*
!src/.gitkeep
14 changes: 14 additions & 0 deletions sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SDK TypeScript Unguess API

Questa cartella contiene l'SDK TypeScript generato automaticamente dalla reference OpenAPI (`src/reference/openapi.yml`).

## Comandi principali

- `yarn build`: genera l'SDK TypeScript (con funzioni fetch) e compila in `dist/`
- `yarn publish`: pubblica il pacchetto su npm (richiede NPM_TOKEN)

La generazione avviene tramite [swagger-typescript-api](https://github.com/acacode/swagger-typescript-api).

## Versionamento automatico

La versione del pacchetto viene aggiornata automaticamente ad ogni pubblicazione tramite GitHub Action.
21 changes: 21 additions & 0 deletions sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@appquality/tryber-api-sdk",
"version": "1.0.0",
"description": "SDK TypeScript generato da openapi.yml per Tryber API.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "swagger-typescript-api generate -p ../src/reference/openapi.yml -o src --modular --http-client fetch && tsc",
"prepublishOnly": "yarn build"
},
"author": "Unguess",
"license": "MIT",
"devDependencies": {
"openapi-typescript": "^5.1.1",
"swagger-typescript-api": "^13.2.2",
"typescript": "^4.6.3"
}
}
Empty file added sdk/src/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"files": [],
"compilerOptions": {
"outDir": "dist",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": false,
"rootDir": "src",
"noEmit": false
},
"include": ["src/**/*"]
}
Loading
Loading