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