-
Notifications
You must be signed in to change notification settings - Fork 1
331 lines (295 loc) · 18.4 KB
/
generate-sdks.yml
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
name: Generate SDKs
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
generate-js-client:
runs-on: ubuntu-latest
name: Generate js sdk
steps:
- name: Checkout OpenAPI
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Generate JS sdk
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: javascript
openapi-file: openapi-3.0.yaml
command-args: --additional-properties=moduleName=dofusdude,projectName=dofusdude-js,licenseName=MIT
- name: Setup Node.js environment
uses: actions/setup-node@v3.4.1
with:
node-version: 16.x
- name: Generate package-lock.json
run: |
cp -r javascript-client javascript-client-cp
cd javascript-client-cp
npm i
cp package-lock.json ../javascript-client/package-lock.json
cd ../javascript-client
mkdir -p .github/workflows/
printf '%s\n' 'name: Node.js CI' 'on:' ' push:' ' branches: [ "main" ]' ' pull_request:' ' branches: [ "main" ]' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' strategy:' ' matrix:' ' node-version: [14.x, 16.x, 18.x]' ' steps:' ' - uses: actions/checkout@v3' ' - name: Use Node.js ${{ matrix.node-version }}' ' uses: actions/setup-node@v3' ' with:' ' node-version: ${{ matrix.node-version }}' ' cache: npm' ' - run: npm ci' ' - run: npm run build --if-present' ' - run: npm test' '' > .github/workflows/testing.yml
printf '%s\n' 'name: Node.js Package' 'on:' ' release:' ' types: [created]' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v3' ' - uses: actions/setup-node@v3' ' with:' ' node-version: 16' ' - run: npm ci' ' - run: npm test' ' publish-npm:' ' needs: build' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v3' ' - uses: actions/setup-node@v3' ' with:' ' node-version: 16' ' registry-url: https://registry.npmjs.org/' ' - run: npm ci' ' - run: npm publish' ' env:' ' NODE_AUTH_TOKEN: secrets.NPM_TOKEN' > .github/workflows/publish.yml
sed -i 's/secrets.NPM_TOKEN/\$\{\{secrets.NPM_TOKEN\}\}/g' .github/workflows/publish.yml
sed -i 's/\\"/"/g' README.md
cd ..
- name: Pushes to another repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
API_TOKEN_GITHUB: ${{ secrets.PUSH_GITHUB_TOKEN }}
with:
source-directory: "javascript-client"
destination-github-username: "dofusdude"
destination-repository-name: "dofusdude-js"
user-email: stelzo@steado.de
target-branch: main
generate-ts-client:
runs-on: ubuntu-latest
name: Generate ts sdk
steps:
- name: Checkout OpenAPI
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Generate TS sdk
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: typescript-axios
openapi-file: openapi-3.0.yaml
command-args: --additional-properties=npmName=dofusdude-ts
- name: Setup Node.js environment
uses: actions/setup-node@v3.4.1
with:
node-version: 16.x
- name: Generate package-lock.json
run: |
cp -r typescript-axios-client typescript-axios-client-cp
cd typescript-axios-client-cp
npm i
cp package-lock.json ../typescript-axios-client/package-lock.json
cd ../typescript-axios-client
mkdir -p .github/workflows/
printf '%s\n' 'name: Node.js CI' 'on:' ' push:' ' branches: [ "main" ]' ' pull_request:' ' branches: [ "main" ]' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' strategy:' ' matrix:' ' node-version: [14.x, 16.x, 18.x]' ' steps:' ' - uses: actions/checkout@v3' ' - name: Use Node.js ${{ matrix.node-version }}' ' uses: actions/setup-node@v3' ' with:' ' node-version: ${{ matrix.node-version }}' ' cache: npm' ' - run: npm ci' ' - run: npm run build --if-present' '' > .github/workflows/build.yml
printf '%s\n' 'name: Node.js Package' 'on:' ' release:' ' types: [created]' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v3' ' - uses: actions/setup-node@v3' ' with:' ' node-version: 16' ' - run: npm ci' ' publish-npm:' ' needs: build' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v3' ' - uses: actions/setup-node@v3' ' with:' ' node-version: 16' ' registry-url: https://registry.npmjs.org/' ' - run: npm ci' ' - run: npm publish' ' env:' ' NODE_AUTH_TOKEN: secrets.NPM_TOKEN' > .github/workflows/publish.yml
sed -i 's/secrets.NPM_TOKEN/\$\{\{secrets.NPM_TOKEN\}\}/g' .github/workflows/publish.yml
sed -i 's/\\"/"/g' README.md
cd ..
- name: Pushes to another repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_TS }}
API_TOKEN_GITHUB: ${{ secrets.PUSH_GITHUB_TOKEN }}
with:
source-directory: "typescript-axios-client"
destination-github-username: "dofusdude"
destination-repository-name: "dofusdude-ts"
user-email: stelzo@steado.de
target-branch: main
generate-java-client:
runs-on: ubuntu-latest
name: Generate java sdk
steps:
- name: Checkout OpenAPI
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Generate java sdk
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: java
openapi-file: openapi-3.0.yaml
command-args: --additional-properties=licenseName=GPLv3,licenseUrl=https://www.gnu.org/licenses/gpl-3.0.txt,scmDeveloperConnection=scm:git:git@github.com:dofusdude/dofusdude-java.git,scmConnection=scm:git:git@github.com:dofusdude/dofusdude-java.git,apiPackage=com.dofusdude.client.api,artifactDescription=dofusdude-client,artifactId=dofusdude-java,artifactUrl=https://github.com/dofusdude/dofusdude-java,developerEmail=stelzo@steado.de,developerName=stelzo,developerOrganization=dofusdude,developerOrganizationUrl=https://github.com/dofusdude,invokerPackage=com.dofusdude.client,modelPackage=com.dofusdude.client.model,groupId=com.dofusdude,useJakartaEe=true
- name: Add actions and patch pom.xml
run: |
cd java-client
mkdir -p .github/workflows/
printf '%s\n' 'name: Build' 'on:' ' push:' ' branches: [ main ]' ' pull_request:' ' branches: [ main ]' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v4' ' - name: Set up Java' ' uses: actions/setup-java@v4' ' with:' ' java-version: "17"' ' distribution: "temurin"' ' - name: Verify and test' ' run: mvn --batch-mode --update-snapshots verify && mvn test' > .github/workflows/build.yml
printf '%s\n' 'name: Upload Java Maven Package' 'on:' ' release:' ' types: [created]' 'jobs:' ' deploy:' ' runs-on: ubuntu-latest' ' permissions:' ' contents: read' ' packages: write' ' steps:' ' - uses: actions/checkout@v4' ' - name: Set up Java' ' uses: actions/setup-java@v4' ' with:' ' java-version: "17"' ' distribution: "temurin"' ' - name: Release Maven package' ' run: mvn --batch-mode deploy' ' env:' ' GITHUB_TOKEN: secrets.GITHUB_TOKEN' > .github/workflows/publish.yml
sed -i 's/secrets.GITHUB_TOKEN/\$\{\{secrets.GITHUB_TOKEN\}\}/g' .github/workflows/publish.yml
sed -i 's|</project>| <distributionManagement><repository><id>github</id><name>GitHub Packages</name><url>https://maven.pkg.github.com/dofusdude/dofusdude-java</url></repository></distributionManagement></project>|g' pom.xml
sed -i 's/\\"/"/g' README.md
cd ..
- name: Pushes to sdk repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_JAVA }}
API_TOKEN_GITHUB: ${{ secrets.PUSH_GITHUB_TOKEN }}
with:
source-directory: "java-client"
destination-github-username: "dofusdude"
destination-repository-name: "dofusdude-java"
user-email: stelzo@steado.de
target-branch: main
generate-csharp-client:
runs-on: ubuntu-latest
name: Generate csharp sdk
steps:
- name: Checkout OpenAPI
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: OpenAPI API Version Print
uses: stelzo/openapi-api-version-print@v1
id: api-version-print
with:
specFile: openapi-3.0.yaml
- name: Generate csharp sdk
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: csharp
openapi-file: openapi-3.0.yaml
command-args: --additional-properties=apiName=DofusdudeApi,packageName=Dofusdude.Api,packageVersion=${{steps.api-version-print.outputs.apiVersion}}
- name: Add actions and patch pom.xml
run: |
cd csharp-client
mkdir -p .github/workflows/
printf '%s\n' 'name: Build' 'on:' ' push:' ' branches: [ main ]' ' pull_request:' ' branches: [ main ]' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v4' ' - name: Set up dotnet' ' uses: actions/setup-dotnet@v3' ' with:' ' dotnet-version: "8.x"' ' - name: Install deps' ' run: dotnet restore' ' - name: Build' ' run: dotnet build' ' - name: Test' ' run: dotnet test' > .github/workflows/build.yml
printf '%s\n' 'name: Publish' 'on:' ' release:' ' types: [ created ]' 'jobs:' ' deploy:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v4' ' - name: Set up dotnet' ' uses: actions/setup-dotnet@v3' ' with:' ' dotnet-version: "8.x"' ' - name: Build' ' run: dotnet build --configuration Release' ' - name: Package' ' run: dotnet pack --configuration Release' ' - name: Publish' ' env:' ' NUGET_AUTH_TOKEN: secrets.NUGET_TOKEN' ' run: dotnet nuget push --api-key "$NUGET_AUTH_TOKEN" --source https://api.nuget.org/v3/index.json src/Dofusdude.Api/bin/Release/Dofusdude.Api.${{steps.api-version-print.outputs.apiVersion}}.nupkg' > .github/workflows/publish.yml
sed -i 's/<Authors>OpenAPI<\/Authors>/<Authors>stelzo<\/Authors>/g' src/Dofusdude.Api/Dofusdude.Api.csproj
sed -i 's/GIT_USER_ID/dofusdude/g' src/Dofusdude.Api/Dofusdude.Api.csproj
sed -i 's/GIT_REPO_ID/dofusdude-csharp/g' src/Dofusdude.Api/Dofusdude.Api.csproj
sed -i 's/<AssemblyTitle>OpenAPI Library<\/AssemblyTitle>/<AssemblyTitle>Dofusdude API<\/AssemblyTitle>/g' src/Dofusdude.Api/Dofusdude.Api.csproj
sed -i 's/<Description>A library generated from a OpenAPI doc<\/Description>/<Description>A project for you - the developer.<\/Description>/g' src/Dofusdude.Api/Dofusdude.Api.csproj
sed -i 's/\\"/"/g' README.md
sed -i 's/secrets.NUGET_TOKEN/\$\{\{secrets.NUGET_TOKEN\}\}/g' .github/workflows/publish.yml
cd ..
- name: Pushes to sdk repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_CSHARP }}
API_TOKEN_GITHUB: ${{ secrets.PUSH_GITHUB_TOKEN }}
with:
source-directory: "csharp-client"
destination-github-username: "dofusdude"
destination-repository-name: "dofusdude-csharp"
user-email: stelzo@steado.de
target-branch: main
generate-go-client:
runs-on: ubuntu-latest
name: Generate go sdk
steps:
- name: Checkout OpenAPI
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Generate go sdk
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: go
openapi-file: openapi-3.0.yaml
command-args: --additional-properties=packageName=dodugo
- name: Setup Go environment
uses: actions/setup-go@v3.3.0
with:
check-latest: true
go-version-file: go-client/go.mod
cache-dependency-path: go-client/go.sum
- name: Add actions
run: |
cd go-client
mkdir -p .github/workflows/
printf '%s\n' 'name: Go' 'on:' ' push:' ' branches: [ main ]' ' pull_request:' ' branches: [ main ]' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v3' ' - name: Set up Go' ' uses: actions/setup-go@v2' ' with:' ' go-version: 1.19' ' - name: Build' ' run: go build -v ./...' > .github/workflows/build.yml
grep -rl GIT_USER_ID . | xargs sed -i 's/GIT_USER_ID\/GIT_REPO_ID/\dofusdude\/dodugo/g'
sed -i 's/\\"/"/g' README.md
go get -u ./...
go mod tidy
printf '%s\n' '* linguist-vendored' '*.go linguist-vendored=false' > .gitattributes
cd ..
- name: Pushes to sdk repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_GO }}
API_TOKEN_GITHUB: ${{ secrets.PUSH_GITHUB_TOKEN }}
with:
source-directory: "go-client"
destination-github-username: "dofusdude"
destination-repository-name: "dodugo"
user-email: stelzo@steado.de
target-branch: main
generate-python-client:
runs-on: ubuntu-latest
name: Generate python sdk
steps:
- name: Checkout OpenAPI
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: OpenAPI API Version Print
uses: stelzo/openapi-api-version-print@v1
id: api-version-print
with:
specFile: openapi-3.0.yaml
- name: Generate python sdk
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: python
openapi-file: openapi-3.0.yaml
command-args: --additional-properties=packageName=dofusdude,projectName=dofusdude,packageUrl=https://github.com/dofusdude/dofusdude-py,packageVersion=${{steps.api-version-print.outputs.apiVersion}}
- name: Setup Python environment
uses: actions/setup-python@v4.2.0
with:
python-version: 3.8
- name: Add actions
run: |
cd python-client
mkdir -p .github/workflows/
printf '%s\n' 'name: Upload Python Package' 'on:' ' release:' ' types: [published]' 'permissions:' ' contents: read' 'jobs:' ' deploy:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v3' ' - name: Set up Python' ' uses: actions/setup-python@v3' ' with:' ' python-version: 3.8' ' - name: Install dependencies' ' run: |' ' python -m pip install --upgrade pip' ' pip install build' ' - name: Build package' ' run: python -m build' ' - name: Publish package' ' uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29' ' with:' ' user: __token__' ' password: secrets.PYPI_API_TOKEN' > .github/workflows/publish.yml
sed -i 's/GIT_USER_ID\/GIT_REPO_ID/\dofusdude\/dofusdude-py/g' README.md
sed -i 's/\\"/"/g' README.md
sed -i 's/secrets.PYPI_API_TOKEN/\$\{\{secrets.PYPI_API_TOKEN\}\}/g' .github/workflows/publish.yml
cd ..
- name: Pushes to sdk repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_PY }}
API_TOKEN_GITHUB: ${{ secrets.PUSH_GITHUB_TOKEN }}
with:
source-directory: "python-client"
destination-github-username: "dofusdude"
destination-repository-name: "dofusdude-py"
user-email: stelzo@steado.de
target-branch: main
generate-php-client:
runs-on: ubuntu-latest
name: Generate php sdk
steps:
- name: Checkout OpenAPI
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Generate php sdk
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: php
openapi-file: openapi-3.0.yaml
command-args: --additional-properties=packageName=dofusdude-php
- name: Add actions
run: |
cd php-client
mkdir -p .github/workflows/
printf '%s\n' 'name: PHP Composer' 'on:' ' push:' ' branches: [ "main" ]' 'permissions:' ' contents: read' 'jobs:' ' build:' ' runs-on: ubuntu-latest' ' steps:' ' - uses: actions/checkout@v3' ' - name: Validate composer.json and composer.lock' ' run: composer validate --strict' ' - name: Cache Composer packages' ' id: composer-cache' ' uses: actions/cache@v3' ' with:' ' path: vendor' ' key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}' ' restore-keys: |' ' ${{ runner.os }}-php-' ' - name: Install dependencies' ' run: composer install --prefer-dist --no-progress' > .github/workflows/build.yml
grep -rl GIT_USER_ID . | xargs sed -i 's/GIT_USER_ID\/GIT_REPO_ID/\dofusdude\/dofusdude-php/g'
sed -i 's/\\"/"/g' README.md
sed -i 's/"description"/"name": "dofusdude\/dofusdude-php",\n "description"/g' composer.json
cd ..
- name: Pushes to another repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_PHP }}
API_TOKEN_GITHUB: ${{ secrets.PUSH_GITHUB_TOKEN }}
with:
source-directory: "php-client"
destination-github-username: "dofusdude"
destination-repository-name: "dofusdude-php"
user-email: stelzo@steado.de
target-branch: main