π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Generate grouped Ensu release notes
Manav Rathi9319af1edaa8
diff --git a/.github/scripts/release-notes.mjs b/.github/scripts/release-notes.mjsnew file mode 100644index 0000000000..809cb98081--- /dev/null+++ b/.github/scripts/release-notes.mjs@@ -0,0 +1,80 @@+#!/usr/bin/env node++import fs from "node:fs";+import path from "node:path";+import { spawnSync } from "node:child_process";++const [changesDir, previousRef] = process.argv.slice(2);++if (!changesDir) {+ console.error("Usage: node .github/scripts/release-notes.mjs <changes-dir> [previous-ref]");+ process.exit(2);+}++function git(args) {+ const result = spawnSync("git", args, { encoding: "utf8" });+ return result.status === 0 ? result.stdout : "";+}++function readMarkdown(file) {+ return fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n").replace(/\n?$/, "\n");+}++function changesetFiles(dir) {+ return fs+ .readdirSync(dir)+ .filter((name) => name.endsWith(".md") && name !== "README.md")+ .sort()+ .map((name) => path.join(dir, name));+}++function changesetFilesAtRef(dir, ref) {+ const prefix = dir.replace(/^\.\//, "").replace(/\/$/, "");+ return git(["ls-tree", "-r", "--name-only", ref, "--", prefix])+ .split("\n")+ .filter((file) => path.dirname(file) === prefix)+ .filter((file) => file.endsWith(".md") && path.basename(file) !== "README.md")+ .sort();+}++function currentBody() {+ return changesetFiles(changesDir).map(readMarkdown).join("").trim();+}++function previousBody() {+ if (!previousRef) return "";+ return changesetFilesAtRef(changesDir, previousRef)+ .map((file) => git(["show", `${previousRef}:${file}`]).replace(/\r\n/g, "\n").replace(/\n?$/, "\n"))+ .join("")+ .trim();+}++function groupedBody(body, previous) {+ const previousLines = new Set(previous.split("\n").filter(Boolean));+ if (!previousLines.size) return body;++ const latest = [];+ const previousAgain = [];+ for (const line of body.split("\n").filter(Boolean)) {+ (previousLines.has(line) ? previousAgain : latest).push(line);+ }++ if (!previousAgain.length) return body;+ return [+ latest.length ? `Latest changes:\n\n${latest.join("\n")}` : "",+ `Previous changes:\n${previousAgain.join("\n")}`,+ ]+ .filter(Boolean)+ .join("\n\n");+}++function output(name, value) {+ console.log(`${name}<<EOF`);+ console.log(value);+ console.log("EOF");+}++const body = currentBody();++output("release_body", body);+output("release_body_grouped", groupedBody(body, previousBody()));diff --git a/.github/workflows/ensu-build.yml b/.github/workflows/ensu-build.ymlindex 30461a1ca2..15e5f3e53a 100644--- a/.github/workflows/ensu-build.yml+++ b/.github/workflows/ensu-build.yml@@ -33,6 +33,7 @@ jobs:release_tag: ${{ steps.prepare.outputs.release_tag }}release_title: ${{ steps.prepare.outputs.release_title }}release_body: ${{ steps.prepare.outputs.release_body }}+ release_body_grouped: ${{ steps.prepare.outputs.release_body_grouped }}steps:- name: Checkout code@@ -77,17 +78,14 @@ jobs:ficommit_sha="$(git rev-parse HEAD)"+ git fetch --force --depth=1 --no-tags origin "refs/tags/${release_tag}:refs/tags/${release_tag}" || trueecho "should_build=true" >> "${GITHUB_OUTPUT}"echo "commit_sha=${commit_sha}" >> "${GITHUB_OUTPUT}"echo "build_number=${build_number}" >> "${GITHUB_OUTPUT}"echo "release_tag=${release_tag}" >> "${GITHUB_OUTPUT}"echo "release_title=${release_title}" >> "${GITHUB_OUTPUT}"- {- echo "release_body<<EOF"- find rust/apps/ensu/changes -maxdepth 1 -type f -name '*.md' ! -name README.md | sort | xargs awk 1- echo "EOF"- } >> "${GITHUB_OUTPUT}"+ node .github/scripts/release-notes.mjs rust/apps/ensu/changes "${release_tag}" >> "${GITHUB_OUTPUT}"build-desktop:needs: build-metadata@@ -406,14 +404,19 @@ jobs:continue-on-error: trueenv:DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTERNAL_RELEASE_WEBHOOK }}- RELEASE_BODY: ${{ needs.build-metadata.outputs.release_body }}+ RELEASE_BODY_GROUPED: ${{ needs.build-metadata.outputs.release_body_grouped }}RELEASE_TAG: ${{ needs.build-metadata.outputs.release_tag }}run: |download_line="-# Download: [Play Store](https://play.google.com/store/apps/details?id=io.ente.ensu) | [TestFlight](https://appstoreconnect.apple.com/apps/6758197006/testflight/ios) | [GitHub Release](https://github.com/${GITHUB_REPOSITORY}/releases/tag/${RELEASE_TAG})"+ release_body_discord="$(awk '+ /^Previous changes:$/ { previous = 1 }+ previous && NF { print "-# " $0; next }+ { print }+ ' <<< "${RELEASE_BODY_GROUPED}")"jq -n \--arg title "${{ needs.build-metadata.outputs.release_title }}" \- --arg body "${RELEASE_BODY}" \+ --arg body "${release_body_discord}" \--arg download_line "${download_line}" \'{embeds: [{title: $title, description: ($body + "\n\n" + $download_line), color: 16633363}]}' \| curl -fsSL -H 'Content-Type: application/json' -d @- "${DISCORD_WEBHOOK}"