From c43bb3aaa70fd1ece6d8cf0bab05caecf99247bf Mon Sep 17 00:00:00 2001 From: Thibault Nocchi <1619359+ThibaultNocchi@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:38:32 +0200 Subject: [PATCH 1/2] Fixed formatting --- .github/workflows/release.yml | 100 +++++++-------- .github/workflows/stable-generation.yml | 128 +++++++++--------- .github/workflows/unstable-generation.yml | 150 +++++++++++----------- 3 files changed, 189 insertions(+), 189 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f85a89d0..ae3ed9e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,61 +15,61 @@ jobs: - unstable steps: - - uses: actions/checkout@v2.3.4 - with: - ref: 'master' + - uses: actions/checkout@v2.3.4 + with: + ref: "master" - - name: Setup node environment for NPMJS - uses: actions/setup-node@v2.4.0 - with: - node-version: 14 - cache: 'npm' - registry-url: 'https://registry.npmjs.org' - cache-dependency-path: | - stable/package-lock.json - unstable/package-lock.json + - name: Setup node environment for NPMJS + uses: actions/setup-node@v2.4.0 + with: + node-version: 14 + cache: "npm" + registry-url: "https://registry.npmjs.org" + cache-dependency-path: | + stable/package-lock.json + unstable/package-lock.json - - name: Get package version - id: version - run: echo "::set-output name=number::$(echo $(cat package.json | jq '.version') | tr -d '"')" - working-directory: ./${{ matrix.version }} + - name: Get package version + id: version + run: echo "::set-output name=number::$(echo $(cat package.json | jq '.version') | tr -d '"')" + working-directory: ./${{ matrix.version }} - - name: Install dependencies - run: npm ci --no-audit - working-directory: ./${{ matrix.version }} + - name: Install dependencies + run: npm ci --no-audit + working-directory: ./${{ matrix.version }} - - name: Publish to npm - run: npm publish --tag ${{ matrix.version }} --access public - working-directory: ./${{ matrix.version }} - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Publish to npm + run: npm publish --tag ${{ matrix.version }} --access public + working-directory: ./${{ matrix.version }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Set as latest in npm - if: ${{ matrix.version == 'stable' }} - run: npm dist-tag add @jellyfin/client-axios@${{ steps.version.outputs.number }} latest - working-directory: ./${{ matrix.version }} - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Set as latest in npm + if: ${{ matrix.version == 'stable' }} + run: npm dist-tag add @jellyfin/client-axios@${{ steps.version.outputs.number }} latest + working-directory: ./${{ matrix.version }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Setup node environment for GitHub Package Registry - uses: actions/setup-node@v2.4.0 - with: - node-version: 14 - cache: 'npm' - registry-url: 'https://npm.pkg.github.com' - cache-dependency-path: | - stable/package-lock.json - unstable/package-lock.json + - name: Setup node environment for GitHub Package Registry + uses: actions/setup-node@v2.4.0 + with: + node-version: 14 + cache: "npm" + registry-url: "https://npm.pkg.github.com" + cache-dependency-path: | + stable/package-lock.json + unstable/package-lock.json - - name: Publish to GitHub Package registry - run: npm publish --tag ${{ matrix.version }} --access public - working-directory: ./${{ matrix.version }} - env: - NODE_AUTH_TOKEN: ${{ secrets.ORG_PAT }} + - name: Publish to GitHub Package registry + run: npm publish --tag ${{ matrix.version }} --access public + working-directory: ./${{ matrix.version }} + env: + NODE_AUTH_TOKEN: ${{ secrets.ORG_PAT }} - - name: Set as latest in GitHub Packages - if: ${{ matrix.version == 'stable' }} - run: npm dist-tag add @jellyfin/client-axios@${{ steps.version.outputs.number }} latest - working-directory: ./${{ matrix.version }} - env: - NODE_AUTH_TOKEN: ${{ secrets.ORG_PAT }} + - name: Set as latest in GitHub Packages + if: ${{ matrix.version == 'stable' }} + run: npm dist-tag add @jellyfin/client-axios@${{ steps.version.outputs.number }} latest + working-directory: ./${{ matrix.version }} + env: + NODE_AUTH_TOKEN: ${{ secrets.ORG_PAT }} diff --git a/.github/workflows/stable-generation.yml b/.github/workflows/stable-generation.yml index feb1a8d9..5e05c032 100644 --- a/.github/workflows/stable-generation.yml +++ b/.github/workflows/stable-generation.yml @@ -9,75 +9,75 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 - with: - ref: 'master' - - - name: Download OpenAPI file - run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json > openapi.json - - - name: Modify the schema - run: node scripts/modifySchema.mjs openapi.json + - uses: actions/checkout@v2.3.4 + with: + ref: "master" - - name: Generate - uses: docker://openapitools/openapi-generator-cli:latest-release - env: - TS_POST_PROCESS_FILE: true - with: - args: >- - generate -i /github/workspace/openapi.json - -g typescript-axios --additional-properties=npmName=@jellyfin/client-axios - --additional-properties=npmRepository=https://www.npmjs.com/package/@jellyfin/client-axios - --additional-properties=supportsES6=true - --additional-properties=useSingleRequestParameter=true - --additional-properties=withSeparateModelsAndApi=true - --additional-properties=modelPackage=models - --additional-properties=apiPackage=api - --enable-post-process-file - -o /github/workspace/stable + - name: Download OpenAPI file + run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json > openapi.json - - name: Check if .ts files were modified - id: diff - run: echo "::set-output name=count::$(git status -s | grep ts | wc -l)" + - name: Modify the schema + run: node scripts/modifySchema.mjs openapi.json - - name: Get OpenApi version - if: ${{ steps.diff.outputs.count }} > 0 - id: version - run: echo "::set-output name=number::$(cat openapi.json | jq '.info.version')" + - name: Generate + uses: docker://openapitools/openapi-generator-cli:latest-release + env: + TS_POST_PROCESS_FILE: true + with: + args: >- + generate -i /github/workspace/openapi.json + -g typescript-axios --additional-properties=npmName=@jellyfin/client-axios + --additional-properties=npmRepository=https://www.npmjs.com/package/@jellyfin/client-axios + --additional-properties=supportsES6=true + --additional-properties=useSingleRequestParameter=true + --additional-properties=withSeparateModelsAndApi=true + --additional-properties=modelPackage=models + --additional-properties=apiPackage=api + --enable-post-process-file + -o /github/workspace/stable - - name: Set version in package.json - if: ${{ steps.diff.outputs.count }} > 0 - run: | - echo "$(cat stable/package.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package.json - echo "$(cat stable/package-lock.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package-lock.json + - name: Check if .ts files were modified + id: diff + run: echo "::set-output name=count::$(git status -s | grep ts | wc -l)" - - name: Setup node environment - if: ${{ steps.diff.outputs.count }} > 0 - uses: actions/setup-node@v2.4.0 - with: - node-version: 14 - cache: 'npm' - cache-dependency-path: | - stable/package-lock.json - unstable/package-lock.json + - name: Get OpenApi version + if: ${{ steps.diff.outputs.count }} > 0 + id: version + run: echo "::set-output name=number::$(cat openapi.json | jq '.info.version')" - - name: Install dependencies - if: ${{ steps.diff.outputs.count }} > 0 - run: npm ci --no-audit - working-directory: ./stable + - name: Set version in package.json + if: ${{ steps.diff.outputs.count }} > 0 + run: | + echo "$(cat stable/package.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package.json + echo "$(cat stable/package-lock.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package-lock.json - - name: Build - if: ${{ steps.diff.outputs.count }} > 0 - run: npm run build - working-directory: ./stable + - name: Setup node environment + if: ${{ steps.diff.outputs.count }} > 0 + uses: actions/setup-node@v2.4.0 + with: + node-version: 14 + cache: "npm" + cache-dependency-path: | + stable/package-lock.json + unstable/package-lock.json - # "echo" in commit returns true so the build succeeds, even if no changed files - - name: Commit new changes to the repo - if: ${{ steps.diff.outputs.count }} > 0 - run: | - git config --global user.email "packaging@jellyfin.org" - git config --global user.name "Jellyfin Packaging Team" - git pull - git add . - git commit -m "Update stable OpenAPI client" || echo - git push + - name: Install dependencies + if: ${{ steps.diff.outputs.count }} > 0 + run: npm ci --no-audit + working-directory: ./stable + + - name: Build + if: ${{ steps.diff.outputs.count }} > 0 + run: npm run build + working-directory: ./stable + + # "echo" in commit returns true so the build succeeds, even if no changed files + - name: Commit new changes to the repo + if: ${{ steps.diff.outputs.count }} > 0 + run: | + git config --global user.email "packaging@jellyfin.org" + git config --global user.name "Jellyfin Packaging Team" + git pull + git add . + git commit -m "Update stable OpenAPI client" || echo + git push diff --git a/.github/workflows/unstable-generation.yml b/.github/workflows/unstable-generation.yml index 216209f3..e7474d21 100644 --- a/.github/workflows/unstable-generation.yml +++ b/.github/workflows/unstable-generation.yml @@ -10,88 +10,88 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 - with: - ref: 'master' - - - name: Download OpenAPI file - run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-unstable.json > openapi.json - - - name: Modify the schema - run: node scripts/modifySchema.mjs openapi.json + - uses: actions/checkout@v2.3.4 + with: + ref: "master" - - name: Generate - uses: docker://openapitools/openapi-generator-cli:latest-release - env: - TS_POST_PROCESS_FILE: true - with: - args: >- - generate -i /github/workspace/openapi.json - -g typescript-axios --additional-properties=npmName=@jellyfin/client-axios - --additional-properties=npmRepository=https://www.npmjs.com/package/@jellyfin/client-axios - --additional-properties=supportsES6=true - --additional-properties=useSingleRequestParameter=true - --additional-properties=withSeparateModelsAndApi=true - --additional-properties=modelPackage=models - --additional-properties=apiPackage=api - --enable-post-process-file - -o /github/workspace/unstable + - name: Download OpenAPI file + run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-unstable.json > openapi.json - - name: Get server commit hash - id: sha - run: | - SERVER_SHA="$(git ls-remote git://github.com/jellyfin/jellyfin.git | grep refs/heads/master | cut -f 1)" - echo "::set-output name=sha::$(echo ${SERVER_SHA::7})" + - name: Modify the schema + run: node scripts/modifySchema.mjs openapi.json - - name: Check if .ts files were modified - id: diff - run: echo "::set-output name=count::$(git status -s | grep ts | wc -l)" + - name: Generate + uses: docker://openapitools/openapi-generator-cli:latest-release + env: + TS_POST_PROCESS_FILE: true + with: + args: >- + generate -i /github/workspace/openapi.json + -g typescript-axios --additional-properties=npmName=@jellyfin/client-axios + --additional-properties=npmRepository=https://www.npmjs.com/package/@jellyfin/client-axios + --additional-properties=supportsES6=true + --additional-properties=useSingleRequestParameter=true + --additional-properties=withSeparateModelsAndApi=true + --additional-properties=modelPackage=models + --additional-properties=apiPackage=api + --enable-post-process-file + -o /github/workspace/unstable - - name: Get OpenApi version - if: ${{ steps.diff.outputs.count }} > 0 - id: apiversion - run: | - SERVER_VERSION="$(cat openapi.json | jq '.info.version')" - echo "::set-output name=number::$(echo ${SERVER_VERSION::-1})" + - name: Get server commit hash + id: sha + run: | + SERVER_SHA="$(git ls-remote git://github.com/jellyfin/jellyfin.git | grep refs/heads/master | cut -f 1)" + echo "::set-output name=sha::$(echo ${SERVER_SHA::7})" - - name: Create new version string - if: ${{ steps.diff.outputs.count }} > 0 - id: version - run: echo "::set-output name=number::$(echo ${{ steps.apiversion.outputs.number }}-unstable+${{ steps.sha.outputs.sha }}")" + - name: Check if .ts files were modified + id: diff + run: echo "::set-output name=count::$(git status -s | grep ts | wc -l)" - - name: Set version in package.json - if: ${{ steps.diff.outputs.count }} > 0 - run: | - echo "$(cat unstable/package.json | jq '.version = "${{ steps.version.outputs.number }}"')" > unstable/package.json - echo "$(cat unstable/package-lock.json | jq '.version = "${{ steps.version.outputs.number }}"')" > unstable/package-lock.json + - name: Get OpenApi version + if: ${{ steps.diff.outputs.count }} > 0 + id: apiversion + run: | + SERVER_VERSION="$(cat openapi.json | jq '.info.version')" + echo "::set-output name=number::$(echo ${SERVER_VERSION::-1})" - - name: Setup node environment - if: ${{ steps.diff.outputs.count }} > 0 - uses: actions/setup-node@v2.4.0 - with: - node-version: 14 - cache: 'npm' - cache-dependency-path: | - stable/package-lock.json - unstable/package-lock.json + - name: Create new version string + if: ${{ steps.diff.outputs.count }} > 0 + id: version + run: echo "::set-output name=number::$(echo ${{ steps.apiversion.outputs.number }}-unstable+${{ steps.sha.outputs.sha }}")" - - name: Install dependencies - if: ${{ steps.diff.outputs.count }} > 0 - run: npm ci --no-audit - working-directory: ./unstable + - name: Set version in package.json + if: ${{ steps.diff.outputs.count }} > 0 + run: | + echo "$(cat unstable/package.json | jq '.version = "${{ steps.version.outputs.number }}"')" > unstable/package.json + echo "$(cat unstable/package-lock.json | jq '.version = "${{ steps.version.outputs.number }}"')" > unstable/package-lock.json - - name: Build - if: ${{ steps.diff.outputs.count }} > 0 - run: npm run build - working-directory: ./unstable + - name: Setup node environment + if: ${{ steps.diff.outputs.count }} > 0 + uses: actions/setup-node@v2.4.0 + with: + node-version: 14 + cache: "npm" + cache-dependency-path: | + stable/package-lock.json + unstable/package-lock.json - # "echo" in commit returns true so the build succeeds, even if no changed files - - name: Commit new changes to the repo - if: ${{ steps.diff.outputs.count }} > 0 - run: | - git config --global user.email "packaging@jellyfin.org" - git config --global user.name "Jellyfin Packaging Team" - git pull - git add . - git commit -m "Update unstable OpenAPI client" || echo - git push + - name: Install dependencies + if: ${{ steps.diff.outputs.count }} > 0 + run: npm ci --no-audit + working-directory: ./unstable + + - name: Build + if: ${{ steps.diff.outputs.count }} > 0 + run: npm run build + working-directory: ./unstable + + # "echo" in commit returns true so the build succeeds, even if no changed files + - name: Commit new changes to the repo + if: ${{ steps.diff.outputs.count }} > 0 + run: | + git config --global user.email "packaging@jellyfin.org" + git config --global user.name "Jellyfin Packaging Team" + git pull + git add . + git commit -m "Update unstable OpenAPI client" || echo + git push From bcb3197536c1996660c84b41112b70967030622d Mon Sep 17 00:00:00 2001 From: Thibault Nocchi <1619359+ThibaultNocchi@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:44:05 +0200 Subject: [PATCH 2/2] Added build (and no commit) on PR --- .github/workflows/stable-generation.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/stable-generation.yml b/.github/workflows/stable-generation.yml index 5e05c032..4f93b058 100644 --- a/.github/workflows/stable-generation.yml +++ b/.github/workflows/stable-generation.yml @@ -4,14 +4,13 @@ on: schedule: - cron: "0 0 * * *" workflow_dispatch: + pull_request: jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2.3.4 - with: - ref: "master" - name: Download OpenAPI file run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json > openapi.json @@ -57,9 +56,7 @@ jobs: with: node-version: 14 cache: "npm" - cache-dependency-path: | - stable/package-lock.json - unstable/package-lock.json + cache-dependency-path: stable/package-lock.json - name: Install dependencies if: ${{ steps.diff.outputs.count }} > 0 @@ -73,7 +70,7 @@ jobs: # "echo" in commit returns true so the build succeeds, even if no changed files - name: Commit new changes to the repo - if: ${{ steps.diff.outputs.count }} > 0 + if: ${{ steps.diff.outputs.count }} > 0 && github.event_name != 'pull_request' run: | git config --global user.email "packaging@jellyfin.org" git config --global user.name "Jellyfin Packaging Team"