11on :
22 push :
3+ branches :
4+ - main
35 pull_request :
46 workflow_dispatch :
7+ inputs :
8+ no_lint :
9+ description : Skip lint job
10+ type : boolean
11+ default : false
12+ no_release :
13+ description : Skip release job
14+ type : boolean
15+ default : false
516
617env :
718 GH_TOKEN : ${{ github.token }}
819
920jobs :
1021 lint :
22+ if : ${{ !contains(github.event.head_commit.message, 'no_lint') && !github.event.inputs.no_lint }}
1123 runs-on : ubuntu-latest
1224 steps :
1325 - uses : actions/checkout@v4
6577 bundle :
6678 runs-on : ubuntu-latest
6779 needs : lint
80+ if : needs.lint.result != 'failure'
6881 strategy :
6982 matrix :
7083 format : [yaml, json]
99112 release :
100113 runs-on : ubuntu-latest
101114 needs : bundle
102- if : github.ref == 'refs/heads/main' && ! contains(github.event.head_commit.message, '[dry]')
115+ if : github.ref == 'refs/heads/main' && needs.bundle.result != 'failure' && ! contains(github.event.head_commit.message, 'no_release') && !github.event.inputs.no_release
103116 outputs :
104- release : ${{ steps.data .outputs.release }}
117+ version : ${{ steps.metadata .outputs.version }}
105118
106119 steps :
107120 - uses : actions/checkout@v4
@@ -134,15 +147,22 @@ jobs:
134147 - id : metadata
135148 run : |
136149 version=$(jq -r '.info.version' dist/openapi.json)
137- echo "version=$version" >> $GITHUB_ENV
138150
139151 version_sha=$(
140152 git rev-list -n 1 "v$version" 2>/dev/null \
141153 || git rev-list -n 1 "release/$version" 2>/dev/null \
142154 || echo ""
143155 )
144- echo "version_sha=$version_sha" >> $GITHUB_ENV
145- echo "prerelease=$(test -z "$version_sha" && echo false || echo true)" >> $GITHUB_ENV
156+
157+ if [ "$version_sha" == "" ]; then
158+ echo "prerelease=false" >> $GITHUB_ENV
159+ else
160+ echo "prerelease=true" >> $GITHUB_ENV
161+ version=$(pnpm semver $version -i)-nightly.$(git rev-list --count "$version_sha"..HEAD)
162+ fi
163+
164+ echo "version=$version" >> $GITHUB_ENV
165+ echo "::set-output name=version::$version"
146166
147167 - name : create release
148168 if : env.prerelease == 'false'
@@ -151,51 +171,15 @@ jobs:
151171 - name : create release (nightly)
152172 if : env.prerelease == 'true'
153173 run : |
154- version=$(pnpm semver ${{ env.version }} -i)-nightly.$(git rev-list --count "${{ env.version_sha }}"..HEAD)
155- echo "version=$version" >> $GITHUB_ENV
156-
157- jq --arg v "$version" '.info.version = $v' dist/openapi.json > dist/.openapi.json && mv dist/.openapi.json dist/openapi.json
158- yq eval ".info.version = \"$version\"" -i dist/openapi.yaml
174+ jq --arg v "${{ env.version }}" '.info.version = $v' dist/openapi.json > dist/.openapi.json && mv dist/.openapi.json dist/openapi.json
175+ yq eval ".info.version = \"${{ env.version }}\"" -i dist/openapi.yaml
159176
160- gh release create v$version dist/* \
177+ gh release create v${{ env. version }} dist/* \
161178 --generate-notes \
162179 --prerelease
163180
164- - id : data
165- run : |
166- release=$(gh release view v${{ env.version }} --json id,tagName,url,isPrerelease,assets | jq -c '{
167- id,
168- url,
169- version: \"${{ env.version }}\"
170- prerelease: .isPrerelease,
171- artifacts: (
172- .assets
173- | map({ (.name): .url })
174- | add
175- )
176- }')
177-
178- echo "release=$release" >> $GITHUB_OUTPUT
179-
180181 release_dispatch :
181- runs-on : ubuntu-latest
182+ uses : ./.github/workflows/release_dispatch.yaml
182183 needs : release
183- strategy :
184- matrix :
185- repository :
186- - vrchatapi-javascript
187- - vrchatapi-csharp
188- - vrchatapi-python
189- - vrchatapi-java
190- - vrchatapi-rust
191- - vrchatapi-dart
192- steps :
193- - uses : actions/checkout@v4
194-
195- - run : |
196- jq -n --argjson payload "$release" '{ event_type: "release", client_payload: $payload }' \
197- | gh api repos/{owner}/$repository/dispatches -X POST -i --input -
198- env:
199- repository: ${{ matrix.repository }}
200- release: ${{ needs.release.outputs.release }}
201- GH_TOKEN: ${{ secrets.RELEASE_DISPATCH_TOKEN }}
184+ with :
185+ version : ${{ needs.release.outputs.version }}
0 commit comments