-
Notifications
You must be signed in to change notification settings - Fork 30
153 lines (131 loc) · 6.05 KB
/
sdk-ts.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
on:
push:
paths:
- 'api-specs/**'
workflow_dispatch:
name: "SDK Generator Typescript"
permissions: {}
jobs:
typescript:
name: "Generate Typescript SDK"
runs-on: ubuntu-latest
steps:
- name: "Checkout api reference"
uses: actions/checkout@v3
with:
path: commercetools-api-reference
- name: "Checkout Typescript SDK"
uses: actions/checkout@v3
with:
repository: 'commercetools/commercetools-sdk-typescript'
path: commercetools-sdk-typescript
ssh-key: ${{ secrets.TS_SDK_DEPLOY_KEY }}
- name: 'Setup Java'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '16'
- name: Setup Node (uses version in .nvmrc)
uses: actions/setup-node@v2
with:
node-version-file: 'commercetools-sdk-typescript/.nvmrc'
- name: "Switch SDK to update branch"
if: github.ref == 'refs/heads/main'
run: |
git fetch --depth=1 origin gen-sdk-updates || true
git checkout -B gen-sdk-updates origin/gen-sdk-updates || true
git checkout -B gen-sdk-updates
git log -1
working-directory: commercetools-sdk-typescript
- name: "Switch SDK to update branch"
if: github.ref != 'refs/heads/main'
run: |
git fetch --depth=1 origin ${{ github.ref_name }} || true
git checkout -B gen-sdk-updates origin/${{ github.ref_name }} || true
git checkout -B ${{ github.ref_name }}
git log -1
working-directory: commercetools-sdk-typescript
- name: "Generate Typescript SDK"
run: sudo chmod 777 /usr/local/bin && make build
working-directory: commercetools-sdk-typescript
env:
RAML_FILE: "../commercetools-api-reference/api-specs/api/api.raml"
API_RAML: "../commercetools-api-reference/api-specs/api/api.raml"
IMPORT_RAML: "../commercetools-api-reference/api-specs/importapi/api.raml"
ML_RAML: "../commercetools-api-reference/api-specs/ml/api.raml"
HISTORY_RAML: "../commercetools-api-reference/api-specs/history/api.raml"
- name: "Checkout previous api reference"
uses: actions/checkout@v3
with:
fetch-depth: 0
path: commercetools-api-reference-previous
- name: "Store api reference version"
run: |
if [ ! -f ../commercetools-sdk-typescript/reference.txt ]; then
git log --format='%H' --no-merges -n 1 --skip 1 > ../commercetools-sdk-typescript/reference.txt
fi
echo "${{ github.sha}}" >> ../commercetools-sdk-typescript/references.txt
echo "previous=$(cat ../commercetools-sdk-typescript/reference.txt | head -n 1)" >> $GITHUB_ENV
working-directory: commercetools-api-reference-previous
- name: "Switch to previous commit"
run: git checkout ${{ env.previous }}
working-directory: commercetools-api-reference-previous
- name: "Calculate diff (API)"
run: rmf-codegen diff -f TS_MARKDOWN -o ./changes_api.md commercetools-api-reference-previous/api-specs/api/api.raml commercetools-api-reference/api-specs/api/api.raml
- name: "Calculate diff (Import API)"
run: rmf-codegen diff -f TS_MARKDOWN -o ./changes_import.md commercetools-api-reference-previous/api-specs/importapi/api.raml commercetools-api-reference/api-specs/importapi/api.raml
- name: "Calculate diff (History)"
run: rmf-codegen diff -f TS_MARKDOWN -o ./changes_history.md commercetools-api-reference-previous/api-specs/history/api.raml commercetools-api-reference/api-specs/history/api.raml
- name: "Calculate diff (ML)"
run: rmf-codegen diff -f TS_MARKDOWN -o ./changes_ml.md commercetools-api-reference-previous/api-specs/ml/api.raml commercetools-api-reference/api-specs/ml/api.raml
- name: 'Create change file'
run: |
if [ -f ./changes_api.md ]; then
echo "**Api changes**" >> ./changes.md
echo "" >> ./changes.md
cat ./changes_api.md >> ./changes.md
echo "" >> ./changes.md
fi
if [ -f ./changes_import.md ]; then
echo "**Import changes**" >> ./changes.md
echo "" >> ./changes.md
cat ./changes_import.md >> ./changes.md
echo "" >> ./changes.md
fi
if [ -f ./changes_history.md ]; then
echo "**History changes**" >> ./changes.md
echo "" >> ./changes.md
cat ./changes_history.md >> ./changes.md
echo "" >> ./changes.md
fi
if [ -f ./changes_ml.md ]; then
echo "**ML changes**" >> ./changes.md
echo "" >> ./changes.md
cat ./changes_ml.md >> ./changes.md
echo "" >> ./changes.md
fi
if [ -f ./changes.md ]; then
cat ./changes.md
cp ./changes.md ./commercetools-sdk-typescript/changes.md
fi
- name: "check pending changes"
run: echo "CHANGES_PENDING=`git status --porcelain -- ':(exclude)*gen.properties' | grep -c ^`" >> $GITHUB_ENV
working-directory: commercetools-sdk-typescript
- uses: stefanzweifel/git-auto-commit-action@v4
if: env.CHANGES_PENDING != '0' && github.ref == 'refs/heads/main'
with:
repository: commercetools-sdk-typescript
branch: gen-sdk-updates
commit_message: "build(codegen): updating SDK"
commit_user_name: Auto Mation
commit_user_email: [email protected]
commit_author: Auto Mation <[email protected]>
- uses: stefanzweifel/git-auto-commit-action@v4
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
with:
repository: commercetools-sdk-typescript
branch: ${{ github.ref_name }}
commit_message: "build(codegen): updating SDK"
commit_user_name: Auto Mation
commit_user_email: [email protected]
commit_author: Auto Mation <[email protected]>