Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
fix(ci): generate release notes in the publishing job
HoshinoSuzumiadb918e05beb
diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.ymlindex 3132bfaa..753ee912 100644--- a/.github/workflows/publish-images.yml+++ b/.github/workflows/publish-images.yml@@ -45,7 +45,6 @@ jobs:outputs:version: ${{ steps.version.outputs.version }}prerelease: ${{ steps.version.outputs.prerelease }}- changelog: ${{ steps.changelog.outputs.changelog }}commit: ${{ steps.source.outputs.commit }}tag: ${{ steps.version.outputs.tag }}publish: ${{ steps.trigger.outputs.publish }}@@ -166,50 +165,6 @@ 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_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"-- echo "changelog<<EOF" >> $GITHUB_OUTPUT- echo "$changelog" >> $GITHUB_OUTPUT- echo "EOF" >> $GITHUB_OUTPUT-build-and-push:needs: prepareif: needs.prepare.outputs.publish == 'true'@@ -374,12 +329,66 @@ jobs:VERSION: ${{ needs.prepare.outputs.version }}IS_PRERELEASE: ${{ needs.prepare.outputs.prerelease }}steps:+ - name: Checkout immutable release source+ uses: actions/checkout@v7+ 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: π Create Releaseuses: softprops/action-gh-release@v2with:tag_name: ${{ needs.prepare.outputs.tag }}target_commitish: ${{ needs.prepare.outputs.commit }}name: Release v${{ env.VERSION }}- body: ${{ needs.prepare.outputs.changelog }}+ body_path: ${{ runner.temp }}/release-notes.mdprerelease: ${{ env.IS_PRERELEASE == 'true' }}draft: truediff --git a/tests/publish-images-workflow.test.ts b/tests/publish-images-workflow.test.tsindex 5a287afc..ecced058 100644--- a/tests/publish-images-workflow.test.ts+++ b/tests/publish-images-workflow.test.ts@@ -1,6 +1,13 @@import assert from 'node:assert/strict'import test from 'node:test'-import { mkdtemp, mkdir, readFile, writeFile, rm } from 'node:fs/promises'+import {+ mkdtemp,+ mkdir,+ readFile,+ writeFile,+ rm,+ chmod,+} from 'node:fs/promises'import { tmpdir } from 'node:os'import { join, dirname } from 'node:path'import { execFileSync, spawnSync } from 'node:child_process'@@ -38,7 +45,9 @@ const git = (cwd: string, ...args: string[]) =>stdio: ['ignore', 'pipe', 'pipe'],}).trim()function runStep(name: string, cwd: string, env: Record<string, string> = {}) {- const step = steps.find((s: any) => s.name === name)+ const step = [...steps, ...workflow.jobs.release.steps].find(+ (s: any) => s.name === name,+ )assert(step?.run, name)return spawnSync('bash', ['-e', '-o', 'pipefail', '-c', step.run], {cwd,@@ -270,3 +279,71 @@ test('a release whose package version is already correct still marks its annotatawait rm(f.root, { recursive: true, force: true })}})++test('release notes stay in the release job and are passed as a Markdown file rather than a secret-filtered output', async () => {+ assert.equal(workflow.jobs.prepare.outputs.changelog, undefined)+ const checkout = workflow.jobs.release.steps.find(+ (s: any) => s.name === 'Checkout immutable release source',+ )+ assert.equal(checkout.with.ref, '${{ needs.prepare.outputs.commit }}')+ const create = workflow.jobs.release.steps.find(+ (s: any) => s.name === 'π Create Release',+ )+ assert.equal(create.with.body, undefined)+ assert.equal(create.with.body_path, '${{ runner.temp }}/release-notes.md')+ const f = await fixture()+ try {+ git(f.work, 'tag', 'v1.0.2')+ success(runStep('Commit version and create release tag', f.work))+ const bin = join(f.root, 'bin'),+ scripts = join(f.work, 'scripts')+ await mkdir(bin)+ await mkdir(scripts)+ await writeFile(+ join(bin, 'npx'),+ `#!/bin/sh+printf '%s\\n' "$@" > "$NPX_ARGUMENTS_FILE"+if [ "$RELEASE_NOTE_FIXTURE_EMPTY" != true ]; then+ printf '[log] ## Features\\n[log] \\n[log] - Public release changes (@PublicMaintainer)\\n'+fi+`,+ )+ await chmod(join(bin, 'npx'), 0o755)+ await writeFile(+ join(scripts, 'changelog-contributors.mjs'),+ `import fs from 'node:fs';fs.writeFileSync(process.env.CONTRIBUTOR_RANGE_FILE,process.argv[2]);if(process.env.RELEASE_NOTE_FIXTURE_EMPTY!=='true')console.log('### β€οΈ Contributors\\n\\n- Public Maintainer (@PublicMaintainer)')`,+ )+ const notes = join(f.root, 'notes.md')+ const env = {+ PATH: bin + ':' + environment.PATH,+ RELEASE_NOTES_FILE: notes,+ IS_PRERELEASE: 'false',+ NPX_ARGUMENTS_FILE: join(f.root, 'args'),+ CONTRIBUTOR_RANGE_FILE: join(f.root, 'range'),+ }+ success(runStep('π Generate changelog', f.work, env))+ const body = await readFile(notes, 'utf8')+ assert.match(body, /## Features/)+ assert.match(body, /### β€οΈ Contributors/)+ assert.match(body, /@PublicMaintainer/)+ assert(!body.includes('[log]'))+ assert(!body.includes('ChronoFrame-Publish-Images-Run'))+ assert.equal(await readFile(join(f.root, 'range'), 'utf8'), 'v1.0.2..HEAD')+ assert(+ (await readFile(join(f.root, 'args'), 'utf8')).includes('--from=v1.0.2'),+ )+ const output = await readFile(join(f.work, 'output'), 'utf8').catch(+ () => '',+ )+ assert(!output.includes('changelog'))+ const empty = runStep('π Generate changelog', f.work, {+ ...env,+ RELEASE_NOTES_FILE: join(f.root, 'empty.md'),+ RELEASE_NOTE_FIXTURE_EMPTY: 'true',+ })+ assert.notEqual(empty.status, 0)+ assert.match(empty.stdout, /Generated release notes are empty/)+ } finally {+ await rm(f.root, { recursive: true, force: true })+ }+})