77
88jobs :
99 lint :
10- runs-on : ubuntu-latest
1110 name : Lint
11+ runs-on : ubuntu-latest
1212 steps :
1313 - uses : actions/checkout@v4
1414 with :
@@ -23,38 +23,36 @@ jobs:
2323
2424 - run : pnpm install
2525
26- - run : |
26+ - name : pnpm run lint-ci
27+ run : |
28+ output=$(pnpm run lint-ci 2>&1) || exit_code=$?
29+
2730 if [ "${{ github.event_name }}" = "push" ]; then
2831 changes=$(git diff --name-only --diff-filter=d "${{ github.event.commits[0].id }}~1" "${{ github.event.commits[0].id }}")
2932 elif [ "${{ github.event_name }}" = "pull_request" ]; then
3033 changes=$(git diff --name-only --diff-filter=d "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}")
3134 fi
3235
3336 if [ -n "$changes" ]; then
34- echo "Changed files:"
35- echo "$changes"
36-
37- # Run lint and capture output
38- lint_output=$(pnpm run lint-ci 2>&1 || true)
39-
40- # Filter for changed files and check if any issues found
41- filtered_output=$(echo "$lint_output" | grep -E "($(echo "$changes" | tr '\n' '|' | sed 's/|$//'))" || true)
37+ filtered_output=$(echo "$output" | grep -E "($(echo "$changes" | tr '\n' '|' | sed 's/|$//'))" || true)
4238
4339 if [ -n "$filtered_output" ]; then
44- echo "Lint issues found in changed files:"
4540 echo "$filtered_output"
46- exit 1
47- else
48- echo "No lint issues in changed files"
41+ echo "$output"
42+
43+ exit ${exit_code:-1}
4944 fi
50- else
51- echo "No changed files."
5245 fi
5346
47+ echo "$output"
48+
5449 bundle :
55- needs : lint
56- runs-on : ubuntu-latest
5750 name : Bundle
51+ runs-on : ubuntu-latest
52+ needs : lint
53+ strategy :
54+ matrix :
55+ format : [yaml, json]
5856 steps :
5957 - uses : actions/checkout@v4
6058
@@ -68,78 +66,129 @@ jobs:
6866 - name : Install dependencies
6967 run : pnpm install
7068
71- - run : |
72- pnpm bundle --ext yaml
73- pnpm bundle --ext json
74-
75- - uses : actions/upload-artifact@v4
76- with :
77- name : openapi.yaml
78- path : dist/openapi.yaml
69+ - run : pnpm bundle --ext ${{ matrix.format }}
7970
8071 - uses : actions/upload-artifact@v4
8172 with :
82- name : openapi.json
83- path : dist/openapi.json
84-
85- pages :
86- # Only if main branch
87- if : github.ref == 'refs/heads/main'
88- needs : bundle
73+ name : openapi.${{ matrix.format }}
74+ path : dist/openapi.${{ matrix.format }}
75+
76+ release :
8977 runs-on : ubuntu-latest
90- name : Upload OpenAPI specification to GitHub Pages
78+ needs : bundle
79+ outputs :
80+ release : ${{ steps.script.outputs.release }}
9181 steps :
9282 - uses : actions/checkout@v4
9383
94- - uses : actions/download-artifact@v4
84+ - uses : actions/download-artifact@v5
9585 with :
96- name : openapi.yaml
9786 path : dist
87+ merge-multiple : true
9888
99- - name : Disable Jekyll for Github Pages
100- run : sudo touch dist/.nojekyll; sudo touch dist/index.html
101-
102- - name : Deploy Bundle to Github Pages 🚀
103- uses : JamesIves/github-pages-deploy-action@v4
104- with :
105- branch : gh-pages
106- folder : dist
107-
108- version_check :
109- # Only if tag "release/*" is pushed
110- if : ${{ startsWith(github.ref, 'refs/tags/release/') }}
111- needs : bundle
112- name : Check if OpenAPI specification version is matching tag
113- runs-on : ubuntu-latest
114- steps :
115- - uses : actions/checkout@v4
116- - name : Check if OpenAPI specification version is matching tag
117- # Tag will be e.g., "release/1.0.0", check if this matches the version in openapi/openapi.yaml
89+ - id : script
11890 run : |
119- if [[ $(cat openapi/openapi.yaml | grep -oP '(?<=version: ).*') != $(echo $GITHUB_REF | grep -oP '(?<=release/).*') ]]; then
120- echo "OpenAPI specification version does not match tag!"
121- exit 1
122- fi
123-
124- # https://blog.marcnuri.com/triggering-github-actions-across-different-repositories
125- # Make sure this is same as in sdk_generate.yaml
126- sdk_generate :
91+ version=$(jq -r '.info.version' dist/openapi.json)
92+ commits_since_release=$(git log --oneline "v$version"..HEAD | wc -l)
93+
94+ version=$(semver $version -i)-nightly.$commits_since_release
95+
96+ gh release create v$version dist/* \
97+ --generate-notes \
98+ --prerelease
99+
100+ release=$(gh release view v$version --json id,tagName,url,isPrerelease,assets | jq -c '{
101+ id,
102+ url,
103+ version: .tagName,
104+ prerelease: .isPrerelease,
105+ artifacts: (
106+ .assets
107+ | map({ (.name): .url })
108+ | add
109+ )
110+ }')
111+
112+ echo "release=$release" >> $GITHUB_OUTPUT
113+
114+ release_dispatch :
127115 runs-on : ubuntu-latest
128- needs : version_check
129- name : Trigger Remote SDK builds
116+ needs : release
130117 strategy :
131118 matrix :
132- project :
133- - javascript
134- - csharp
135- - python
136- - java
137- - rust
138- - dart
119+ repositories :
120+ - vrchatapi- javascript
121+ - vrchatapi- csharp
122+ - vrchatapi- python
123+ - vrchatapi- java
124+ - vrchatapi- rust
125+ - vrchatapi- dart
139126 steps :
140- - name : Triggering build SDK - ${{ matrix.node }}
141- run : |
142- curl -X POST https://api.github.com/repos/vrchatapi/vrchatapi-${{ matrix.project }}/dispatches \
143- -H 'Accept: application/vnd.github.everest-preview+json' \
144- -u ${{ secrets.ACCESS_TOKEN }} \
145- --data '{"event_type": "spec_release"}'
127+ - run : |
128+ jq -n --argjson payload "$release" '{ event_type: "release", client_payload: $payload }' \
129+ | gh api repos/{owner}/vrchatapi-javascript/dispatches -X POST -i --input -
130+ env:
131+ release: ${{ needs.release.outputs.release }}
132+
133+ # pages:
134+ # name: Upload OpenAPI specification to GitHub Pages
135+ # runs-on: ubuntu-latest
136+ # needs: bundle
137+ # # Only if main branch
138+ # if: github.ref == 'refs/heads/main'
139+ # steps:
140+ # - uses: actions/checkout@v4
141+ #
142+ # - uses: actions/download-artifact@v4
143+ # with:
144+ # name: openapi.yaml
145+ # path: dist
146+ #
147+ # - name: Disable Jekyll for Github Pages
148+ # run: sudo touch dist/.nojekyll; sudo touch dist/index.html
149+ #
150+ # - name: Deploy Bundle to Github Pages 🚀
151+ # uses: JamesIves/github-pages-deploy-action@v4
152+ # with:
153+ # branch: gh-pages
154+ # folder: dist
155+ #
156+ # version_check:
157+ # name: Check if OpenAPI specification version is matching tag
158+ # runs-on: ubuntu-latest
159+ # needs: bundle
160+ # # Only if tag "release/*" is pushed
161+ # if: ${{ startsWith(github.ref, 'refs/tags/release/') }}
162+ # steps:
163+ # - uses: actions/checkout@v4
164+ # - name: Check if OpenAPI specification version is matching tag
165+ # # Tag will be e.g., "release/1.0.0", check if this matches the version in openapi/openapi.yaml
166+ # run: |
167+ # if [[ $(cat openapi/openapi.yaml | grep -oP '(?<=version: ).*') != $(echo $GITHUB_REF | grep -oP '(?<=release/).*') ]]; then
168+ # echo "OpenAPI specification version does not match tag!"
169+ # exit 1
170+ # fi
171+ #
172+ # # https://blog.marcnuri.com/triggering-github-actions-across-different-repositories
173+ # # Make sure this is same as in sdk_generate.yaml
174+ # sdk_generate:
175+ # runs-on: ubuntu-latest
176+ # needs: version_check
177+ # name: Trigger Remote SDK builds
178+ # strategy:
179+ # matrix:
180+ # project:
181+ # - javascript
182+ # - csharp
183+ # - python
184+ # - java
185+ # - rust
186+ # - dart
187+ # steps:
188+ # - name: Triggering build SDK - ${{ matrix.node }}
189+ # run: |
190+ # curl -X POST https://api.github.com/repos/vrchatapi/vrchatapi-${{ matrix.project }}/dispatches \
191+ # -H 'Accept: application/vnd.github.everest-preview+json' \
192+ # -u ${{ secrets.ACCESS_TOKEN }} \
193+ # --data '{"event_type": "spec_release"}'
194+ #
0 commit comments