Skip to content

Commit cf38bac

Browse files
authored
Merge pull request #4 from HumanSignal/PLT-374
ci: PLT-374: Trigger Generator
2 parents 688f2f1 + e9e8b56 commit cf38bac

File tree

1 file changed

+40
-18
lines changed

1 file changed

+40
-18
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
name: ci
22

33
on:
4+
push:
5+
branches:
6+
- master
47
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
108

119
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-
2410
fern-generate-pr:
2511
needs: fern-check
2612
runs-on: ubuntu-latest
@@ -34,7 +20,43 @@ jobs:
3420
- name: Download Fern
3521
run: npm install -g fern-api
3622

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+
3759
- name: Publish Python SDK PR
3860
env:
3961
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

Comments
 (0)