aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-09-05 23:32:21 -0600
committercrobibero <cody@robibe.ro>2020-09-05 23:32:21 -0600
commit320e3b98ab50e83932156b1a8ce7fc25685f7252 (patch)
treee90c3b8a5542cd2fbbec9ed794914f4faf33c90d
parent6d154041b9e456ab97e1066f525e4d9732fb672a (diff)
Add ci task to publish api client
-rw-r--r--.ci/azure-pipelines-api-client.yml72
-rw-r--r--.gitignore1
-rw-r--r--apiclient/.openapi-generator-ignore2
-rw-r--r--apiclient/templates/typescript/package.mustache30
-rw-r--r--apiclient/templates/typescript/stable.sh10
-rw-r--r--apiclient/templates/typescript/unstable.sh10
6 files changed, 125 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..babee15b5
--- /dev/null
+++ b/.ci/azure-pipelines-api-client.yml
@@ -0,0 +1,72 @@
+parameters:
+ - name: LinuxImage
+ type: string
+ default: "ubuntu-latest"
+ - name: GeneratorVersion
+ type: string
+ default: "4.3.1"
+
+jobs:
+- job: GenerateApiClients
+ displayName: 'Generate Api Clients'
+
+ pool:
+ vmImage: "${{ parameters.LinuxImage }}"
+
+ steps:
+ - task: DownloadPipelineArtifact@2
+ displayName: 'Download OpenAPI Spec Artifact'
+ inputs:
+ source: "specific"
+ artifact: "OpenAPI Spec"
+ path: "$(System.ArtifactsDirectory)/openapi"
+ project: "$(System.TeamProjectId)"
+ pipeline: "29" # The main server CI build
+ runVersion: "latestFromBranch"
+ runBranch: "refs/heads/$(System.PullRequest.TargetBranch)"
+
+ - task: CmdLine@2
+ displayName: 'Download OpenApi Generator'
+ inputs:
+ scripts: "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: npmAuthenticate@0
+ displayName: 'Authenticate to unstable npm feed'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
+
+ - task: CmdLine@2
+ displayName: 'Build unstable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
+ inputs:
+ script: 'bash ./apiclient/templates/typescript/unstable.sh axios'
+
+ - task: Npm@1
+ displayName: 'Publish unstable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
+ inputs:
+ command: publish
+ publishRegistry: useFeed
+ publishFeed: jellyfin/unstable
+ workingDir: ./apiclient/generated/typescript/axios
+
+# Stable
+ - task: npmAuthenticate@0
+ displayName: 'Authenticate to stable npm feed'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
+
+ - task: CmdLine@2
+ displayName: 'Build stable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
+ inputs:
+ script: 'bash ./apiclient/templates/typescript/stable.sh axios'
+
+ - task: Npm@1
+ displayName: 'Publish stable typescript axios client'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
+ inputs:
+ command: publish
+ publishRegistry: useExternalRegistry
+ publishEndpoint:
+ workingDir: ./apiclient/generated/typescript/axios
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/package.mustache b/apiclient/templates/typescript/package.mustache
new file mode 100644
index 000000000..5127917a1
--- /dev/null
+++ b/apiclient/templates/typescript/package.mustache
@@ -0,0 +1,30 @@
+{
+ "name": "jellyfin-apiclient-{{npmName}}",
+ "version": "10.7.0{{snapshotVersion}}",
+ "description": "Jellyfin api client using {{npmName}}",
+ "author": "Jellyfin Contributors",
+ "keywords": [
+ "{{npmName}}",
+ "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/stable.sh b/apiclient/templates/typescript/stable.sh
new file mode 100644
index 000000000..46af6433f
--- /dev/null
+++ b/apiclient/templates/typescript/stable.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+CLIENT=$1
+openapi-generator generate \
+ --input-spec $(System.ArtifactsDirectory)/openapi/openapi.json \
+ --generator-name typescript-${CLIENT} \
+ --output ./apiclient/generated/typescript/${CLIENT} \
+ --template-dir ./apiclient/templates/typescript \
+ --ignore-file-override ./apiclient/.openapi-generator-ignore \
+ --additional-properties=useSingleRequestParameter="true",npmName="${CLIENT}"
diff --git a/apiclient/templates/typescript/unstable.sh b/apiclient/templates/typescript/unstable.sh
new file mode 100644
index 000000000..255e20c4f
--- /dev/null
+++ b/apiclient/templates/typescript/unstable.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+CLIENT=$1
+openapi-generator generate \
+ --input-spec $(System.ArtifactsDirectory)/openapi/openapi.json \
+ --generator-name typescript-${CLIENT} \
+ --output ./apiclient/generated/typescript/${CLIENT} \
+ --template-dir ./apiclient/templates/typescript \
+ --ignore-file-override ./apiclient/.openapi-generator-ignore \
+ --additional-properties=useSingleRequestParameter="true",npmName="${CLIENT}",snapshotVersion="-SNAPSHOT.$(Build.BuildNumber)",npmRepository="https://dev.azure.com/jellyfin-project/jellyfin/_packaging"