Skip to content
Merged
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
118 changes: 118 additions & 0 deletions .github/workflows/publish-api-clients.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Publish API Clients

on:
workflow_call:
inputs:
spec-path:
required: true
type: string
api-name:
required: true
type: string
version:
required: true
type: string
ts-package:
required: true
type: string
maven-group:
required: true
type: string
java-artifact:
required: true
type: string
kotlin-artifact:
required: true
type: string
dry-run:
required: false
type: boolean
default: false
openapi-client-gradle-version:
required: false
type: string
default: "0.3.0"
node-version:
required: false
type: string
default: "24"
java-version:
required: false
type: string
default: "21"
npm-registry-url:
required: false
type: string
default: "https://npm.pkg.github.com"
secrets:
packages-token:
required: false
node-auth-token:
required: false

permissions:
contents: read
packages: write
id-token: write

jobs:
clients:
name: API Clients
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: actions/checkout@v6
with:
repository: JorisJonkers-dev/github-workflows
ref: ${{ github.job_workflow_sha }}
path: .github-workflows
persist-credentials: false

- uses: ./.github-workflows/actions/setup-java-gradle
with:
java-version: ${{ inputs.java-version }}
github-packages-token: ${{ secrets.packages-token || github.token }}

- uses: ./.github-workflows/actions/setup-node
with:
node-version: ${{ inputs.node-version }}
package-manager: npm
install-command: "npm install --no-audit --no-fund"
working-directory: ${{ runner.temp }}/api-clients/typescript
github-packages-token: ${{ secrets.node-auth-token || secrets.packages-token || github.token }}

- name: Generate and verify all clients
uses: ./.github-workflows/actions/api-client-publish
with:
mode: dry-run
spec-path: ${{ inputs.spec-path }}
api-name: ${{ inputs.api-name }}
version: ${{ inputs.version }}
ts-package: ${{ inputs.ts-package }}
maven-group: ${{ inputs.maven-group }}
java-artifact: ${{ inputs.java-artifact }}
kotlin-artifact: ${{ inputs.kotlin-artifact }}
openapi-client-gradle-version: ${{ inputs.openapi-client-gradle-version }}
npm-registry-url: ${{ inputs.npm-registry-url }}
env:
GITHUB_TOKEN: ${{ secrets.packages-token || github.token }}
NODE_AUTH_TOKEN: ${{ secrets.node-auth-token || secrets.packages-token || github.token }}

- name: Publish all clients
if: ${{ !inputs.dry-run }}
uses: ./.github-workflows/actions/api-client-publish
with:
mode: publish
spec-path: ${{ inputs.spec-path }}
api-name: ${{ inputs.api-name }}
version: ${{ inputs.version }}
ts-package: ${{ inputs.ts-package }}
maven-group: ${{ inputs.maven-group }}
java-artifact: ${{ inputs.java-artifact }}
kotlin-artifact: ${{ inputs.kotlin-artifact }}
openapi-client-gradle-version: ${{ inputs.openapi-client-gradle-version }}
npm-registry-url: ${{ inputs.npm-registry-url }}
env:
GITHUB_TOKEN: ${{ secrets.packages-token || github.token }}
NODE_AUTH_TOKEN: ${{ secrets.node-auth-token || secrets.packages-token || github.token }}
52 changes: 52 additions & 0 deletions actions/api-client-publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish API Clients
description: Generate, verify, and publish Java, Kotlin, and TypeScript API clients from an OpenAPI spec.

inputs:
mode:
description: Execution mode. Use dry-run or publish.
required: true
spec-path:
description: Path to the OpenAPI spec relative to GITHUB_WORKSPACE.
required: true
api-name:
description: API name used to derive generated package names.
required: true
version:
description: Client package version. A leading v is stripped.
required: true
ts-package:
description: npm package name for the generated TypeScript client.
required: true
maven-group:
description: Maven group ID for the generated JVM clients.
required: true
java-artifact:
description: Maven artifact ID for the generated Java client.
required: true
kotlin-artifact:
description: Maven artifact ID for the generated Kotlin client.
required: true
openapi-client-gradle-version:
description: Version of dev.jorisjonkers.openapi-client Gradle plugin to apply.
required: true
npm-registry-url:
description: npm registry URL used for publishConfig and authentication.
required: true

runs:
using: composite
steps:
- name: Generate, build, and publish clients
shell: bash
env:
INPUT_MODE: ${{ inputs.mode }}
INPUT_SPEC_PATH: ${{ inputs.spec-path }}
INPUT_API_NAME: ${{ inputs.api-name }}
INPUT_VERSION: ${{ inputs.version }}
INPUT_TS_PACKAGE: ${{ inputs.ts-package }}
INPUT_MAVEN_GROUP: ${{ inputs.maven-group }}
INPUT_JAVA_ARTIFACT: ${{ inputs.java-artifact }}
INPUT_KOTLIN_ARTIFACT: ${{ inputs.kotlin-artifact }}
INPUT_OPENAPI_CLIENT_GRADLE_VERSION: ${{ inputs.openapi-client-gradle-version }}
INPUT_NPM_REGISTRY_URL: ${{ inputs.npm-registry-url }}
run: "$GITHUB_ACTION_PATH/run.sh"
Loading
Loading