Skip to content

Commit 8a1f2d9

Browse files
committed
Build both release52 and release53 nightly
1 parent b6a70b6 commit 8a1f2d9

File tree

2 files changed

+93
-12
lines changed

2 files changed

+93
-12
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Nightly publish release branches
2+
3+
on:
4+
schedule:
5+
# Run nightly at 1 AM UTC
6+
- cron: '0 1 * * *'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
actions: write
12+
13+
jobs:
14+
dispatch:
15+
name: Dispatch publish workflow
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Dispatch publish-libs on release branches
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const workflowId = 'publish-libs.yml'
23+
const branches = ['release53', 'release52']
24+
25+
core.info(`Evaluating branches for nightly publish: ${branches.join(', ')}`)
26+
27+
for (const ref of branches) {
28+
// Get current HEAD SHA for the branch
29+
const branchInfo = await github.rest.repos.getBranch({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
branch: ref,
33+
})
34+
const headSha = branchInfo.data?.commit?.sha
35+
if (!headSha) {
36+
core.warning(`Could not determine HEAD SHA for ${ref}, dispatching anyway`)
37+
}
38+
39+
// Find the latest publish-libs run on that branch (workflow_dispatch)
40+
const runs = await github.rest.actions.listWorkflowRuns({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
workflow_id: workflowId,
44+
branch: ref,
45+
event: 'workflow_dispatch',
46+
per_page: 1,
47+
})
48+
49+
const latest = runs.data?.workflow_runs?.[0]
50+
const latestSha = latest?.head_sha
51+
const latestConclusion = latest?.conclusion
52+
53+
if (headSha && latestSha === headSha && latestConclusion === 'success') {
54+
core.info(`Skipping ${ref}: HEAD ${headSha.substring(0, 7)} already published successfully in last run ${latest.id}`)
55+
continue
56+
}
57+
58+
core.info(
59+
`Dispatching ${ref}: HEAD=${headSha ? headSha.substring(0, 7) : 'unknown'} (last=${latestSha ? latestSha.substring(0, 7) : 'none'}, conclusion=${latestConclusion ?? 'none'})`
60+
)
61+
62+
await github.rest.actions.createWorkflowDispatch({
63+
owner: context.repo.owner,
64+
repo: context.repo.repo,
65+
workflow_id: workflowId,
66+
ref,
67+
inputs: {
68+
nightly_mode: 'true',
69+
},
70+
})
71+
}

.github/workflows/publish-libs.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ name: Publish libraries
33
on:
44
# Allows you to run this workflow manually from the Actions tab
55
workflow_dispatch:
6+
inputs:
7+
nightly_mode:
8+
description: 'Enable nightly change detection + skip publishing when no packages changed'
9+
required: false
10+
default: 'false'
11+
type: choice
12+
options:
13+
- 'false'
14+
- 'true'
615
push:
716
tags:
817
- "v**"
9-
schedule:
10-
# Run nightly at 1 AM UTC
11-
- cron: '0 1 * * *'
1218

1319
permissions:
1420
contents: read
@@ -17,6 +23,7 @@ env:
1723
IS_UPSTREAM: ${{ github.repository_owner == 'Sofie-Automation' }}
1824
NPM_PACKAGE_SCOPE: ${{ vars.NPM_PACKAGE_SCOPE }} # In the form of nrkno, without the @
1925
NPM_PACKAGE_PREFIX: ${{ vars.NPM_PACKAGE_PREFIX }} # Set to anything to prefix the published package names with "sofie-". eg in combination with NPM_PACKAGE_SCOPE this will turn @sofie-automation/shared-lib into @nrkno/sofie-shared-lib
26+
IS_NIGHTLY: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.nightly_mode == 'true') }}
2027

2128
jobs:
2229
check-publish:
@@ -171,8 +178,8 @@ jobs:
171178
run: |
172179
cd packages
173180
174-
# Default: publish for non-scheduled events
175-
if [ "${{ github.event_name }}" != "schedule" ]; then
181+
# Default: publish for non-nightly events
182+
if [ "${{ env.IS_NIGHTLY }}" != "true" ]; then
176183
echo "should_publish=1" >> $GITHUB_OUTPUT
177184
exit 0
178185
fi
@@ -214,9 +221,9 @@ jobs:
214221
if [ -d "$PKG/dist" ]; then
215222
CURRENT_DIST_HASH=$(find "$PKG/dist" -type f -print0 | sort -z | xargs -0 cat | sha256sum | cut -c1-8)
216223
else
217-
echo "📦 **$PKG**: No dist folder, will publish" >> $GITHUB_STEP_SUMMARY
218-
HAS_ANY_CHANGES=1
219-
continue
224+
echo " **$PKG**: No dist folder after build" >> $GITHUB_STEP_SUMMARY
225+
echo "Build did not produce $PKG/dist; failing." >&2
226+
exit 1
220227
fi
221228
222229
if [ "$LAST_DIST_HASH" = "$CURRENT_DIST_HASH" ]; then
@@ -278,6 +285,9 @@ jobs:
278285
"
279286
280287
echo "Updated $PKG_DIR to $NEW_VERSION"
288+
else
289+
echo "Missing $PKG_DIR/dist after build; failing." >&2
290+
exit 1
281291
fi
282292
done
283293
@@ -295,22 +305,22 @@ jobs:
295305
CI: true
296306

297307
- name: Build OpenAPI client library
298-
if: ${{ github.event_name != 'schedule' || steps.detect.outputs.should_publish == '1' }}
308+
if: ${{ env.IS_NIGHTLY != 'true' || steps.detect.outputs.should_publish == '1' }}
299309
run: |
300310
cd packages/openapi
301311
yarn build
302312
env:
303313
CI: true
304314
- name: Modify dependencies to use npm packages
305-
if: ${{ github.event_name != 'schedule' || steps.detect.outputs.should_publish == '1' }}
315+
if: ${{ env.IS_NIGHTLY != 'true' || steps.detect.outputs.should_publish == '1' }}
306316
run: |
307317
node scripts/prepublish.js "${{ github.repository }}" "${{ env.NPM_PACKAGE_SCOPE }}" ${{ env.NPM_PACKAGE_PREFIX }}
308318
309319
cd packages
310320
yarn install --no-immutable
311321
312322
- name: Upload release artifact
313-
if: ${{ github.event_name != 'schedule' || steps.detect.outputs.should_publish == '1' }}
323+
if: ${{ env.IS_NIGHTLY != 'true' || steps.detect.outputs.should_publish == '1' }}
314324
uses: actions/upload-artifact@v5
315325
with:
316326
name: publish-dist
@@ -331,7 +341,7 @@ jobs:
331341
- prepare-publish
332342
- test-packages
333343

334-
if: ${{ github.event_name != 'schedule' || needs.prepare-publish.outputs.should_publish == '1' }}
344+
if: ${{ env.IS_NIGHTLY != 'true' || needs.prepare-publish.outputs.should_publish == '1' }}
335345

336346
permissions:
337347
contents: write

0 commit comments

Comments
 (0)