Skip to content

Commit ff102a8

Browse files
Skip release publishing for workflow-only main pushes
(cherry picked from commit f0dd557)
1 parent 3c279d4 commit ff102a8

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/release-on-main.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,48 @@ jobs:
2626
- name: Setup CI environment
2727
uses: ./.github/actions/setup-ci-env
2828

29+
- name: Detect release artifact changes
30+
id: release_scope
31+
shell: bash
32+
run: |
33+
set -euo pipefail
34+
BEFORE_SHA='${{ github.event.before }}'
35+
AFTER_SHA='${{ github.sha }}'
36+
RANGE="${BEFORE_SHA}..${AFTER_SHA}"
37+
if [[ -z "${BEFORE_SHA}" || "${BEFORE_SHA}" =~ ^0+$ ]]; then
38+
RANGE="${AFTER_SHA}^..${AFTER_SHA}"
39+
fi
40+
41+
mapfile -t changed_files < <(git diff --name-only "${RANGE}" || true)
42+
should_publish=0
43+
for changed_file in "${changed_files[@]}"; do
44+
case "${changed_file}" in
45+
folderview.plus.plg|folderview.plus.xml|archive/*.txz|archive/*.sha256)
46+
should_publish=1
47+
break
48+
;;
49+
esac
50+
done
51+
52+
{
53+
echo "range=${RANGE}"
54+
echo "should_publish=${should_publish}"
55+
} >> "${GITHUB_OUTPUT}"
56+
57+
- name: Skip release publish for non-release main pushes
58+
if: steps.release_scope.outputs.should_publish != '1'
59+
shell: bash
60+
run: |
61+
{
62+
echo "## Release publish skipped"
63+
echo
64+
echo "No release artifacts changed on this \`main\` push, so GitHub release publishing was intentionally skipped."
65+
echo "Workflow/process-only syncs can land on \`main\` without creating a new plugin release."
66+
} >> "${GITHUB_STEP_SUMMARY}"
67+
2968
- name: Resolve release version and archive
3069
id: release_meta
70+
if: steps.release_scope.outputs.should_publish == '1'
3171
run: |
3272
set -euo pipefail
3373
VERSION=$(grep -oP '<!ENTITY version "\K[^"]+' folderview.plus.plg)
@@ -48,6 +88,7 @@ jobs:
4888
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
4989
5090
- name: Run release validation suite
91+
if: steps.release_scope.outputs.should_publish == '1'
5192
env:
5293
FVPLUS_UNRAID_MATRIX: ${{ secrets.FVPLUS_UNRAID_MATRIX }}
5394
FVPLUS_UNRAID_MATRIX_REQUIRED: ${{ secrets.FVPLUS_UNRAID_MATRIX != '' && '1' || '0' }}
@@ -80,13 +121,15 @@ jobs:
80121
81122
- name: Build release notes from current CHANGES block
82123
id: notes
124+
if: steps.release_scope.outputs.should_publish == '1'
83125
run: |
84126
set -euo pipefail
85127
VERSION="${{ steps.release_meta.outputs.version }}"
86128
chmod +x scripts/build_release_notes.sh
87129
bash scripts/build_release_notes.sh --version "${VERSION}" --output release_notes.md
88130
89131
- name: Validate remote raw publish artifacts
132+
if: steps.release_scope.outputs.should_publish == '1'
90133
env:
91134
FVPLUS_REMOTE_PUBLISH_ATTEMPTS: '30'
92135
FVPLUS_REMOTE_PUBLISH_DELAY_SEC: '10'
@@ -95,6 +138,7 @@ jobs:
95138
bash scripts/remote_publish_guard.sh
96139
97140
- name: Ensure GitHub CLI
141+
if: steps.release_scope.outputs.should_publish == '1'
98142
run: |
99143
if command -v gh >/dev/null 2>&1; then
100144
gh --version
@@ -104,6 +148,7 @@ jobs:
104148
sudo apt-get install -y gh
105149
106150
- name: Create or update GitHub release
151+
if: steps.release_scope.outputs.should_publish == '1'
107152
env:
108153
GH_TOKEN: ${{ github.token }}
109154
run: |

scripts/workflow_self_check.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ if (!/ci-duration-report/.test(ciWorkflow)) {
6767
if (!/bash scripts\/build_release_notes\.sh/.test(releaseOnMainWorkflow)) {
6868
fail('Release On Main workflow must build release notes via scripts/build_release_notes.sh.');
6969
}
70+
if (!/Detect release artifact changes/.test(releaseOnMainWorkflow)) {
71+
fail('Release On Main workflow must detect whether a main push actually changed release artifacts.');
72+
}
73+
if (!/Skip release publish for non-release main pushes/.test(releaseOnMainWorkflow)) {
74+
fail('Release On Main workflow must explicitly skip publishing for workflow-only main pushes.');
75+
}
7076
if (!/gh release create/.test(releaseOnMainWorkflow) || !/gh release edit/.test(releaseOnMainWorkflow)) {
7177
fail('Release On Main workflow must own GitHub release publishing.');
7278
}

tests/versioning-guard.test.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ test('validation workflows delegate to the shared ci suite with dev coverage, fa
364364
});
365365

366366
test('release-on-main validates remote raw publish artifacts before publishing releases', () => {
367+
assert.match(releaseOnMainWorkflow, /Detect release artifact changes/);
368+
assert.match(releaseOnMainWorkflow, /should_publish/);
369+
assert.match(releaseOnMainWorkflow, /Skip release publish for non-release main pushes/);
367370
assert.match(releaseOnMainWorkflow, /Validate remote raw publish artifacts/);
368371
assert.match(releaseOnMainWorkflow, /FVPLUS_REMOTE_PUBLISH_ATTEMPTS:\s*'30'/);
369372
assert.match(releaseOnMainWorkflow, /FVPLUS_REMOTE_PUBLISH_DELAY_SEC:\s*'10'/);

0 commit comments

Comments
 (0)