Skip to content

Commit af87a8c

Browse files
Harden release scripts and checksum workflow handling
1 parent 31d673c commit af87a8c

7 files changed

Lines changed: 56 additions & 9 deletions

File tree

.github/workflows/release-beta.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,23 @@ jobs:
6161
run: |
6262
VERSION="${{ steps.beta.outputs.version }}"
6363
FILENAME="archive/folderview.plus-${VERSION}.txz"
64+
CHECKSUM="${FILENAME}.sha256"
6465
6566
if [ ! -f "$FILENAME" ]; then
6667
echo "ERROR: Expected $FILENAME not found"
6768
ls -la archive/
6869
exit 1
6970
fi
71+
if [ ! -f "$CHECKSUM" ]; then
72+
echo "ERROR: Expected $CHECKSUM not found"
73+
ls -la archive/
74+
exit 1
75+
fi
7076
7177
# Verify plg was updated
7278
PLG_VERSION=$(grep -oP '<!ENTITY version "\K[^"]+' folderview.plus.plg)
7379
echo "Package: $FILENAME"
80+
echo "Checksum: $CHECKSUM"
7481
echo "PLG version: $PLG_VERSION"
7582
7683
if [ "$PLG_VERSION" != "$VERSION" ]; then
@@ -105,7 +112,7 @@ jobs:
105112
106113
- name: Commit and push to beta
107114
run: |
108-
git add archive/ folderview.plus.plg
115+
git add archive/ folderview.plus.plg folderview.plus.xml
109116
git commit -m "Build beta ${{ steps.beta.outputs.version }}"
110117
git push origin beta
111118

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@ jobs:
3030
set -euo pipefail
3131
VERSION=$(grep -oP '<!ENTITY version "\K[^"]+' folderview.plus.plg)
3232
ARCHIVE="archive/folderview.plus-${VERSION}.txz"
33+
CHECKSUM="${ARCHIVE}.sha256"
3334
if [ ! -f "${ARCHIVE}" ]; then
3435
echo "ERROR: expected archive not found: ${ARCHIVE}" >&2
3536
exit 1
3637
fi
38+
if [ ! -f "${CHECKSUM}" ]; then
39+
echo "ERROR: expected checksum not found: ${CHECKSUM}" >&2
40+
exit 1
41+
fi
3742
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
3843
echo "archive=${ARCHIVE}" >> "$GITHUB_OUTPUT"
44+
echo "checksum=${CHECKSUM}" >> "$GITHUB_OUTPUT"
3945
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
4046
4147
- name: Run release guard
@@ -120,11 +126,12 @@ jobs:
120126
set -euo pipefail
121127
TAG="${{ steps.release_meta.outputs.tag }}"
122128
ARCHIVE="${{ steps.release_meta.outputs.archive }}"
129+
CHECKSUM="${{ steps.release_meta.outputs.checksum }}"
123130
if gh release view "${TAG}" >/dev/null 2>&1; then
124131
gh release edit "${TAG}" --title "${TAG}" --notes-file release_notes.md
125-
gh release upload "${TAG}" "${ARCHIVE}" --clobber
132+
gh release upload "${TAG}" "${ARCHIVE}" "${CHECKSUM}" --clobber
126133
echo "Updated release ${TAG}"
127134
else
128-
gh release create "${TAG}" "${ARCHIVE}" --title "${TAG}" --notes-file release_notes.md
135+
gh release create "${TAG}" "${ARCHIVE}" "${CHECKSUM}" --title "${TAG}" --notes-file release_notes.md
129136
echo "Created release ${TAG}"
130137
fi

