π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Extract release notification script
Manav Rathi6e0c90356318
diff --git a/.github/scripts/release-notify.mjs b/.github/scripts/release-notify.mjsnew file mode 100644index 0000000000..59cbe69a55--- /dev/null+++ b/.github/scripts/release-notify.mjs@@ -0,0 +1,83 @@+const apps = {+ photos: {+ packageId: "io.ente.photos",+ testFlightId: "1542026904",+ accentColor: 65280,+ },+ auth: {+ packageId: "io.ente.auth",+ testFlightId: "6444121398",+ accentColor: 8388736,+ },+ locker: {+ packageId: "io.ente.locker",+ testFlightId: "6747611956",+ accentColor: 1077759,+ },+ ensu: {+ packageId: "io.ente.ensu",+ testFlightId: "6758197006",+ accentColor: 16633363,+ },+};++const app = process.argv[2];+const config = apps[app];+const releaseUrl = process.argv[3];+if (!config || !releaseUrl) {+ throw new Error(`Usage: node .github/scripts/release-notify.mjs ${Object.keys(apps).join("|")} <release-url>`);+}++const env = (name) => {+ const value = process.env[name];+ if (!value) {+ throw new Error(`${name} is required`);+ }+ return value;+};++const releaseTitle = env("RELEASE_TITLE");+const releaseBodyGrouped = process.env.RELEASE_BODY_GROUPED ?? "";++let previousChanges = false;+const releaseBody = releaseBodyGrouped+ .split("\n")+ .map((line) => {+ if (line === "Previous changes:") {+ previousChanges = true;+ }+ return previousChanges && line.trim() ? `-# ${line}` : line;+ })+ .join("\n");++const releaseBodyDiscord =+ Array.from(releaseBody).length > 3000+ ? `${Array.from(releaseBody).slice(0, 3000).join("")}\n...\n-# See the GitHub release for full notes.`+ : releaseBody;++const downloadLine = `-# Download: [Play Store](https://play.google.com/store/apps/details?id=${config.packageId}) | [TestFlight](https://appstoreconnect.apple.com/apps/${config.testFlightId}/testflight/ios) | [GitHub Release](${releaseUrl})`;++const components = [{ type: 10, content: `## ${releaseTitle}` }];+if (releaseBodyDiscord) {+ components.push({ type: 10, content: releaseBodyDiscord });+}+components.push({ type: 14 }, { type: 10, content: downloadLine });++const response = await fetch(`${env("DISCORD_WEBHOOK")}?with_components=true`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ flags: 32768,+ components: [+ {+ type: 17,+ accent_color: config.accentColor,+ components,+ },+ ],+ }),+});++if (!response.ok) {+ throw new Error(`Discord notification failed: ${response.status} ${await response.text()}`);+}diff --git a/.github/workflows/auth-build.yml b/.github/workflows/auth-build.ymlindex b72af2c947..809577b148 100644--- a/.github/workflows/auth-build.yml+++ b/.github/workflows/auth-build.yml@@ -667,34 +667,7 @@ jobs:env:DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTERNAL_RELEASE_WEBHOOK }}GH_TOKEN: ${{ github.token }}+ RELEASE_TITLE: ${{ needs.build-metadata.outputs.release_title }}RELEASE_BODY_GROUPED: ${{ needs.build-metadata.outputs.release_body_grouped }}RELEASE_TAG: ${{ needs.build-metadata.outputs.release_tag }}- run: |- release_url="$(gh release view "${RELEASE_TAG}" --json url --jq .url)"- download_line="-# Download: [Play Store](https://play.google.com/store/apps/details?id=io.ente.auth) | [TestFlight](https://appstoreconnect.apple.com/apps/6444121398/testflight/ios) | [GitHub Release](${release_url})"- release_body_discord="$(awk '- /^Previous changes:$/ { previous = 1 }- previous && NF { print "-# " $0; next }- { print }- ' <<< "${RELEASE_BODY_GROUPED}")"- if [ "${#release_body_discord}" -gt 3000 ]; then- release_body_discord="${release_body_discord:0:3000}"$'\n...\n-# See the GitHub release for full notes.'- fi-- jq -n \- --arg title "${{ needs.build-metadata.outputs.release_title }}" \- --arg body "${release_body_discord}" \- --arg download_line "${download_line}" \- '{- flags: 32768,- components: [{- type: 17,- accent_color: 8388736,- components: (- [{type: 10, content: ("## " + $title)}]- + (if $body == "" then [] else [{type: 10, content: $body}] end)- + [{type: 14}, {type: 10, content: $download_line}]- )- }]- }' \- | curl -fsSL -H 'Content-Type: application/json' -d @- "${DISCORD_WEBHOOK}?with_components=true"+ run: node .github/scripts/release-notify.mjs auth "$(gh release view "${RELEASE_TAG}" --json url --jq .url)"diff --git a/.github/workflows/ensu-build.yml b/.github/workflows/ensu-build.ymlindex 6ea0b2f644..0fe94ccdb4 100644--- a/.github/workflows/ensu-build.yml+++ b/.github/workflows/ensu-build.yml@@ -406,34 +406,7 @@ jobs:env:DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTERNAL_RELEASE_WEBHOOK }}GH_TOKEN: ${{ github.token }}+ RELEASE_TITLE: ${{ needs.build-metadata.outputs.release_title }}RELEASE_BODY_GROUPED: ${{ needs.build-metadata.outputs.release_body_grouped }}RELEASE_TAG: ${{ needs.build-metadata.outputs.release_tag }}- run: |- release_url="$(gh release view "${RELEASE_TAG}" --json url --jq .url)"- 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](${release_url})"- release_body_discord="$(awk '- /^Previous changes:$/ { previous = 1 }- previous && NF { print "-# " $0; next }- { print }- ' <<< "${RELEASE_BODY_GROUPED}")"- if [ "${#release_body_discord}" -gt 3000 ]; then- release_body_discord="${release_body_discord:0:3000}"$'\n...\n-# See the GitHub release for full notes.'- fi-- jq -n \- --arg title "${{ needs.build-metadata.outputs.release_title }}" \- --arg body "${release_body_discord}" \- --arg download_line "${download_line}" \- '{- flags: 32768,- components: [{- type: 17,- accent_color: 16633363,- components: (- [{type: 10, content: ("## " + $title)}]- + (if $body == "" then [] else [{type: 10, content: $body}] end)- + [{type: 14}, {type: 10, content: $download_line}]- )- }]- }' \- | curl -fsSL -H 'Content-Type: application/json' -d @- "${DISCORD_WEBHOOK}?with_components=true"+ run: node .github/scripts/release-notify.mjs ensu "$(gh release view "${RELEASE_TAG}" --json url --jq .url)"diff --git a/.github/workflows/locker-build.yml b/.github/workflows/locker-build.ymlindex 256456ed9f..58802642bd 100644--- a/.github/workflows/locker-build.yml+++ b/.github/workflows/locker-build.yml@@ -323,34 +323,7 @@ jobs:env:DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTERNAL_RELEASE_WEBHOOK }}GH_TOKEN: ${{ github.token }}+ RELEASE_TITLE: ${{ needs.build-metadata.outputs.release_title }}RELEASE_BODY_GROUPED: ${{ needs.build-metadata.outputs.release_body_grouped }}RELEASE_TAG: ${{ needs.build-metadata.outputs.release_tag }}- run: |- release_url="$(gh release view "${RELEASE_TAG}" --json url --jq .url)"- download_line="-# Download: [Play Store](https://play.google.com/store/apps/details?id=io.ente.locker) | [TestFlight](https://appstoreconnect.apple.com/apps/6747611956/testflight/ios) | [GitHub Release](${release_url})"- release_body_discord="$(awk '- /^Previous changes:$/ { previous = 1 }- previous && NF { print "-# " $0; next }- { print }- ' <<< "${RELEASE_BODY_GROUPED}")"- if [ "${#release_body_discord}" -gt 3000 ]; then- release_body_discord="${release_body_discord:0:3000}"$'\n...\n-# See the GitHub release for full notes.'- fi-- jq -n \- --arg title "${{ needs.build-metadata.outputs.release_title }}" \- --arg body "${release_body_discord}" \- --arg download_line "${download_line}" \- '{- flags: 32768,- components: [{- type: 17,- accent_color: 1077759,- components: (- [{type: 10, content: ("## " + $title)}]- + (if $body == "" then [] else [{type: 10, content: $body}] end)- + [{type: 14}, {type: 10, content: $download_line}]- )- }]- }' \- | curl -fsSL -H 'Content-Type: application/json' -d @- "${DISCORD_WEBHOOK}?with_components=true"+ run: node .github/scripts/release-notify.mjs locker "$(gh release view "${RELEASE_TAG}" --json url --jq .url)"diff --git a/.github/workflows/photos-build.yml b/.github/workflows/photos-build.ymlindex 250863d34e..90456e9866 100644--- a/.github/workflows/photos-build.yml+++ b/.github/workflows/photos-build.yml@@ -318,34 +318,7 @@ jobs:env:DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTERNAL_RELEASE_WEBHOOK }}GH_TOKEN: ${{ github.token }}+ RELEASE_TITLE: ${{ needs.build-metadata.outputs.release_title }}RELEASE_BODY_GROUPED: ${{ needs.build-metadata.outputs.release_body_grouped }}RELEASE_TAG: ${{ needs.build-metadata.outputs.release_tag }}- run: |- release_url="$(gh release view "${RELEASE_TAG}" --json url --jq .url)"- download_line="-# Download: [Play Store](https://play.google.com/store/apps/details?id=io.ente.photos) | [TestFlight](https://appstoreconnect.apple.com/apps/1542026904/testflight/ios) | [GitHub Release](${release_url})"- release_body_discord="$(awk '- /^Previous changes:$/ { previous = 1 }- previous && NF { print "-# " $0; next }- { print }- ' <<< "${RELEASE_BODY_GROUPED}")"- if [ "${#release_body_discord}" -gt 3000 ]; then- release_body_discord="${release_body_discord:0:3000}"$'\n...\n-# See the GitHub release for full notes.'- fi-- jq -n \- --arg title "${{ needs.build-metadata.outputs.release_title }}" \- --arg body "${release_body_discord}" \- --arg download_line "${download_line}" \- '{- flags: 32768,- components: [{- type: 17,- accent_color: 65280,- components: (- [{type: 10, content: ("## " + $title)}]- + (if $body == "" then [] else [{type: 10, content: $body}] end)- + [{type: 14}, {type: 10, content: $download_line}]- )- }]- }' \- | curl -fsSL -H 'Content-Type: application/json' -d @- "${DISCORD_WEBHOOK}?with_components=true"+ run: node .github/scripts/release-notify.mjs photos "$(gh release view "${RELEASE_TAG}" --json url --jq .url)"