Skip to content

Commit d21bbe2

Browse files
committed
ci: publish from the ci workflow
1 parent 024710f commit d21bbe2

2 files changed

Lines changed: 68 additions & 82 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ on:
33
branches:
44
- '**'
55
pull_request:
6+
repository_dispatch:
7+
types: [release]
8+
workflow_dispatch:
9+
inputs:
10+
json:
11+
description: Passed json from repository_dispatch
12+
required: true
13+
type: string
14+
version_postfix:
15+
description: Additional string to concatenate onto the existing version before release
16+
required: false
17+
type: string
18+
default: ''
619
workflow_call:
720
inputs:
821
ref:
@@ -13,9 +26,15 @@ on:
1326

1427
name: CI
1528

29+
env:
30+
PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json || '{}'))['version'] }}
31+
VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }}
32+
1633
jobs:
1734
generate:
1835
runs-on: ubuntu-latest
36+
outputs:
37+
version: ${{ steps.version.outputs.version }}
1938
steps:
2039
- uses: actions/checkout@v7
2140
with:
@@ -28,11 +47,22 @@ jobs:
2847
with:
2948
bundle: openapi-legacy.yaml
3049

31-
- run: bash ./generate.sh openapi-legacy.yaml "$(yq -r '.info.version' openapi-legacy.yaml)"
50+
# PyPI wants `.dev` where the specification says `-nightly.`
51+
- id: version
52+
run: |
53+
version="${PASSED_VERSION}${VERSION_POSTPEND}"
54+
version="${version:-$(yq -r '.info.version' openapi-legacy.yaml)}"
55+
56+
echo "version=${version/-nightly./.dev}" >> $GITHUB_OUTPUT
57+
58+
- if: env.VERSION_POSTPEND != ''
59+
run: yq '--inplace' ".info.version |= \"${{ steps.version.outputs.version }}\"" openapi-legacy.yaml
60+
61+
- run: bash ./generate.sh openapi-legacy.yaml "${{ steps.version.outputs.version }}"
3262

3363
- uses: actions/upload-artifact@v7
3464
with:
35-
name: generated-python
65+
name: python-generated
3666
path: .
3767
include-hidden-files: true
3868

@@ -42,7 +72,7 @@ jobs:
4272
steps:
4373
- uses: actions/download-artifact@v8
4474
with:
45-
name: generated-python
75+
name: python-generated
4676

4777
- uses: actions/setup-python@v7
4878
with:
@@ -51,11 +81,11 @@ jobs:
5181

5282
- run: python -m pip install build
5383

54-
- run: python -m build
84+
- run: python -m build --sdist --wheel --outdir dist/ .
5585

5686
- uses: actions/upload-artifact@v7
5787
with:
58-
name: dist-python
88+
name: python-package
5989
path: dist
6090

6191
install:
@@ -64,7 +94,7 @@ jobs:
6494
steps:
6595
- uses: actions/download-artifact@v8
6696
with:
67-
name: dist-python
97+
name: python-package
6898
path: dist
6999

70100
- uses: actions/setup-python@v7
@@ -74,3 +104,35 @@ jobs:
74104
- run: python -m pip install dist/*.whl
75105

76106
- run: python -c "import vrchatapi; print(vrchatapi.__name__)"
107+
108+
publish:
109+
needs:
110+
- generate
111+
- build
112+
- install
113+
if: github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch'
114+
runs-on: ubuntu-latest
115+
steps:
116+
- uses: actions/checkout@v7
117+
118+
- uses: actions/download-artifact@v8
119+
with:
120+
name: python-generated
121+
122+
- run: rm -f openapi-legacy.yaml
123+
124+
- uses: JamesIves/github-pages-deploy-action@v4.9.0
125+
with:
126+
branch: main
127+
folder: .
128+
commit-message: Upgrade Python SDK to spec ${{ needs.generate.outputs.version }}
129+
130+
- uses: actions/download-artifact@v8
131+
with:
132+
name: python-package
133+
path: dist
134+
135+
- uses: pypa/gh-action-pypi-publish@release/v1
136+
with:
137+
skip_existing: true
138+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release.yaml

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)