Skip to content

Commit 037463d

Browse files
authored
Migrate to the new release ci (#40)
* Migrate to the new release ci * Actually change the version in the `Cargo.toml` when necessary * Make `version_postfix` optional
1 parent 48ee9c7 commit 037463d

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
on:
22
repository_dispatch:
3-
types: [spec_release]
3+
types: [release]
44
workflow_dispatch:
5-
#on: push
5+
inputs:
6+
json:
7+
description: 'Passed json from repository_dispatch'
8+
required: true
9+
type: string
10+
version_postfix:
11+
description: 'Additional string to concatenate onto the existing version before release'
12+
required: false
13+
type: string
14+
default: ''
615

716
name: Generate VRChat API SDK
817

918
jobs:
1019
generate:
1120
runs-on: ubuntu-latest
1221
name: Generate VRChat API SDK
22+
env:
23+
INPUT: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json }}
24+
SPEC_URL: ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['artifacts']['openapi.json'] }}
25+
PASSED_VERSION: ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['version'] }}
26+
VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }}
1327
steps:
1428
- uses: actions/setup-node@v4
1529
with:
@@ -34,18 +48,26 @@ jobs:
3448
- name: Install Rustup toolchain
3549
uses: moonrepo/setup-rust@v1
3650
- name: Generate SDK Client
37-
run: bash ./generate.sh
51+
run: bash ./generate.sh ${SPEC_URL}
3852
- name: Check version number
3953
run: |
40-
echo "spec_version=$(grep "^version" ./Cargo.toml | cut -d "\"" -f 2)" >> $GITHUB_ENV
41-
- name: Print version number
42-
run: echo ${{ env.spec_version }}
54+
set -euo pipefail
55+
VERSION=
56+
if [ "$(tomlq .package.version Cargo.toml -r)" != ${PASSED_VERSION}]
57+
then
58+
echo "Mismatch between actual and expected version!\nAborting Release." >&2
59+
exit 1
60+
fi
61+
if [ "${VERSION_POSTPEND}" != "" ]
62+
then
63+
tomlq '.package.version |= "${PASSED_VERSION}${VERSION_POSTPEND}"' Cargo.toml --toml-output --in-place
64+
fi
4365
- name: Deploy SDK back into main branch
4466
uses: JamesIves/github-pages-deploy-action@v4
4567
with:
4668
branch: main
4769
folder: .
48-
commit-message: "Upgrade Rust SDK to spec ${{ env.spec_version }}"
70+
commit-message: "Upgrade Rust SDK to spec ${{ env.PASSED_VERSION }}${{env.VERSION_POSTPEND}}"
4971
- name: Deploy to Crates.io
5072
uses: katyo/publish-crates@v2
5173
with:

generate.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ ${#} -le 0 ]
5+
then
6+
echo "Usage: generate.sh <openapi.json>" >&2
7+
exit 1
8+
fi
29

310
# Generate Client
411
rm src/apis src/models docs -rf
@@ -9,7 +16,7 @@ rm src/apis src/models docs -rf
916
--git-user-id=vrchatapi \
1017
--git-repo-id=vrchatapi-rust \
1118
-o . \
12-
-i https://raw.githubusercontent.com/vrchatapi/specification/gh-pages/openapi.yaml \
19+
-i "${1}" \
1320
--http-user-agent="vrchatapi-rust"
1421
#--global-property debugOperations=true
1522

0 commit comments

Comments
 (0)