aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2020-10-02 16:57:50 -0400
committerGitHub <noreply@github.com>2020-10-02 16:57:50 -0400
commitcb94b5a94460be58e1b90366ef0ee45b8de1c0d1 (patch)
tree58738351d601a1e36f5c7bc7c7c00acd27be43f9
parent5f65fd93a1ec84b3feaeea1dd11798f85693436e (diff)
parent0ffc58e25509c375654430e64a2208baf6d65be9 (diff)
Merge pull request #4070 from crobibero/ci-api-client
Add ci task to publish api client
-rw-r--r--.ci/azure-pipelines-api-client.yml62
-rw-r--r--.ci/azure-pipelines.yml3
-rw-r--r--.gitignore1
-rw-r--r--apiclient/.openapi-generator-ignore2
-rw-r--r--apiclient/templates/typescript/axios/package.mustache30
-rw-r--r--apiclient/templates/typescript/axios/stable.sh9
-rw-r--r--apiclient/templates/typescript/axios/unstable.sh9
7 files changed, 116 insertions, 0 deletions
diff --git a/.ci/azure-pipelines-api-client.yml b/.ci/azure-pipelines-api-client.yml
new file mode 100644
index 000000000..7f428aec1
--- /dev/null
+++ b/.ci/azure-pipelines-api-client.yml
@@ -0,0 +1,62 @@
+parameters:
+ - name: LinuxImage
+ type: string
+ default: "ubuntu-latest"
+ - name: GeneratorVersion
+ type: string
+ default: "5.0.0-beta2"
+
+jobs:
+- job: GenerateApiClients
+ displayName: 'Generate Api Clients'
+ dependsOn: Test
+
+ pool:
+ vmImage: "${{ parameters.LinuxImage }}"
+
+ steps:
+ - task: DownloadPipelineArtifact@2
+ displayName: 'Download OpenAPI Spec Artifact'
+ inputs:
+ source: 'current'
+ artifact: "OpenAPI Spec"
+ path: "$(System.ArtifactsDirectory)/openapispec"
+ runVersion: "latest"
+
+ - task: CmdLine@2
+ displayName: 'Download OpenApi Generator'
+ inputs:
+ script: "wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${{ parameters.GeneratorVersion }}/openapi-generator-cli-${{ parameters.GeneratorVersion }}.jar -O openapi-generator-cli.jar"
+
+# Generate npm api client
+# Unstable
+ - task: CmdLine@2
+ displayName: 'Build unstable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
+ inputs:
+ script: 'bash ./apiclient/templates/typescript/axios/unstable.sh'
+
+ - task: Npm@1
+ displayName: 'Publish unstable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
+ inputs:
+ command: publish
+ publishRegistry: useFeed
+ publishFeed: unstable
+ workingDir: ./apiclient/generated/typescript/axios
+
+# Stable
+ - task: CmdLine@2
+ displayName: 'Build stable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
+ inputs:
+ script: 'bash ./apiclient/templates/typescript/axios/stable.sh'
+
+ - task: Npm@1
+ displayName: 'Publish stable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
+ inputs:
+ command: publish
+ publishRegistry: useExternalRegistry
+ publishEndpoint: 'jellyfin-bot for NPM'
+ workingDir: ./apiclient/generated/typescript/axios
diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml
index 347918e0b..5b5a17dea 100644
--- a/.ci/azure-pipelines.yml
+++ b/.ci/azure-pipelines.yml
@@ -61,3 +61,6 @@ jobs:
- ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
- template: azure-pipelines-package.yml
+
+- ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
+ - template: azure-pipelines-api-client.yml
diff --git a/.gitignore b/.gitignore
index 0df7606ce..7cd3d0068 100644
--- a/.gitignore
+++ b/.gitignore
@@ -276,3 +276,4 @@ BenchmarkDotNet.Artifacts
web/
web-src.*
MediaBrowser.WebDashboard/jellyfin-web
+apiclient/generated
diff --git a/apiclient/.openapi-generator-ignore b/apiclient/.openapi-generator-ignore
new file mode 100644
index 000000000..f3802cf54
--- /dev/null
+++ b/apiclient/.openapi-generator-ignore
@@ -0,0 +1,2 @@
+# Prevent generator from creating these files:
+git_push.sh
diff --git a/apiclient/templates/typescript/axios/package.mustache b/apiclient/templates/typescript/axios/package.mustache
new file mode 100644
index 000000000..7bfab08cb
--- /dev/null
+++ b/apiclient/templates/typescript/axios/package.mustache
@@ -0,0 +1,30 @@
+{
+ "name": "@jellyfin/client-axios",
+ "version": "10.7.0{{snapshotVersion}}",
+ "description": "Jellyfin api client using axios",
+ "author": "Jellyfin Contributors",
+ "keywords": [
+ "axios",
+ "typescript",
+ "jellyfin"
+ ],
+ "license": "GPL-3.0-only",
+ "main": "./dist/index.js",
+ "typings": "./dist/index.d.ts",
+ "scripts": {
+ "build": "tsc --outDir dist/",
+ "prepublishOnly": "npm run build"
+ },
+ "dependencies": {
+ "axios": "^0.19.2"
+ },
+ "devDependencies": {
+ "@types/node": "^12.11.5",
+ "typescript": "^3.6.4"
+ }{{#npmRepository}},{{/npmRepository}}
+{{#npmRepository}}
+ "publishConfig": {
+ "registry": "{{npmRepository}}"
+ }
+{{/npmRepository}}
+}
diff --git a/apiclient/templates/typescript/axios/stable.sh b/apiclient/templates/typescript/axios/stable.sh
new file mode 100644
index 000000000..118ef219f
--- /dev/null
+++ b/apiclient/templates/typescript/axios/stable.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+java -jar openapi-generator-cli.jar generate \
+ --input-spec $(System.ArtifactsDirectory)/openapispec/openapi.json \
+ --generator-name typescript-axios \
+ --output ./apiclient/generated/typescript/axios \
+ --template-dir ./apiclient/templates/typescript/axios \
+ --ignore-file-override ./apiclient/.openapi-generator-ignore \
+ --additional-properties=useSingleRequestParameter="true",withSeparateModelsAndApi="true",npmName="axios"
diff --git a/apiclient/templates/typescript/axios/unstable.sh b/apiclient/templates/typescript/axios/unstable.sh
new file mode 100644
index 000000000..be9f9be43
--- /dev/null
+++ b/apiclient/templates/typescript/axios/unstable.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+java -jar openapi-generator-cli.jar generate \
+ --input-spec $(System.ArtifactsDirectory)/openapispec/openapi.json \
+ --generator-name typescript-axios \
+ --output ./apiclient/generated/typescript/axios \
+ --template-dir ./apiclient/templates/typescript/axios \
+ --ignore-file-override ./apiclient/.openapi-generator-ignore \
+ --additional-properties=useSingleRequestParameter="true",withSeparateModelsAndApi="true",npmName="axios",snapshotVersion="-SNAPSHOT.$(Build.BuildNumber)",npmRepository="https://pkgs.dev.azure.com/jellyfin-project/jellyfin/_packaging/unstable/npm/registry/"