This repository was archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
102 lines (89 loc) · 3.92 KB
/
Copy pathgeneration.yml
File metadata and controls
102 lines (89 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Generate API client
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
fail-fast: false
matrix:
version:
- stable
- unstable
steps:
- uses: actions/checkout@v2.4.0
with:
token: ${{ secrets.JF_BOT_TOKEN }}
- name: Download OpenAPI file
run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-${{ matrix.version }}.json > openapi.json
- name: Modify the schema
run: node scripts/modifySchema.mjs openapi.json
- 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/${{ matrix.version }}
- name: Check if .ts files were modified
id: diff
run: echo "::set-output name=count::$(git status -su | grep ts | wc -l)"
- name: (stable) Set version in package.json
if: ${{ steps.diff.outputs.count > 0 && matrix.version == 'stable' }}
run: |
VERSION=$(cat openapi.json | jq '.info.version')
echo "$(cat stable/package.json | jq ".version = $VERSION")" > stable/package.json
echo "$(cat stable/package-lock.json | jq ".version = $VERSION")" > stable/package-lock.json
- name: (unstable) Set version in package.json
if: ${{ steps.diff.outputs.count > 0 && matrix.version == 'unstable' }}
run: |
BUILD_VERSION=$(cat openapi.json | jq -r '.info.version')
NPM_UNSTABLE=$(npm show @jellyfin/client-axios@unstable version) # Current unstable version on npm
UNSTABLE_NPM_VERSION=$(echo $NPM_UNSTABLE | sed -n 's/^\(.\+\)-unstable\.\([0-9]\+\)$/\1/p' )
UNSTABLE_NPM_SUFFIX=$(echo $NPM_UNSTABLE | sed -n 's/^\(.\+\)-unstable\.\([0-9]\+\)$/\2/p' )
if [[ "$BUILD_VERSION" == "$UNSTABLE_NPM_VERSION" ]]; then
FINAL_NPM_SUFFIX=$((UNSTABLE_NPM_SUFFIX + 1))
else
FINAL_NPM_SUFFIX=0
fi
VERSION=$BUILD_VERSION-unstable.$FINAL_NPM_SUFFIX
echo "$(cat unstable/package.json | jq ".version = \"${VERSION}\"")" > unstable/package.json
echo "$(cat unstable/package-lock.json | jq ".version = \"${VERSION}\"")" > unstable/package-lock.json
- name: Setup node environment
if: ${{ steps.diff.outputs.count > 0 }}
uses: actions/setup-node@v2.5.0
with:
node-version: 14
cache: "npm"
cache-dependency-path: ${{ matrix.version }}/package-lock.json
- name: Install dependencies
if: ${{ steps.diff.outputs.count > 0 }}
run: npm ci --no-audit
working-directory: ./${{ matrix.version }}
- name: Build
if: ${{ steps.diff.outputs.count > 0 }}
run: npm run build
working-directory: ./${{ matrix.version }}
# "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 && github.event_name != 'pull_request' }}
run: |
git config user.name jellyfin-bot
git config user.email team@jellyfin.org
git pull
git add .
git commit -m "Update ${{ matrix.version }} OpenAPI client" || echo
git push