Skip to content

Commit a1a021a

Browse files
committed
ci: sync actions
1 parent 09fdd1a commit a1a021a

14 files changed

+222
-13
lines changed

.github/workflows/build_pypi.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ on:
2020
description: "Attach Artifact to Release"
2121
type: string
2222
required: false
23+
release_type:
24+
description: "Release type (release or nightly)"
25+
type: string
26+
required: false
27+
default: "release"
2328
outputs:
2429
pipy-artifact-url:
2530
description: "PyPI Artifact URL"
@@ -46,10 +51,19 @@ on:
4651
description: "Attach Artifact to Release"
4752
type: string
4853
required: false
54+
release_type:
55+
description: "Release type (release or nightly)"
56+
type: choice
57+
required: false
58+
default: "release"
59+
options:
60+
- "release"
61+
- "nightly"
4962

5063
env:
5164
PYTHON_VERSION_FILE: "pyproject.toml"
5265
FRONTEND_MONOREPO_DIR: "web"
66+
NODE: "18"
5367

5468
jobs:
5569
pypi:
@@ -161,6 +175,7 @@ jobs:
161175
}
162176
163177
- name: Check SDK version is not git sha
178+
if: inputs.release_type == 'release'
164179
run: grep 'label-studio-sdk\s*=\s*"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"' pyproject.toml
165180

166181
- name: Check Build
@@ -176,7 +191,7 @@ jobs:
176191

177192
- name: Get PyPI package details
178193
id: pypi-package-details
179-
if: inputs.upload_to_pypi
194+
if: inputs.upload_to_pypi && inputs.release_type == 'release'
180195
uses: actions/github-script@v7
181196
env:
182197
VERSION: ${{ inputs.version }}
@@ -211,6 +226,7 @@ jobs:
211226
result=true
212227
for file in $(find "${DIST_DIR}" -maxdepth 1 -type f); do
213228
size=$(du -m "$file" | cut -f1)
229+
echo "${file}(${size}Mb)"
214230
if [ $size -ge $THRESHOLD ]; then
215231
echo "::error::${file}(${size}Mb) exceeds size threshold(${THRESHOLD}Mb)"
216232
result=false
@@ -221,7 +237,7 @@ jobs:
221237
fi
222238
223239
- name: Upload to artifact
224-
if: always()
240+
if: always() && inputs.release_type == 'release'
225241
uses: actions/upload-artifact@v4
226242
with:
227243
name: Dist
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: "Build PyPI Nightly"
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * 1-5' # Run at midnight UTC Monday through Friday
7+
8+
jobs:
9+
calculate-version:
10+
name: "Calculate Version"
11+
runs-on: ubuntu-latest
12+
if: github.repository_owner == 'HumanSignal'
13+
outputs:
14+
version: ${{ steps.set-nightly-version.outputs.version }}
15+
steps:
16+
- name: Set nightly version
17+
id: set-nightly-version
18+
run: |
19+
set -e
20+
version=$(curl -s "https://raw.githubusercontent.com/HumanSignal/label-studio/refs/heads/${{ github.event.repository.default_branch }}/pyproject.toml" | grep '^version' | cut -d'"' -f2)
21+
version="${version%dev*}dev$(date +'%Y%m%d')"
22+
echo "version=${version}" >> $GITHUB_OUTPUT
23+
24+
create-nightly-release:
25+
name: "Create Nightly Release"
26+
runs-on: ubuntu-latest
27+
if: github.repository_owner == 'HumanSignal'
28+
needs: calculate-version
29+
outputs:
30+
release_id: ${{ steps.create_release.outputs.id }}
31+
steps:
32+
- name: Get previous nightly release
33+
id: previous-nightly
34+
uses: actions/github-script@v7
35+
with:
36+
github-token: ${{ secrets.GIT_PAT }}
37+
script: |
38+
const { repo, owner } = context.repo;
39+
try {
40+
const nightlyRelease = await github.rest.repos.getReleaseByTag({
41+
owner,
42+
repo,
43+
tag: 'nightly'
44+
});
45+
await github.rest.repos.deleteRelease({
46+
owner,
47+
repo,
48+
release_id: nightlyRelease.data.id
49+
});
50+
await github.rest.git.deleteRef({
51+
owner,
52+
repo,
53+
ref: 'tags/nightly'
54+
});
55+
} catch (error) {
56+
if (error.status === 404) {
57+
console.log('No previous nightly release found');
58+
} else {
59+
throw error;
60+
}
61+
}
62+
63+
- name: Generate Changelog
64+
uses: actions/github-script@v7
65+
with:
66+
github-token: ${{ secrets.GIT_PAT }}
67+
script: |
68+
const { repo, owner } = context.repo;
69+
const latestRelease = await github.rest.repos.getLatestRelease({
70+
owner,
71+
repo
72+
});
73+
const latestTag = latestRelease.data.tag_name;
74+
const message = `# Nightly Build
75+
76+
This is an automated nightly build that is recreated every night with the latest changes from the \`${{ github.event.repository.default_branch }}\` branch.
77+
78+
## Installation
79+
80+
You can install this nightly build by downloading the wheel package (the file ending in \`.whl\`) from the \`Assets\` section below this description.
81+
After downloading, you can install it using the following commands from your terminal:
82+
83+
For Windows:
84+
\`\`\`bash
85+
pip install %USERPROFILE%\\Downloads\\label_studio-${{ needs.calculate-version.outputs.version }}-py3-none-any.whl
86+
\`\`\`
87+
88+
For macOS/Linux:
89+
\`\`\`bash
90+
pip install ~/Downloads/label_studio-${{ needs.calculate-version.outputs.version }}-py3-none-any.whl
91+
\`\`\`
92+
93+
## Important Notes
94+
- This is a development build and may contain bugs or incomplete features
95+
- Use in production environments is not recommended
96+
- Please report any issues you encounter in our [GitHub Issues](https://github.com/${owner}/${repo}/issues)
97+
- This release is automatically recreated every night with the latest changes
98+
99+
## Changes
100+
Changes since ${latestTag}: https://github.com/${owner}/${repo}/compare/${latestTag}...nightly`;
101+
const fs = require('fs');
102+
fs.writeFileSync('${{ github.workspace }}-CHANGELOG.txt', message);
103+
104+
- name: Create Nightly Release
105+
id: create_release
106+
uses: softprops/[email protected]
107+
with:
108+
token: ${{ secrets.GIT_PAT }}
109+
body_path: ${{ github.workspace }}-CHANGELOG.txt
110+
tag_name: nightly
111+
name: ${{ needs.calculate-version.outputs.version }}
112+
generate_release_notes: false
113+
draft: false
114+
prerelease: true
115+
append_body: false
116+
117+
build-pypi:
118+
name: "Build"
119+
if: github.repository_owner == 'HumanSignal'
120+
needs: [calculate-version, create-nightly-release]
121+
permissions:
122+
contents: write
123+
uses: ./.github/workflows/build_pypi.yml
124+
with:
125+
version: ${{ needs.calculate-version.outputs.version }}
126+
ref: ${{ github.ref_name }}
127+
upload_to_pypi: false
128+
release_type: nightly
129+
release-id: ${{ needs.create-nightly-release.outputs.release_id }}
130+
secrets: inherit
131+
132+
notify_slack_on_failure:
133+
name: "Notify Slack on Failure"
134+
needs:
135+
- build-pypi
136+
- create-nightly-release
137+
runs-on: ubuntu-latest
138+
if: failure()
139+
steps:
140+
- name: Send Notification to Slack
141+
id: slack_notify_ops_release
142+
uses: slackapi/[email protected]
143+
with:
144+
channel-id: '${{ vars.SLACK_CH_RELEASE_TRAIN }}'
145+
slack-message: |
146+
❌ Nightly PyPI build failed! <!subteam^${{ vars.SLACK_GR_DEVOPS }}>
147+
148+
><https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|[Workflow run]>
149+
env:
150+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_LSE_BOT_TOKEN }}

