|
3 | 3 | branches: |
4 | 4 | - '**' |
5 | 5 | pull_request: |
| 6 | + repository_dispatch: |
| 7 | + types: [release] |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + url: |
| 11 | + type: string |
| 12 | + description: URL (openapi.json) |
6 | 13 | workflow_call: |
7 | 14 | inputs: |
8 | 15 | ref: |
|
11 | 18 | type: string |
12 | 19 | default: main |
13 | 20 |
|
| 21 | +permissions: |
| 22 | + id-token: write |
| 23 | + contents: read |
| 24 | + |
14 | 25 | name: CI |
15 | 26 |
|
16 | 27 | jobs: |
17 | 28 | generate: |
18 | 29 | runs-on: ubuntu-latest |
19 | 30 | outputs: |
20 | 31 | version: ${{ steps.version.outputs.version }} |
| 32 | + tag: ${{ steps.version.outputs.tag }} |
21 | 33 | steps: |
22 | 34 | - uses: actions/checkout@v7 |
23 | 35 | with: |
24 | 36 | repository: vrchatapi/vrchatapi-javascript |
25 | 37 | ref: ${{ inputs.ref || github.ref }} |
26 | 38 |
|
27 | | - - uses: vrchatapi/specification/.github/actions/download@ci/modernise-actions |
| 39 | + - id: released |
| 40 | + if: github.event_name == 'repository_dispatch' || inputs.url != '' |
| 41 | + run: curl -Lfo openapi.json "${{ github.event.client_payload.artifacts['openapi.json'] || inputs.url }}" |
| 42 | + |
| 43 | + - if: steps.released.outcome == 'skipped' |
| 44 | + uses: vrchatapi/specification/.github/actions/download@ci/modernise-actions |
28 | 45 |
|
29 | 46 | - uses: pnpm/setup@v2 |
30 | 47 | with: |
|
47 | 64 | ") |
48 | 65 |
|
49 | 66 | echo "version=$version" >> $GITHUB_OUTPUT |
| 67 | + echo "tag=$(node -p "require('semver').parse('$version')?.prerelease[0] || 'latest'")" >> $GITHUB_OUTPUT |
50 | 68 |
|
51 | 69 | - uses: actions/upload-artifact@v7 |
52 | 70 | with: |
@@ -82,3 +100,40 @@ jobs: |
82 | 100 | --no-template \ |
83 | 101 | --no-compact \ |
84 | 102 | --commentWithSha |
| 103 | +
|
| 104 | + publish: |
| 105 | + needs: |
| 106 | + - generate |
| 107 | + - build |
| 108 | + if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'no_release') |
| 109 | + runs-on: ubuntu-latest |
| 110 | + steps: |
| 111 | + - uses: actions/checkout@v7 |
| 112 | + with: |
| 113 | + repository: vrchatapi/vrchatapi-javascript |
| 114 | + ref: ${{ inputs.ref || github.ref }} |
| 115 | + |
| 116 | + - uses: actions/download-artifact@v8 |
| 117 | + with: |
| 118 | + name: generated-javascript |
| 119 | + path: src/generated |
| 120 | + |
| 121 | + - uses: pnpm/setup@v2 |
| 122 | + with: |
| 123 | + runtime: node@24 |
| 124 | + cache: true |
| 125 | + |
| 126 | + - uses: actions/setup-node@v7 |
| 127 | + with: |
| 128 | + node-version: 24 |
| 129 | + registry-url: https://registry.npmjs.org |
| 130 | + |
| 131 | + # Trusted publishing requires npm CLI version 11.5.1 or later. |
| 132 | + # https://docs.npmjs.com/trusted-publishers |
| 133 | + - run: npm install -g npm@latest |
| 134 | + |
| 135 | + - run: pnpm version ${{ needs.generate.outputs.version }} --no-git-tag-version |
| 136 | + |
| 137 | + - run: pnpm build |
| 138 | + |
| 139 | + - run: pnpm publish --no-git-checks --tag ${{ needs.generate.outputs.tag }} |
0 commit comments