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+ 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+ 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 }}
0 commit comments