Skip to content

Update environment configuration, enhance token management, and add U… #19

Update environment configuration, enhance token management, and add U…

Update environment configuration, enhance token management, and add U… #19

Workflow file for this run

name: Generate and Publish TypeScript SDK
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
generate-sdk:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Install swag
run: go install github.com/swaggo/swag/cmd/swag@latest
- name: Generate Swagger docs
run: swag init -g main.go
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install OpenAPI Generator
run: npm install @openapitools/openapi-generator-cli -g
- name: Generate TypeScript SDK
run: |
# Get the current date in YYYY.MM.DD format
VERSION=$(date +%Y.%-m.%-d)
# Get the short SHA
SHA=$(git rev-parse --short HEAD)
# Combine them into a valid version
FULL_VERSION="${VERSION}-${SHA}"
openapi-generator-cli generate \
-i docs/swagger.json \
-g typescript-axios \
-o sdk/typescript \
--additional-properties=npmName=@vhybzOS/api,npmVersion=$FULL_VERSION,supportsES6=true,useSingleRequestParameter=true,public=true
- name: Configure npm
run: |
cd sdk/typescript
# Set GitHub Packages authentication
npm config set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}
# Set GitHub Packages registry only for @vhybzOS scope
npm config set @vhybzOS:registry https://npm.pkg.github.com
# Set default registry to npm
npm config set registry https://registry.npmjs.org/
- name: Install dependencies and build
run: |
cd sdk/typescript
npm install
npm run build
# Fix package.json
npm pkg set repository.url="https://github.com/vhybzOS/api.git"
npm pkg set repository.type="git"
npm pkg set repository.directory="sdk/typescript"
- name: Publish to GitHub Packages
run: |
cd sdk/typescript
npm publish --access public
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: sdk/typescript/package.json
generate_release_notes: true
draft: false
prerelease: false
tag_name: sdk-v${{ env.FULL_VERSION }}