diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5a0ecaa..85413fe 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,12 +17,19 @@ name: Release # lint/format commit that would trigger another bump. # # A second commit, stacked on top of the bump commit but never merged into -# main, adds the built .user.js files to git. GreasyFork's webhook-triggered -# sync does `git show :` against the real repository - it cannot -# see files that only exist as GitHub Release binary assets. Tagging that -# second commit (as the release tag, and as the floating `latest` tag) gives -# GreasyFork a git ref it can read the built file from, without ever putting -# build artifacts in main's history. +# main, adds the built .user.js files to git. GreasyFork's "release published" +# webhook event resolves a sync URL of the form +# .../releases/latest/download/.user.js to a *repo-root-relative* git +# path of exactly .user.js at the release's own tag (see +# lib/github.rb#file_from_root_for_url in GreasyFork's source - it strips the +# releases/.../download/ prefix and treats what's left as the whole path, so +# packages//dist/ nesting is not preserved), then reads it with +# `git show :`. That's why this commit mirrors each package's +# built file at repo root under that exact flat name, in addition to its +# normal packages//dist/ location. Tagging that commit (as the release +# tag, and as the floating `latest` tag) gives GreasyFork a git ref it can +# read both forms from, without ever putting build artifacts in main's +# history. on: push: @@ -210,6 +217,14 @@ jobs: exit 1 fi git add -f "$src" + + # Flat root-level mirror, named to match each package's + # @downloadURL/@updateURL asset name - see the comment above this + # step for why GreasyFork's release-webhook sync needs this exact + # path instead of the nested packages//dist/ one. + root_copy="${pkg_name}.user.js" + cp "$src" "$root_copy" + git add -f "$root_copy" done git commit -m "chore(release): include built userscripts for GreasyFork sync [skip ci]" echo "dist-sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" diff --git a/packages/github-actions-grafana-jump/package.json b/packages/github-actions-grafana-jump/package.json index 4257d95..cd3a028 100644 --- a/packages/github-actions-grafana-jump/package.json +++ b/packages/github-actions-grafana-jump/package.json @@ -1,6 +1,6 @@ { "name": "@nsheaps/gm-github-actions-grafana-jump", - "version": "0.2.2", + "version": "0.2.3", "main": "dist/index.js", "greasyforkPublish": true, "scripts": { diff --git a/packages/github-to-graphite-button/package.json b/packages/github-to-graphite-button/package.json index 0061da6..2d987e6 100644 --- a/packages/github-to-graphite-button/package.json +++ b/packages/github-to-graphite-button/package.json @@ -1,6 +1,6 @@ { "name": "@nsheaps/gm-github-to-graphite-button", - "version": "0.3.5", + "version": "0.3.6", "main": "dist/index.js", "private": true, "greasyforkPublish": true, diff --git a/packages/graphite-to-github-button/package.json b/packages/graphite-to-github-button/package.json index a9c8e77..99f4726 100644 --- a/packages/graphite-to-github-button/package.json +++ b/packages/graphite-to-github-button/package.json @@ -1,6 +1,6 @@ { "name": "@nsheaps/gm-graphite-to-github-button", - "version": "0.3.8", + "version": "0.3.9", "main": "dist/index.js", "greasyforkPublish": true, "scripts": { diff --git a/scripts/setup-greasyfork-webhook.js b/scripts/setup-greasyfork-webhook.js deleted file mode 100755 index 0f42d6e..0000000 --- a/scripts/setup-greasyfork-webhook.js +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env node - -const https = require("https"); -const readline = require("readline"); - -const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, -}); - -const questions = [ - "Enter your GreasyFork API key: ", - "Enter your GitHub repository URL (e.g., https://github.com/username/repo): ", - "Enter your GitHub webhook secret: ", -]; - -const answers = []; - -function askQuestion(index) { - if (index === questions.length) { - setupWebhook(answers[0], answers[1], answers[2]); - return; - } - - rl.question(questions[index], (answer) => { - answers.push(answer); - askQuestion(index + 1); - }); -} - -function setupWebhook(apiKey, repoUrl, secret) { - const options = { - hostname: "greasyfork.org", - path: "/en/users/webhook-info", - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${apiKey}`, - }, - }; - - const data = JSON.stringify({ - repository_url: repoUrl, - webhook_secret: secret, - }); - - const req = https.request(options, (res) => { - let responseData = ""; - - res.on("data", (chunk) => { - responseData += chunk; - }); - - res.on("end", () => { - if (res.statusCode === 200) { - console.log("Webhook setup successful!"); - } else { - console.error("Error setting up webhook:", responseData); - } - rl.close(); - }); - }); - - req.on("error", (error) => { - console.error("Error:", error); - rl.close(); - }); - - req.write(data); - req.end(); -} - -console.log("GreasyFork Webhook Setup"); -console.log("------------------------"); -askQuestion(0);