.github/workflows/cicd_pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ jobs:
401401
402402
version="${RELEASE_BRANCH/#ls-release\//}"
403403
404-
previous_tag=$(git tag --sort=-committerdate | head -n1)
404+
previous_tag=$(git tag --sort=-committerdate | grep -v nightly | head -n1)
405405
406406
echo "previous_tag_name=tags/${previous_tag}" >> $GITHUB_OUTPUT
407407

.github/workflows/docker-build-ontop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
uses: docker/[email protected]
9595

9696
- name: Login to DockerHub
97-
uses: docker/login-action@v3.3.0
97+
uses: docker/login-action@v3.4.0
9898
with:
9999
username: ${{ vars.DOCKERHUB_USERNAME }}
100100
password: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
uses: docker/[email protected]
9393

9494
- name: Login to DockerHub
95-
uses: docker/login-action@v3.3.0
95+
uses: docker/login-action@v3.4.0
9696
with:
9797
username: ${{ vars.DOCKERHUB_USERNAME }}
9898
password: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/docker-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ jobs:
117117
> Command | Description
118118
> --- | ---
119119
> /docker build | Build and push custom docker image
120-
reaction-type: hooray
120+
reactions: hooray

.github/workflows/docker-release-promote.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
uses: docker/[email protected]
158158

159159
- name: Login to DockerHub
160-
uses: docker/login-action@v3.3.0
160+
uses: docker/login-action@v3.4.0
161161
with:
162162
username: ${{ vars.DOCKERHUB_USERNAME }}
163163
password: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/ff-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
> Command | Description
3232
> --- | ---
3333
> /ff update | Update feature flags
34-
reaction-type: hooray
34+
reactions: hooray

.github/workflows/fm-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
> Command | Description
3232
> --- | ---
3333
> /fm sync | Sync upstream prs and merge with pull request base
34-
reaction-type: hooray
34+
reactions: hooray
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Follow Merge: Set LSE Check for non Follow Merge PR'
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- ready_for_review
10+
branches:
11+
- develop
12+
- 'ls-release/**'
13+
14+
jobs:
15+
set_lse_check:
16+
name: "Set LSE Check"
17+
if: "${{ ! ( startsWith(github.head_ref, 'fb-') || (startsWith(github.head_ref, 'revert-') && contains(github.head_ref, '-fb-') ) ) }}"
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: hmarr/[email protected]
21+
22+
- name: Set Label Studio status
23+
uses: actions/github-script@v7
24+
env:
25+
SHA: "${{ github.event.pull_request.head.sha || github.event.after }}"
26+
WORKFLOW_RUN_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
27+
with:
28+
github-token: ${{ secrets.GIT_PAT }}
29+
script: |
30+
const {repo, owner} = context.repo;
31+
const sha = process.env.SHA;
32+
const workflow_run_link = process.env.WORKFLOW_RUN_LINK;
33+
34+
const { data: commit_status} = await github.rest.repos.createCommitStatus({
35+
owner,
36+
repo,
37+
sha: sha,
38+
state: "success",
39+
context: "External / LSE PyTest",
40+
description: "",
41+
target_url: workflow_run_link,
42+
});
43+
console.log(`Commit Status created: ${commit_status.url}`);

0 commit comments

Comments
 (0)