Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(ci): validate release notes before publishing images

HoshinoSuzumidc1bca9de7a9
diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml
index 753ee912..0ea1115d 100644
--- a/.github/workflows/publish-images.yml
+++ b/.github/workflows/publish-images.yml
@@ -165,6 +165,62 @@ jobs:
if: steps.trigger.outputs.publish == 'true'
run: echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
+ - name: πŸ“ Generate changelog
+ id: changelog
+ if: steps.trigger.outputs.publish == 'true'
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ RELEASE_NOTES_FILE: ${{ runner.temp }}/release-notes.md
+ RELEASE_TAG: ${{ steps.version.outputs.tag }}
+ IS_PRERELEASE: ${{ steps.version.outputs.prerelease }}
+ run: |
+ set -euo pipefail
+ echo "Generating changelog..."
+
+ echo "All tags:"
+ git tag -l --sort=-version:refname
+
+ PREVIOUS_TAG=""
+ while IFS= read -r candidate; do
+ [[ "$candidate" == "$RELEASE_TAG" ]] && continue
+ if [[ "$IS_PRERELEASE" != true && "$candidate" == *-* ]]; then continue; fi
+ if git merge-base --is-ancestor "$candidate" HEAD; then
+ PREVIOUS_TAG="$candidate"
+ break
+ fi
+ done < <(git tag -l 'v*' --sort=-version:refname)
+
+ echo "Previous tag: $PREVIOUS_TAG"
+
+ if [ -n "$PREVIOUS_TAG" ]; then
+ echo "Generating changelog from $PREVIOUS_TAG to current"
+ changelog=$(npx @uniiem/[email protected] --from="$PREVIOUS_TAG" --no-output --noMerges --noAuthors)
+ contributors=$(node scripts/changelog-contributors.mjs "$PREVIOUS_TAG..HEAD")
+ else
+ echo "No previous tag found, generating full changelog"
+ changelog=$(npx @uniiem/[email protected] --no-output --noMerges --noAuthors)
+ contributors=$(node scripts/changelog-contributors.mjs HEAD)
+ fi
+
+ changelog=$(echo "$changelog" | sed 's/^\[log\][[:space:]]*//')
+ changelog="$changelog
+ $contributors"
+
+ if [[ -z "$(printf '%s' "$changelog" | tr -d '[:space:]')" ]]; then
+ echo "::error::Generated release notes are empty."
+ exit 1
+ fi
+ printf '%s\n' "$changelog" > "$RELEASE_NOTES_FILE"
+
+ - name: Upload release notes
+ if: steps.trigger.outputs.publish == 'true'
+ uses: actions/upload-artifact@v4
+ with:
+ name: release-notes
+ path: ${{ runner.temp }}/release-notes.md
+ if-no-files-found: error
+ retention-days: 7
+
build-and-push:
needs: prepare
if: needs.prepare.outputs.publish == 'true'
@@ -329,59 +385,11 @@ jobs:
VERSION: ${{ needs.prepare.outputs.version }}
IS_PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
steps:
- - name: Checkout immutable release source
- uses: actions/checkout@v7
+ - name: Download validated release notes
+ uses: actions/download-artifact@v4
with:
- ref: ${{ needs.prepare.outputs.commit }}
- fetch-depth: 0
- fetch-tags: true
- persist-credentials: false
-
- - name: πŸ“ Generate changelog
- id: changelog
- env:
- GITHUB_TOKEN: ${{ github.token }}
- RELEASE_NOTES_FILE: ${{ runner.temp }}/release-notes.md
- RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
- IS_PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
- run: |
- set -euo pipefail
- echo "Generating changelog..."
-
- echo "All tags:"
- git tag -l --sort=-version:refname
-
- PREVIOUS_TAG=""
- while IFS= read -r candidate; do
- [[ "$candidate" == "$RELEASE_TAG" ]] && continue
- if [[ "$IS_PRERELEASE" != true && "$candidate" == *-* ]]; then continue; fi
- if git merge-base --is-ancestor "$candidate" HEAD; then
- PREVIOUS_TAG="$candidate"
- break
- fi
- done < <(git tag -l 'v*' --sort=-version:refname)
-
- echo "Previous tag: $PREVIOUS_TAG"
-
- if [ -n "$PREVIOUS_TAG" ]; then
- echo "Generating changelog from $PREVIOUS_TAG to current"
- changelog=$(npx @uniiem/[email protected] --from="$PREVIOUS_TAG" --no-output --noMerges --noAuthors)
- contributors=$(node scripts/changelog-contributors.mjs "$PREVIOUS_TAG..HEAD")
- else
- echo "No previous tag found, generating full changelog"
- changelog=$(npx @uniiem/[email protected] --no-output --noMerges --noAuthors)
- contributors=$(node scripts/changelog-contributors.mjs HEAD)
- fi
-
- changelog=$(echo "$changelog" | sed 's/^\[log\][[:space:]]*//')
- changelog="$changelog
- $contributors"
-
- if [[ -z "$(printf '%s' "$changelog" | tr -d '[:space:]')" ]]; then
- echo "::error::Generated release notes are empty."
- exit 1
- fi
- printf '%s\n' "$changelog" > "$RELEASE_NOTES_FILE"
+ name: release-notes
+ path: ${{ runner.temp }}
- name: πŸ“ Create Release
uses: softprops/action-gh-release@v2
diff --git a/tests/publish-images-workflow.test.ts b/tests/publish-images-workflow.test.ts
index ecced058..ab0bf3f0 100644
--- a/tests/publish-images-workflow.test.ts
+++ b/tests/publish-images-workflow.test.ts
@@ -280,12 +280,22 @@ test('a release whose package version is already correct still marks its annotat
}
})
-test('release notes stay in the release job and are passed as a Markdown file rather than a secret-filtered output', async () => {
+test('release notes are validated before image publication and transferred as an artifact', async () => {
assert.equal(workflow.jobs.prepare.outputs.changelog, undefined)
- const checkout = workflow.jobs.release.steps.find(
- (s: any) => s.name === 'Checkout immutable release source',
+ const generate = steps.findIndex((s: any) => s.name === 'πŸ“ Generate changelog')
+ const resolve = steps.findIndex((s: any) => s.name === 'Resolve immutable release commit')
+ const upload = steps.findIndex((s: any) => s.name === 'Upload release notes')
+ assert(generate > resolve)
+ assert(upload > generate)
+ assert.equal(workflow.jobs['build-and-push'].needs, 'prepare')
+ assert.equal(steps[upload].uses, 'actions/upload-artifact@v4')
+ assert.equal(steps[upload].with['if-no-files-found'], 'error')
+ const download = workflow.jobs.release.steps.find(
+ (s: any) => s.name === 'Download validated release notes',
)
- assert.equal(checkout.with.ref, '${{ needs.prepare.outputs.commit }}')
+ assert.equal(download.uses, 'actions/download-artifact@v4')
+ assert.equal(download.with.name, steps[upload].with.name)
+ assert.equal(download.with.path, '${{ runner.temp }}')
const create = workflow.jobs.release.steps.find(
(s: any) => s.name === 'πŸ“ Create Release',
)