-
Notifications
You must be signed in to change notification settings - Fork 12
Ci/modernise actions #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9649e08
ci: update actions to their current major versions
ariesclark c016258
ci: run build and test workflows on every branch
ariesclark 6025e0d
ci: build from a supplied spec on push, pull request, or call
ariesclark e5dc1ee
ci: use the shared SDK specification action
ariesclark 2f7df21
ci: build against the bundle this SDK generates from
ariesclark d8fafb3
ci: take the default bundle
ariesclark 92e66f4
ci: let setup decide where the bundle comes from
ariesclark bc461db
ci: cache dependencies and drop redundant setup
ariesclark 4091f18
ci: run the generator from its jar instead of an npm wrapper
ariesclark c24de56
ci: use the renamed setup-generator and download actions
ariesclark 1f60b47
ci: split the checks into their own jobs and separate release
ariesclark 37cd8d0
ci: give generation its own job ahead of the checks
ariesclark 3c42cf5
refactor: leave building and testing to CI in generate.sh
ariesclark c4e020c
ci: fold the standalone checks into the ci workflow
ariesclark e19f608
Merge remote-tracking branch 'origin/main' into ci/modernise-actions
ariesclark aecd781
ci: check formatting of the committed sources and the patches
ariesclark 2c9b361
ci: run the checks once per change
ariesclark 184a47a
ci: run the checks once per change, and on fork pull requests
ariesclark 4e77adc
ci: run the checks on every branch
ariesclark 78eded6
ci: report how to install what this run built
ariesclark 82eb95d
ci: report how to install what this run built
ariesclark 5577142
ci: let each SDK report itself
ariesclark 4c59cef
ci: publish from the ci workflow
ariesclark 3487ef9
fix(ci): only publish from the SDK's own repository
ariesclark 066e821
ci: use the actions from the specification's main branch
ariesclark 138284a
Merge remote-tracking branch 'origin/main' into ci/modernise-actions
ariesclark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,85 +1,133 @@ | ||
| on: | ||
| push: | ||
| branches: | ||
| - '**' | ||
| pull_request: | ||
| repository_dispatch: | ||
| types: [release] | ||
| workflow_dispatch: | ||
| inputs: | ||
| json: | ||
| description: 'Passed json from repository_dispatch' | ||
| description: Passed json from repository_dispatch | ||
| required: true | ||
| type: string | ||
| version_postfix: | ||
| description: 'Additional string to concatenate onto the existing version before release' | ||
| description: Additional string to concatenate onto the existing version before release | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| workflow_call: | ||
| inputs: | ||
| ref: | ||
| description: Ref of this repository to build. | ||
| required: false | ||
| type: string | ||
| default: main | ||
|
|
||
| name: Generate VRChat API SDK | ||
| name: CI | ||
|
|
||
| env: | ||
| PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json || '{}'))['version'] }} | ||
| VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }} | ||
|
|
||
| jobs: | ||
| generate: | ||
| runs-on: ubuntu-latest | ||
| name: Generate VRChat API SDK | ||
| env: | ||
| ARTIFACT_NAME: "openapi.json" | ||
| INPUT: ${{ github.event_name == 'repository_dispatch' && toJSON(github.event.client_payload) || inputs.json }} | ||
| SPEC_URL: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json))['artifacts']['openapi.json'] }} | ||
| PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json))['version'] }} | ||
| VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }} | ||
| steps: | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 22 | ||
| - uses: actions/checkout@v6 | ||
| - name: 'Cache node_modules' | ||
| uses: actions/cache@v6 | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| path: node_modules | ||
| key: ${{ runner.os }}-node-v22-${{ hashFiles('**/generate.sh') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-node-v22 | ||
| - name: Install OpenAPI Generator CLI | ||
| run: npm install @openapitools/openapi-generator-cli | ||
| - name: Set OpenAPI Generator version | ||
| run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 7.21.0 | ||
| - name: Set up JDK 20 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: '20' | ||
| distribution: 'temurin' | ||
| - name: Install Rustup toolchain | ||
| uses: moonrepo/setup-rust@v1 | ||
| - name: Download Specification | ||
| run: wget "${SPEC_URL}" '--output-document' "${ARTIFACT_NAME}" | ||
| - name: Check version number | ||
| repository: vrchatapi/vrchatapi-rust | ||
| ref: ${{ inputs.ref || github.ref }} | ||
|
|
||
| - uses: vrchatapi/specification/.github/actions/setup-generator@main | ||
|
|
||
| - uses: vrchatapi/specification/.github/actions/download@main | ||
|
|
||
| - if: env.PASSED_VERSION != '' | ||
| run: | | ||
| set -euo pipefail | ||
| if [ "$(yq '--unwrapScalar' '.info.version' "${ARTIFACT_NAME}")" != ${PASSED_VERSION} ] | ||
| then | ||
| echo -e "Mismatch between actual and expected version!\nAborting Release." >&2 | ||
|
|
||
| if [ "$(yq '--unwrapScalar' '.info.version' openapi.json)" != "${PASSED_VERSION}" ]; then | ||
| echo "Mismatch between actual and expected version" >&2 | ||
| exit 1 | ||
| fi | ||
| - name: Apply Version Postpend | ||
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix != '' }} | ||
| run: yq '--inplace' ".info.version |= \"${PASSED_VERSION}${VERSION_POSTPEND}\"" "${ARTIFACT_NAME}" | ||
| - name: Generate SDK Client | ||
| run: bash ./generate.sh "${ARTIFACT_NAME}" | ||
| - name: Check version number | ||
|
|
||
| - if: env.VERSION_POSTPEND != '' | ||
| run: yq '--inplace' ".info.version |= \"${PASSED_VERSION}${VERSION_POSTPEND}\"" openapi.json | ||
|
|
||
| - run: bash ./generate.sh openapi.json | ||
|
|
||
| - if: env.PASSED_VERSION != '' | ||
| run: | | ||
| set -euo pipefail | ||
| if [ "$(yq '--unwrapScalar' '--input-format=toml' '--output-format=toml' '.package.version' 'Cargo.toml')" != "${PASSED_VERSION}${VERSION_POSTPEND}" ] | ||
| then | ||
| echo -e "Mismatch between actual and expected version!\nAborting Release." >&2 | ||
|
|
||
| if [ "$(yq '--unwrapScalar' '--input-format=toml' '--output-format=toml' '.package.version' Cargo.toml)" != "${PASSED_VERSION}${VERSION_POSTPEND}" ]; then | ||
| echo "Mismatch between actual and expected version" >&2 | ||
| exit 1 | ||
| fi | ||
| - name: Remove API Spec | ||
| run: unlink "${ARTIFACT_NAME}" | ||
| - name: Deploy SDK back into main branch | ||
| uses: JamesIves/github-pages-deploy-action@v4 | ||
|
|
||
| - uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: rust-generated | ||
| path: . | ||
| include-hidden-files: true | ||
|
|
||
| format: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| repository: vrchatapi/vrchatapi-rust | ||
| ref: ${{ inputs.ref || github.ref }} | ||
|
|
||
| - uses: moonrepo/setup-rust@v1.3.0 | ||
| with: | ||
| components: rustfmt | ||
|
|
||
| - run: cargo fmt --all -- --check | ||
|
|
||
| - run: rustfmt --edition 2021 --check patches/*.rs | ||
|
|
||
| test: | ||
| needs: generate | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| name: rust-generated | ||
|
|
||
| - uses: moonrepo/setup-rust@v1.3.0 | ||
|
|
||
| - run: cargo test --all | ||
|
|
||
| publish: | ||
| needs: | ||
| - generate | ||
| - format | ||
| - test | ||
| if: github.repository == 'vrchatapi/vrchatapi-rust' | ||
| && (github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| repository: vrchatapi/vrchatapi-rust | ||
|
|
||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| name: rust-generated | ||
|
|
||
| - run: rm -f openapi.json | ||
|
|
||
| - uses: JamesIves/github-pages-deploy-action@v4.9.0 | ||
| with: | ||
| branch: main | ||
| folder: . | ||
| commit-message: "Upgrade Rust SDK to spec ${{ env.PASSED_VERSION }}${{env.VERSION_POSTPEND}}" | ||
| - name: Deploy to Crates.io | ||
| run: cargo publish --allow-dirty #Cargo.toml is always detected as "dirty", eventhough the changed should have been pushed by the step above | ||
| commit-message: Upgrade Rust SDK to spec ${{ env.PASSED_VERSION }}${{ env.VERSION_POSTPEND }} | ||
|
|
||
| - uses: moonrepo/setup-rust@v1.3.0 | ||
|
|
||
| # Cargo.toml always reads as dirty, though the change was pushed above. | ||
| - run: cargo publish --allow-dirty | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.