generated from okp4/template-oss
-
Notifications
You must be signed in to change notification settings - Fork 1
188 lines (162 loc) · 5.48 KB
/
update-schema.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
name: Update schema
concurrency: update-schema-${{ github.ref }}
on:
workflow_dispatch:
inputs:
ref:
description: "New axone-protocol/contracts version (repository tag or repository ref)"
required: true
draft:
type: boolean
description: "Indicate if schemas need to be only publish in draft or need to be released and published publicly"
required: false
default: false
jobs:
update-schema:
runs-on: ubuntu-22.04
steps:
- name: Checks params
run: |
if [[ ! ${{ github.event.inputs.ref }} =~ ^v[0-9]+(\.[0-9]+)* ]] && [[ ! ${{ github.event.inputs.ref }} = "main" ]]; then
>&2 echo "❌ Invalid github ref given '${{ github.event.inputs.ref }}', should be eithier 'main' or 'v*'."
exit 1
fi
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ secrets.OPS_TOKEN }}
fetch-depth: 2
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.75
default: true
override: true
- name: Install cargo make
uses: davidB/rust-cargo-make@v1
- name: Install Mage
run: go install github.com/magefile/[email protected]
- name: Download & generate schema
run: |
mage -v schema:generate ${{ github.event.inputs.ref }}
- name: Generate readme
run: |
mage -v schema:readme ${{ github.event.inputs.ref }}
- name: Upload artefact
uses: actions/upload-artifact@v4
with:
name: schema
path: ./
retention-days: 1
overwrite: true
schema-matrix:
runs-on: ubuntu-22.04
needs: update-schema
outputs:
schema: ${{ steps.set-matrix.outputs.schema }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "::set-output name=schema::$(ls schema/ | jq -R -s -c 'split("\n")[:-1] | map(select(test(".json$") | not))')"
build-target:
runs-on: ubuntu-22.04
needs: schema-matrix
strategy:
matrix:
target: [ts, go]
schema: ${{ fromJson(needs.schema-matrix.outputs.schema) }}
max-parallel: 1
steps:
- name: Download artefact
uses: actions/download-artifact@v4
with:
name: schema
path: ./
- name: Setup node environment (for building)
uses: actions/setup-node@v4
with:
node-version: 18.12.0
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Install Mage
run: go install github.com/magefile/[email protected]
- name: Build
run: |
mage -v build:${{ matrix.target }} ${{ matrix.schema }}
- name: Upload artefact
uses: actions/upload-artifact@v4
with:
name: schema
path: ./
retention-days: 1
overwrite: true
publish-new-schema:
runs-on: ubuntu-22.04
needs: build-target
steps:
- name: Download artefact
uses: actions/download-artifact@v4
with:
name: schema
path: ./
- name: Setup Go environment
uses: actions/setup-go@v5
if: ${{ github.event.inputs.draft == 'false' }}
with:
go-version: "1.22"
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Install Mage
if: ${{ github.event.inputs.draft == 'false' }}
run: go install github.com/magefile/[email protected]
- name: "Bump ts version"
if: ${{ github.event.inputs.draft == 'false' }}
run: |
mage -v bumpVersion:ts ${{ github.event.inputs.ref }}
- name: "Bump go version"
if: ${{ github.event.inputs.draft == 'false' }}
run: |
mage -v bumpVersion:go ${{ github.event.inputs.ref }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit documentation draft
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_user_name: ${{ vars.BOT_GIT_COMMITTER_NAME }}
commit_user_email: ${{ vars.BOT_GIT_COMMITTER_EMAIL }}
commit_author: ${{ vars.BOT_GIT_AUTHOR_NAME }} <${{ vars.BOT_GIT_AUTHOR_EMAIL }}>
commit_message: "${{ github.event.inputs.draft == 'true' && 'feat: update schema files' || 'chore(release): perform release' }} ${{ github.event.inputs.draft == 'false' && github.event.inputs.ref || '' }}"
tagging_message: ${{ github.event.inputs.draft == 'false' && github.event.inputs.ref || '' }}
file_pattern: '*.json */README.md go/**/*.go'