.github/workflows/release-stable.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ jobs:
7777
VERSION=$(grep -oP '<!ENTITY version "\K[^"]+' folderview.plus.plg)
7878
echo "version=$VERSION" >> $GITHUB_OUTPUT
7979
FILENAME="folderview.plus-${VERSION}.txz"
80+
CHECKSUM_FILENAME="${FILENAME}.sha256"
81+
if [ ! -f "archive/${CHECKSUM_FILENAME}" ]; then
82+
echo "ERROR: Missing checksum archive/${CHECKSUM_FILENAME}" >&2
83+
exit 1
84+
fi
8085
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
86+
echo "checksum_filename=$CHECKSUM_FILENAME" >> $GITHUB_OUTPUT
8187
echo "Stable version: $VERSION"
8288
8389
# Rename beta version headers to stable in both changelog files
@@ -114,7 +120,9 @@ jobs:
114120
Install URL: `https://raw.githubusercontent.com/alexphillips-dev/FolderView-Plus/main/folderview.plus.plg`
115121
116122
See [CHANGELOG-fixes.md](CHANGELOG-fixes.md) for detailed changes.
117-
files: archive/${{ steps.version.outputs.filename }}
123+
files: |
124+
archive/${{ steps.version.outputs.filename }}
125+
archive/${{ steps.version.outputs.checksum_filename }}
118126
draft: false
119127
prerelease: false
120128

scripts/ensure_plg_changes_entry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ awk -v version="${VERSION}" '
3030
if (!inserted && $0 ~ /<CHANGES>/) {
3131
print ""
3232
print "###" version
33-
print "- Automated release metadata update."
33+
print "- Maintenance: automated release metadata update."
3434
print ""
3535
inserted = 1
3636
}

scripts/install_smoke.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -euo pipefail
33

44
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
55
PLG_FILE="${ROOT_DIR}/folderview.plus.plg"
6+
ARCHIVE_DIR="${FVPLUS_ARCHIVE_DIR:-${ROOT_DIR}/archive}"
67

78
if [[ ! -f "${PLG_FILE}" ]]; then
89
echo "ERROR: Missing plugin manifest: ${PLG_FILE}" >&2
@@ -15,7 +16,7 @@ if [[ -z "${VERSION}" ]]; then
1516
exit 1
1617
fi
1718

18-
ARCHIVE_FILE="${ROOT_DIR}/archive/folderview.plus-${VERSION}.txz"
19+
ARCHIVE_FILE="${ARCHIVE_DIR}/folderview.plus-${VERSION}.txz"
1920
if [[ ! -f "${ARCHIVE_FILE}" ]]; then
2021
echo "ERROR: Missing archive for current version: ${ARCHIVE_FILE}" >&2
2122
exit 1

scripts/release_prepare.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ chmod +x pkg_build.sh scripts/ensure_plg_changes_entry.sh scripts/release_guard.
88

99
if [[ "${1:-}" == "--beta" ]]; then
1010
if [[ -n "${2:-}" ]]; then
11-
bash pkg_build.sh --beta "${2}"
11+
bash pkg_build.sh --beta "${2}" --no-validate
1212
else
13-
bash pkg_build.sh --beta
13+
bash pkg_build.sh --beta --no-validate
1414
fi
1515
else
16-
bash pkg_build.sh
16+
bash pkg_build.sh --no-validate
1717
fi
1818

1919
bash scripts/ensure_plg_changes_entry.sh

