-
Notifications
You must be signed in to change notification settings - Fork 2
312 lines (294 loc) · 10.1 KB
/
publish.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
name: Publish Check
on:
workflow_run:
workflows:
- Build and Test
types:
- completed
jobs:
check_changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}
outputs:
sdk_node: ${{ steps.filter.outputs.sdk_node }}
sdk_react: ${{ steps.filter.outputs.sdk_react }}
sdk_dotnet: ${{ steps.filter.outputs.sdk_dotnet }}
sdk_go: ${{ steps.filter.outputs.sdk_go }}
cli: ${{ steps.filter.outputs.cli }}
bootstrap: ${{ steps.filter.outputs.bootstrap }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Filter changed files
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
sdk_node:
- 'sdk-node/**'
sdk_react:
- 'sdk-react/**'
sdk_dotnet:
- 'sdk-dotnet/**'
sdk_go:
- 'sdk-go/**'
cli:
- 'cli/**'
bootstrap:
- 'bootstrap*/**'
publish-cli:
needs: check_changes
if: ${{ needs.check_changes.outputs.cli == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
defaults:
run:
working-directory: cli
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: cli/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Configure Git User
run: |
git config --global user.name "Inferable CI"
git config --global user.email "[email protected]"
- name: Release It
run: |
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
version=$(npx release-it --release-version)
npx release-it --npm.skipChecks --git.tagName=cli/v${version} --no-github.release --git.commitMessage="Bump cli version to ${version}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-node:
needs: check_changes
if: ${{ needs.check_changes.outputs.sdk_node == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
defaults:
run:
working-directory: sdk-node
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: sdk-node/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Configure Git User
run: |
git config --global user.name "Inferable CI"
git config --global user.email "[email protected]"
- name: Release It
run: |
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
version=$(npx release-it --release-version)
npx release-it --npm.skipChecks --git.tagName=sdk-node/v${version} --no-github.release --git.commitMessage="Bump sdk-node version to ${version}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-react:
needs: check_changes
if: ${{ needs.check_changes.outputs.sdk_react == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
defaults:
run:
working-directory: sdk-react
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: sdk-react/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Configure Git User
run: |
git config --global user.name "Inferable CI"
git config --global user.email "[email protected]"
- name: Release It
run: |
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
version=$(npx release-it --release-version)
npx release-it --npm.skipChecks --git.tagName=sdk-react/v${version} --no-github.release --git.commitMessage="Bump sdk-react version to ${version}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-dotnet:
needs: check_changes
if: ${{ needs.check_changes.outputs.sdk_dotnet == 'true' }}
runs-on: windows-latest
permissions:
contents: write
defaults:
run:
working-directory: sdk-dotnet
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Restore dependencies
run: dotnet restore
- name: Get and Increment Version
id: increment_version
shell: pwsh
run: |
$projectFile = Get-ChildItem -Path ./src -Filter *.csproj | Select-Object -First 1
if (-not $projectFile) {
throw "No .csproj file found in current directory"
}
$xml = [xml](Get-Content $projectFile.FullName)
$currentVersion = $xml.Project.PropertyGroup.Version
if (-not $currentVersion) {
throw "Version element not found in project file"
}
# Parse version components
$major, $minor, $patch = $currentVersion.Split('.')
$newPatch = [int]$patch + 1
$newVersion = "$major.$minor.$newPatch"
# Update project file
$xml.Project.PropertyGroup.Version = $newVersion
$xml.Save($projectFile.FullName)
# Set output for later steps
echo "new_version=$newVersion" >> $env:GITHUB_OUTPUT
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Pack
run: dotnet pack --configuration Release --no-restore --output ./output
- name: Setup NuGet
uses: nuget/setup-nuget@v2
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: latest
- name: Publish
run: dotnet nuget push output\*.nupkg -s https://api.nuget.org/v3/index.json
- name: Commit and push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -am "Bump sdk-dotnet version to ${{ steps.increment_version.outputs.new_version }}"
git push
- name: Create Git tag
run: |
git tag sdk-dotnet/v${{ steps.increment_version.outputs.new_version }}
git push origin sdk-dotnet/v${{ steps.increment_version.outputs.new_version }}
publish-go:
needs: check_changes
if: ${{ needs.check_changes.outputs.sdk_go == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
defaults:
run:
working-directory: sdk-go
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Get current version
id: get_version
run: |
VERSION=$(grep -oP 'const Version = "\K[^"]+' inferable.go)
echo "current_version=$VERSION" >> $GITHUB_OUTPUT
- name: Increment patch version
id: increment_version
run: |
IFS='.' read -ra VERSION_PARTS <<< "${{ steps.get_version.outputs.current_version }}"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=$((VERSION_PARTS[2] + 1))
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Update version in code
run: |
sed -i 's/const Version = "[^"]*"/const Version = "${{ steps.increment_version.outputs.new_version }}"/' inferable.go
- name: Commit and push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -am "Bump sdk-go version to ${{ steps.increment_version.outputs.new_version }}"
git push
- name: Create Git tag
run: |
git tag sdk-go/v${{ steps.increment_version.outputs.new_version }}
git push origin sdk-go/v${{ steps.increment_version.outputs.new_version }}
create-archives:
runs-on: ubuntu-latest
needs: check_changes
if: ${{ needs.check_changes.outputs.bootstrap == 'true' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Archive bootstrap-node
run: |
zip -r "archives/bootstrap-node.zip" "bootstrap-node/"
- name: Archive bootstrap-dotnet
run: |
zip -r "archives/bootstrap-dotnet.zip" "bootstrap-dotnet/"
- name: Archive bootstrap-go
run: |
zip -r "archives/bootstrap-go.zip" "bootstrap-go/"
- name: Commit archives
uses: EndBug/add-and-commit@v9
with:
add: 'archives/'
message: '[skip ci] Update bootstrap project archives'
default_author: github_actions
push: true
github_token: ${{ secrets.GITHUB_TOKEN }}