Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(ci): use bot API (POST /channels/{forum}/threads) for forum channels
EtienneLescot990cead31eb1
diff --git a/.github/scripts/discord-release-announce.mjs b/.github/scripts/discord-release-announce.mjsindex 2df2cbf78..64321e67c 100644--- a/.github/scripts/discord-release-announce.mjs+++ b/.github/scripts/discord-release-announce.mjs@@ -1,21 +1,12 @@import { info, warning } from "@actions/core";import { context, getOctokit } from "@actions/github";-const WEBHOOK_USERNAME = (process.env.DISCORD_WEBHOOK_USERNAME || "OpenScreen").trim();-const WEBHOOK_AVATAR = (process.env.DISCORD_WEBHOOK_AVATAR_URL || "").trim();-const botToken = (process.env.DISCORD_BOT_TOKEN || "").trim();const channelId = (process.env.DISCORD_RC_TESTING_CHANNEL_ID ||process.env.DISCORD_RELEASE_CHANNEL_ID ||"").trim();-const webhookUrl = (- process.env.DISCORD_RC_TESTING_WEBHOOK_URL ||- process.env.DISCORD_RELEASE_WEBHOOK_URL ||- process.env.DISCORD_WEBHOOK_URL ||- ""-).trim();const kind = (process.env.KIND || "stable").trim();const stableTag = (process.env.STABLE_TAG || "").trim();@@ -26,11 +17,8 @@ if (!stableTag) {warning("STABLE_TAG missing; skipping.");process.exit(0);}-if (!webhookUrl && (!botToken || !channelId)) {- info(- "Discord announce skipped: set either a webhook URL (preferred) or both " +- "DISCORD_BOT_TOKEN and a channel id.",- );+if (!botToken || !channelId) {+ info("Discord announce skipped: set DISCORD_BOT_TOKEN and a channel id variable.");process.exit(0);}@@ -70,9 +58,10 @@ if (process.env.GITHUB_TOKEN) {}const isRc = kind === "rc";-const title = isRc+const embedTitle = isRc? `π§ͺ ${stableTag} release candidate ready for testing`: `π ${stableTag} released`;+const threadName = isRc ? `${stableTag} RC β testing` : `${stableTag} released`;const color = isRc ? 15844367 : 5814783;const description = [@@ -84,60 +73,87 @@ const description = [.filter(Boolean).join("\n");-const payload = {- embeds: [- {- title,- url: releaseUrl,- description,- color,- timestamp: new Date().toISOString(),- },- ],- allowed_mentions: { parse: [] },-};+async function fetchChannelType() {+ const res = await fetch(`https://discord.com/api/v10/channels/${channelId}`, {+ headers: { Authorization: `Bot ${botToken}` },+ });+ if (!res.ok) {+ const txt = await res.text();+ warning(`Discord channel fetch failed ${res.status}: ${txt}`);+ return null;+ }+ return res.json();+}-async function postViaWebhook() {- const endpoint = new URL(webhookUrl);- endpoint.searchParams.set("wait", "true");- const res = await fetch(endpoint.toString(), {+async function postToForum() {+ // Forum channel (type 15): create a thread, the first message is the announcement.+ const body = {+ name: threadName.slice(0, 100),+ message: {+ embeds: [+ {+ title: embedTitle,+ url: releaseUrl,+ description,+ color,+ timestamp: new Date().toISOString(),+ },+ ],+ allowed_mentions: { parse: [] },+ },+ };+ const res = await fetch(`https://discord.com/api/v10/channels/${channelId}/threads`, {method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({- username: WEBHOOK_USERNAME,- avatar_url: WEBHOOK_AVATAR || undefined,- ...payload,- }),+ headers: { Authorization: `Bot ${botToken}`, "Content-Type": "application/json" },+ body: JSON.stringify(body),});if (!res.ok) {const txt = await res.text();- warning(`Discord webhook POST failed ${res.status}: ${txt}`);+ warning(`Discord forum thread create failed ${res.status}: ${txt}`);return false;}- info(`π£ ${kind} announcement posted for ${stableTag} via webhook.`);+ const data = await res.json();+ info(`π£ ${kind} announcement posted to forum thread ${data.id}.`);return true;}-async function postViaBot() {+async function postToText() {+ const body = {+ embeds: [+ {+ title: embedTitle,+ url: releaseUrl,+ description,+ color,+ timestamp: new Date().toISOString(),+ },+ ],+ allowed_mentions: { parse: [] },+ };const res = await fetch(`https://discord.com/api/v10/channels/${channelId}/messages`, {method: "POST",- headers: {- Authorization: `Bot ${botToken}`,- "Content-Type": "application/json",- },- body: JSON.stringify(payload),+ headers: { Authorization: `Bot ${botToken}`, "Content-Type": "application/json" },+ body: JSON.stringify(body),});if (!res.ok) {const txt = await res.text();- warning(`Discord bot POST failed ${res.status}: ${txt}`);+ warning(`Discord message POST failed ${res.status}: ${txt}`);return false;}- info(`π£ ${kind} announcement posted for ${stableTag} via bot.`);+ info(`π£ ${kind} announcement posted to text channel.`);return true;}-if (webhookUrl) {- await postViaWebhook();+// Discord channel types that require a thread wrapper (no top-level messages).+const FORUM_LIKE_TYPES = new Set([15, 16]); // 15 = GUILD_FORUM, 16 = GUILD_MEDIA++const channel = await fetchChannelType();+if (!channel) {+ process.exit(0);+}++if (FORUM_LIKE_TYPES.has(channel.type)) {+ await postToForum();} else {- await postViaBot();+ await postToText();}diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.ymlindex 4f6209d11..e3f355928 100644--- a/.github/workflows/prerelease.yml+++ b/.github/workflows/prerelease.yml@@ -143,9 +143,6 @@ jobs:- name: Announce RC on Discord (#rc-testing)if: success()env:- # Webhook is preferred over bot+channel because #rc-testing is a forum channel,- # which only accepts posts via webhook (the bot can't create messages there directly).- DISCORD_RC_TESTING_WEBHOOK_URL: ${{ vars.DISCORD_RC_TESTING_WEBHOOK_URL }}DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}DISCORD_RC_TESTING_CHANNEL_ID: ${{ vars.DISCORD_RC_TESTING_CHANNEL_ID }}GITHUB_TOKEN: ${{ secrets.OPENSCREEN_RELEASE_TOKEN }}diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.ymlindex d15e5a51b..da7625071 100644--- a/.github/workflows/promote.yml+++ b/.github/workflows/promote.yml@@ -124,8 +124,6 @@ jobs:- name: Announce stable on Discordif: success()env:- # Webhook is preferred over bot+channel for forum/announcement channels.- DISCORD_RELEASE_WEBHOOK_URL: ${{ vars.DISCORD_RELEASE_WEBHOOK_URL }}DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}DISCORD_RELEASE_CHANNEL_ID: ${{ vars.DISCORD_RELEASE_CHANNEL_ID }}GITHUB_TOKEN: ${{ secrets.OPENSCREEN_RELEASE_TOKEN }}diff --git a/docs/secrets.md b/docs/secrets.mdindex 1e236575c..a0bc582f9 100644--- a/docs/secrets.md+++ b/docs/secrets.md@@ -94,29 +94,32 @@ gh api /repos/getopenscreen/openscreen/rulesets/18060803 --jq '.bypass_actors'Bot token from a Discord application added to the OpenScreen Discord server with the `bot` scope and at minimum:- `Send Messages` in any text channels where the bot posts+- `Create Public Threads` in the forum channels (for the release announce script)+- `Send Messages in Threads` so the first message in a new thread goes through- `Manage Messages` if you want the roadmap-sync workflow to pin its message- `Read Message History` (usually default)Stored as a repository secret.-### `DISCORD_RC_TESTING_WEBHOOK_URL` (preferred) or `DISCORD_RC_TESTING_CHANNEL_ID` (fallback)+### `DISCORD_RC_TESTING_CHANNEL_ID`-A **Discord webhook** for the `#rc-testing` channel. Each pre-release creates a new thread in the forum. Preferred because the channel is a forum and webhooks can create threads there, while a bot cannot post messages directly to a forum channel.+Snowflake ID of the Discord channel where release candidates are announced. Can be a regular text channel or a forum channel β the `discord-release-announce.mjs` script auto-detects the type:-To create: in Discord, channel βοΈ β Integrations β Webhooks β New Webhook β name it (e.g. "OpenScreen Releases") β Copy URL. Set as a **repository variable** (not a secret if it's a per-channel URL, but you can also set it as a secret if you want it private):+- **Text channel** (`type=0`): posts the announcement as a regular message.+- **Forum channel** (`type=15` or `16`): creates a new thread with the announcement as the first message. One thread per release, named like `v1.5.1-rc.1 RC β testing`.++Set as a **repository variable** (not a secret β it's not sensitive):```bash-gh variable set DISCORD_RC_TESTING_WEBHOOK_URL --body "https://discord.com/api/webhooks/<id>/<token>" --repo getopenscreen/openscreen+gh variable set DISCORD_RC_TESTING_CHANNEL_ID --body "1521416826146263051" --repo getopenscreen/openscreen```-If a webhook is not set, the script falls back to `DISCORD_BOT_TOKEN` + `DISCORD_RC_TESTING_CHANNEL_ID` (bot message in a text channel). Forum channels will not work via this fallback β it returns Discord error `50008 Cannot send messages in a non-text channel`.--### `DISCORD_RELEASE_WEBHOOK_URL` (preferred) or `DISCORD_RELEASE_CHANNEL_ID` (fallback)+### `DISCORD_RELEASE_CHANNEL_ID`-Same pattern as above, for the stable release announcement channel. Each stable release creates a new thread in the forum.+Same pattern as above, for the stable release announcement channel.```bash-gh variable set DISCORD_RELEASE_WEBHOOK_URL --body "https://discord.com/api/webhooks/<id>/<token>" --repo getopenscreen/openscreen+gh variable set DISCORD_RELEASE_CHANNEL_ID --body "<id>" --repo getopenscreen/openscreen```### `DISCORD_ROADMAP_CHANNEL_ID` and `DISCORD_ROADMAP_MESSAGE_ID`