|
1 | 1 | name: ci
|
2 | 2 |
|
3 | 3 | on:
|
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
4 | 7 | workflow_dispatch:
|
5 |
| - inputs: |
6 |
| - version: |
7 |
| - description: "The version of the python SDK that you would like to release" |
8 |
| - required: true |
9 |
| - type: string |
10 | 8 |
|
11 | 9 | jobs:
|
12 |
| - fern-check: |
13 |
| - runs-on: ubuntu-latest |
14 |
| - steps: |
15 |
| - - name: Checkout repo |
16 |
| - uses: actions/checkout@v4 |
17 |
| - |
18 |
| - - name: Install Fern |
19 |
| - run: npm install -g fern-api |
20 |
| - |
21 |
| - - name: Check Fern API is valid |
22 |
| - run: fern check |
23 |
| - |
24 | 10 | fern-generate-pr:
|
25 | 11 | needs: fern-check
|
26 | 12 | runs-on: ubuntu-latest
|
|
34 | 20 | - name: Download Fern
|
35 | 21 | run: npm install -g fern-api
|
36 | 22 |
|
| 23 | + - name: Check Fern API is valid |
| 24 | + run: fern check |
| 25 | + |
| 26 | + - name: Get version from label-studio-sdk |
| 27 | + id: sdk-version |
| 28 | + uses: actions/github-script@v7 |
| 29 | + with: |
| 30 | + github-token: ${{ secrets.GIT_PAT }} |
| 31 | + script: | |
| 32 | + const { repo, owner } = context.repo; |
| 33 | + const sdk_repo = 'label-studio-sdk'; |
| 34 | + const pyProjectPath = 'pyproject.toml'; |
| 35 | +
|
| 36 | + const {data: sdk_repo_data} = await github.rest.repos.get({ |
| 37 | + owner, |
| 38 | + repo: sdk_repo, |
| 39 | + }); |
| 40 | + const {data: commit} = await github.rest.repos.getCommit({ |
| 41 | + owner, |
| 42 | + repo: sdk_repo, |
| 43 | + ref: sdk_repo_data.default_branch, |
| 44 | + }); |
| 45 | + const pyprojectBlob = await github.rest.repos.getContent({ |
| 46 | + owner, |
| 47 | + repo: sdk_repo, |
| 48 | + ref: commit.sha, |
| 49 | + path: pyProjectPath, |
| 50 | + }); |
| 51 | + const pyproject = Buffer.from(pyprojectBlob.data.content, pyprojectBlob.data.encoding).toString("utf8"); |
| 52 | + const versionMatch = pyproject.match(/version = "(?<version>[.a-f0-9]+)"/); |
| 53 | + if (versionMatch && versionMatch.groups.version && false) { |
| 54 | + core.setOutput('version', versionMatch.groups.version); |
| 55 | + } else { |
| 56 | + throw `Version not found in ${pyprojectBlob.url}` |
| 57 | + } |
| 58 | +
|
37 | 59 | - name: Publish Python SDK PR
|
38 | 60 | env:
|
39 | 61 | FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
|
40 |
| - run: fern generate --group python-sdk-staging --version ${{ inputs.version }} --log-level debug |
| 62 | + run: fern generate --group python-sdk-staging --version ${{ steps.sdk-version.outputs.version }} --log-level debug |
0 commit comments