tests/versioning-guard.test.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const releaseBetaWorkflowPath = path.join(repoRoot, '.github/workflows/release-b
1414
const releaseOnMainWorkflowPath = path.join(repoRoot, '.github/workflows/release-on-main.yml');
1515
const browserSmokeShellPath = path.join(repoRoot, 'scripts/browser_smoke.sh');
1616
const browserSmokeNodePath = path.join(repoRoot, 'scripts/browser_smoke.mjs');
17+
const installSmokePath = path.join(repoRoot, 'scripts/install_smoke.sh');
18+
const ensureChangesPath = path.join(repoRoot, 'scripts/ensure_plg_changes_entry.sh');
1719
const pkgBuild = fs.readFileSync(pkgBuildPath, 'utf8');
1820
const releaseGuard = fs.readFileSync(releaseGuardPath, 'utf8');
1921
const releasePrepare = fs.readFileSync(releasePreparePath, 'utf8');
@@ -24,6 +26,8 @@ const releaseBetaWorkflow = fs.readFileSync(releaseBetaWorkflowPath, 'utf8');
2426
const releaseOnMainWorkflow = fs.readFileSync(releaseOnMainWorkflowPath, 'utf8');
2527
const browserSmokeShell = fs.readFileSync(browserSmokeShellPath, 'utf8');
2628
const browserSmokeNode = fs.readFileSync(browserSmokeNodePath, 'utf8');
29+
const installSmoke = fs.readFileSync(installSmokePath, 'utf8');
30+
const ensureChanges = fs.readFileSync(ensureChangesPath, 'utf8');
2731

2832
test('pkg_build computes stable versions per current date only', () => {
2933
assert.match(pkgBuild, /next_stable_version_for_date/);
@@ -121,6 +125,8 @@ test('validation workflows include optional browser smoke integration', () => {
121125
assert.match(workflow, /bash scripts\/browser_smoke\.sh/);
122126
}
123127
assert.match(releasePrepare, /bash scripts\/browser_smoke\.sh/);
128+
assert.match(releasePrepare, /bash pkg_build\.sh --no-validate/);
129+
assert.match(releasePrepare, /bash pkg_build\.sh --beta .* --no-validate/);
124130
});
125131

126132
test('release-on-main workflow auto-publishes validated releases from current plg version', () => {
@@ -132,7 +138,25 @@ test('release-on-main workflow auto-publishes validated releases from current pl
132138
assert.match(releaseOnMainWorkflow, /release_notes\.md/);
133139
assert.match(releaseOnMainWorkflow, /folderview\.plus\.plg/);
134140
assert.match(releaseOnMainWorkflow, /archive\/folderview\.plus-\$\{VERSION\}\.txz/);
141+
assert.match(releaseOnMainWorkflow, /CHECKSUM="\$\{ARCHIVE\}\.sha256"/);
135142
assert.match(releaseOnMainWorkflow, /gh release create/);
136143
assert.match(releaseOnMainWorkflow, /gh release edit/);
144+
assert.match(releaseOnMainWorkflow, /gh release upload "\$\{TAG\}" "\$\{ARCHIVE\}" "\$\{CHECKSUM\}" --clobber/);
137145
assert.match(releaseOnMainWorkflow, /GH_TOKEN:\s*\$\{\{\s*github\.token\s*\}\}/);
138146
});
147+
148+
test('install smoke supports configurable archive directory override', () => {
149+
assert.match(installSmoke, /ARCHIVE_DIR="\$\{FVPLUS_ARCHIVE_DIR:-\$\{ROOT_DIR\}\/archive\}"/);
150+
assert.match(installSmoke, /ARCHIVE_FILE="\$\{ARCHIVE_DIR\}\/folderview\.plus-\$\{VERSION\}\.txz"/);
151+
});
152+
153+
test('ensure changes entry seeds category-signaling release note text', () => {
154+
assert.match(ensureChanges, /Maintenance: automated release metadata update/);
155+
});
156+
157+
test('release workflows keep checksum assets and metadata changes', () => {
158+
assert.match(releaseBetaWorkflow, /CHECKSUM="\$\{FILENAME\}\.sha256"/);
159+
assert.match(releaseBetaWorkflow, /git add archive\/ folderview\.plus\.plg folderview\.plus\.xml/);
160+
assert.match(releaseStableWorkflow, /CHECKSUM_FILENAME="\$\{FILENAME\}\.sha256"/);
161+
assert.match(releaseStableWorkflow, /archive\/\$\{\{ steps\.version\.outputs\.checksum_filename \}\}/);
162+
});

0 commit comments

Comments
 (0)